OLD | NEW |
---|---|
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/sandbox_mount_point_provider.h" | 5 #include "webkit/fileapi/sandbox_mount_point_provider.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/platform_file.h" | 17 #include "base/platform_file.h" |
18 #include "base/scoped_temp_dir.h" | 18 #include "base/scoped_temp_dir.h" |
19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "webkit/fileapi/file_system_context.h" | 21 #include "webkit/fileapi/file_system_context.h" |
22 #include "webkit/fileapi/file_system_operation_context.h" | 22 #include "webkit/fileapi/file_system_operation_context.h" |
23 #include "webkit/fileapi/file_system_path_manager.h" | 23 #include "webkit/fileapi/file_system_path_manager.h" |
24 #include "webkit/fileapi/file_system_util.h" | 24 #include "webkit/fileapi/file_system_util.h" |
25 #include "webkit/quota/mock_special_storage_policy.h" | |
25 | 26 |
26 namespace fileapi { | 27 namespace fileapi { |
27 | 28 |
28 class MockFileSystemPathManager : public FileSystemPathManager { | 29 class MockFileSystemPathManager : public FileSystemPathManager { |
29 public: | 30 public: |
30 explicit MockFileSystemPathManager(const FilePath& profile_path) | 31 explicit MockFileSystemPathManager(const FilePath& profile_path) |
31 : FileSystemPathManager(base::MessageLoopProxy::CreateForCurrentThread(), | 32 : FileSystemPathManager(base::MessageLoopProxy::CreateForCurrentThread(), |
32 profile_path, NULL, false, true) {} | 33 profile_path, NULL, false, true) {} |
33 }; | 34 }; |
34 | 35 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 | 121 |
121 const MigrationTestCaseRecord kMigrationTestRecords[] = { | 122 const MigrationTestCaseRecord kMigrationTestRecords[] = { |
122 { GURL("http://www.example.com"), true, false }, | 123 { GURL("http://www.example.com"), true, false }, |
123 { GURL("http://example.com"), false, true }, | 124 { GURL("http://example.com"), false, true }, |
124 { GURL("http://www.google.com"), false, true }, | 125 { GURL("http://www.google.com"), false, true }, |
125 { GURL("http://www.another.origin.com"), true, true }, | 126 { GURL("http://www.another.origin.com"), true, true }, |
126 { GURL("http://www.yet.another.origin.com"), true, true }, | 127 { GURL("http://www.yet.another.origin.com"), true, true }, |
127 { GURL("file:///"), false, true }, | 128 { GURL("file:///"), false, true }, |
128 }; | 129 }; |
129 | 130 |
130 class TestSpecialStoragePolicy : public quota::SpecialStoragePolicy { | |
131 public: | |
132 explicit TestSpecialStoragePolicy(bool unlimited_quota) | |
133 : unlimited_quota_(unlimited_quota) {} | |
134 | |
135 virtual bool IsStorageProtected(const GURL& origin) { | |
136 return false; | |
137 } | |
138 | |
139 virtual bool IsStorageUnlimited(const GURL& origin) { | |
140 return unlimited_quota_; | |
141 } | |
142 | |
143 virtual bool IsFileHandler(const std::string& extension_id) { | |
144 return true; | |
145 } | |
146 | |
147 private: | |
148 bool unlimited_quota_; | |
149 }; | |
150 | |
151 } // anonymous namespace | 131 } // anonymous namespace |
152 | 132 |
153 class SandboxMountPointProviderMigrationTest : public testing::Test { | 133 class SandboxMountPointProviderMigrationTest : public testing::Test { |
154 public: | 134 public: |
155 SandboxMountPointProviderMigrationTest() : | 135 SandboxMountPointProviderMigrationTest() : |
156 ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) { | 136 ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) { |
157 } | 137 } |
158 | 138 |
159 void SetUp() { | 139 void SetUp() { |
160 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 140 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
161 path_manager_ = new MockFileSystemPathManager(data_dir_.path()); | 141 path_manager_ = new MockFileSystemPathManager(data_dir_.path()); |
162 | 142 |
163 file_system_context_ = new FileSystemContext( | 143 file_system_context_ = new FileSystemContext( |
164 base::MessageLoopProxy::CreateForCurrentThread(), | 144 base::MessageLoopProxy::CreateForCurrentThread(), |
165 base::MessageLoopProxy::CreateForCurrentThread(), | 145 base::MessageLoopProxy::CreateForCurrentThread(), |
166 new TestSpecialStoragePolicy(true /* unlimited quota */), | 146 new quota::MockSpecialStoragePolicy, |
marja
2011/08/16 10:54:25
I changed this to use the "all unlimited" mode of
| |
167 NULL, | 147 NULL, |
168 data_dir_.path(), | 148 data_dir_.path(), |
169 false, // incognito | 149 false, // incognito |
170 true, // allow_file_access_from_files | 150 true, // allow_file_access_from_files |
171 true, // unlimited quota | 151 true, // unlimited quota |
172 path_manager_); | 152 path_manager_); |
173 } | 153 } |
174 | 154 |
175 FileSystemPathManager* path_manager() { | 155 FileSystemPathManager* path_manager() { |
176 return path_manager_; | 156 return path_manager_; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
416 | 396 |
417 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod8) { | 397 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod8) { |
418 RunMigrationTest(8); | 398 RunMigrationTest(8); |
419 } | 399 } |
420 | 400 |
421 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod9) { | 401 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod9) { |
422 RunMigrationTest(9); | 402 RunMigrationTest(9); |
423 } | 403 } |
424 | 404 |
425 } // namespace fileapi | 405 } // namespace fileapi |
OLD | NEW |