Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Side by Side Diff: webkit/fileapi/file_system_path_manager_unittest.cc

Issue 7633016: Test cleanup: Using MockSpecialStoragePolicy instead of local subclasses of SpecialStoragePolicy. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Oops, cleaning up leftover TestSpecialStoragePolicy classes. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/fileapi/file_system_path_manager.h" 5 #include "webkit/fileapi/file_system_path_manager.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_callback_factory.h" 13 #include "base/memory/scoped_callback_factory.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/message_loop_proxy.h" 16 #include "base/message_loop_proxy.h"
17 #include "base/scoped_temp_dir.h" 17 #include "base/scoped_temp_dir.h"
18 #include "base/sys_string_conversions.h" 18 #include "base/sys_string_conversions.h"
19 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "webkit/fileapi/file_system_util.h" 22 #include "webkit/fileapi/file_system_util.h"
23 #include "webkit/fileapi/sandbox_mount_point_provider.h" 23 #include "webkit/fileapi/sandbox_mount_point_provider.h"
24 #include "webkit/quota/special_storage_policy.h" 24 #include "webkit/quota/mock_special_storage_policy.h"
25 25
26 namespace fileapi { 26 namespace fileapi {
27 namespace { 27 namespace {
28 28
29 // PS stands for path separator. 29 // PS stands for path separator.
30 #if defined(FILE_PATH_USES_WIN_SEPARATORS) 30 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
31 #define PS "\\" 31 #define PS "\\"
32 #else 32 #else
33 #define PS "/" 33 #define PS "/"
34 #endif 34 #endif
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 FilePath UTF8ToFilePath(const std::string& str) { 198 FilePath UTF8ToFilePath(const std::string& str) {
199 FilePath::StringType result; 199 FilePath::StringType result;
200 #if defined(OS_POSIX) 200 #if defined(OS_POSIX)
201 result = base::SysWideToNativeMB(UTF8ToWide(str)); 201 result = base::SysWideToNativeMB(UTF8ToWide(str));
202 #elif defined(OS_WIN) 202 #elif defined(OS_WIN)
203 result = UTF8ToUTF16(str); 203 result = UTF8ToUTF16(str);
204 #endif 204 #endif
205 return FilePath(result); 205 return FilePath(result);
206 } 206 }
207 207
208 class TestSpecialStoragePolicy : public quota::SpecialStoragePolicy {
209 public:
210 virtual bool IsStorageProtected(const GURL& origin) {
211 return false;
212 }
213
214 virtual bool IsStorageUnlimited(const GURL& origin) {
marja 2011/08/16 10:54:25 IsStorageUnlimited & IsFileHandler here were never
215 return true;
216 }
217
218 virtual bool IsFileHandler(const std::string& extension_id) {
219 return true;
220 }
221 };
222
223 } // namespace 208 } // namespace
224 209
225 class FileSystemPathManagerTest : public testing::Test { 210 class FileSystemPathManagerTest : public testing::Test {
226 public: 211 public:
227 FileSystemPathManagerTest() 212 FileSystemPathManagerTest()
228 : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 213 : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
229 } 214 }
230 215
231 void SetUp() { 216 void SetUp() {
232 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); 217 ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
233 root_path_callback_status_ = false; 218 root_path_callback_status_ = false;
234 root_path_.clear(); 219 root_path_.clear();
235 file_system_name_.clear(); 220 file_system_name_.clear();
236 } 221 }
237 222
238 protected: 223 protected:
239 FileSystemPathManager* NewPathManager( 224 FileSystemPathManager* NewPathManager(
240 bool incognito, 225 bool incognito,
241 bool allow_file_access) { 226 bool allow_file_access) {
242 FileSystemPathManager* manager = new FileSystemPathManager( 227 FileSystemPathManager* manager = new FileSystemPathManager(
243 base::MessageLoopProxy::CreateForCurrentThread(), 228 base::MessageLoopProxy::CreateForCurrentThread(),
244 data_dir_.path(), 229 data_dir_.path(),
245 scoped_refptr<quota::SpecialStoragePolicy>( 230 scoped_refptr<quota::SpecialStoragePolicy>(
246 new TestSpecialStoragePolicy()), 231 new quota::MockSpecialStoragePolicy),
247 incognito, 232 incognito,
248 allow_file_access); 233 allow_file_access);
249 #if defined(OS_CHROMEOS) 234 #if defined(OS_CHROMEOS)
250 fileapi::ExternalFileSystemMountPointProvider* ext_provider = 235 fileapi::ExternalFileSystemMountPointProvider* ext_provider =
251 manager->external_provider(); 236 manager->external_provider();
252 ext_provider->AddMountPoint(FilePath("/tmp/testing")); 237 ext_provider->AddMountPoint(FilePath("/tmp/testing"));
253 #endif 238 #endif
254 return manager; 239 return manager;
255 } 240 }
256 241
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kIsRestrictedNameTestCases); ++i) { 418 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kIsRestrictedNameTestCases); ++i) {
434 SCOPED_TRACE(testing::Message() << "IsRestrictedName #" << i << " " 419 SCOPED_TRACE(testing::Message() << "IsRestrictedName #" << i << " "
435 << kIsRestrictedNameTestCases[i].name); 420 << kIsRestrictedNameTestCases[i].name);
436 FilePath name(kIsRestrictedNameTestCases[i].name); 421 FilePath name(kIsRestrictedNameTestCases[i].name);
437 EXPECT_EQ(kIsRestrictedNameTestCases[i].expected_dangerous, 422 EXPECT_EQ(kIsRestrictedNameTestCases[i].expected_dangerous,
438 manager->IsRestrictedFileName(kFileSystemTypeTemporary, name)); 423 manager->IsRestrictedFileName(kFileSystemTypeTemporary, name));
439 } 424 }
440 } 425 }
441 426
442 } // namespace fileapi 427 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698