OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 11 #include "base/bind.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/files/scoped_temp_dir.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
16 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
17 #include "base/message_loop_proxy.h" | 18 #include "base/message_loop_proxy.h" |
18 #include "base/platform_file.h" | 19 #include "base/platform_file.h" |
19 #include "base/scoped_temp_dir.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_context.h" | 22 #include "webkit/fileapi/file_system_context.h" |
23 #include "webkit/fileapi/file_system_mount_point_provider.h" | 23 #include "webkit/fileapi/file_system_mount_point_provider.h" |
24 #include "webkit/fileapi/file_system_operation_context.h" | 24 #include "webkit/fileapi/file_system_operation_context.h" |
25 #include "webkit/fileapi/file_system_task_runners.h" | 25 #include "webkit/fileapi/file_system_task_runners.h" |
26 #include "webkit/fileapi/file_system_url.h" | 26 #include "webkit/fileapi/file_system_url.h" |
27 #include "webkit/fileapi/file_system_util.h" | 27 #include "webkit/fileapi/file_system_util.h" |
28 #include "webkit/fileapi/file_util_helper.h" | 28 #include "webkit/fileapi/file_util_helper.h" |
29 #include "webkit/fileapi/mock_file_system_options.h" | 29 #include "webkit/fileapi/mock_file_system_options.h" |
(...skipping 22 matching lines...) Expand all Loading... |
52 | 52 |
53 protected: | 53 protected: |
54 void CreateOriginTypeDirectory(const GURL& origin, | 54 void CreateOriginTypeDirectory(const GURL& origin, |
55 fileapi::FileSystemType type) { | 55 fileapi::FileSystemType type) { |
56 FilePath target = sandbox_provider_-> | 56 FilePath target = sandbox_provider_-> |
57 GetBaseDirectoryForOriginAndType(origin, type, true); | 57 GetBaseDirectoryForOriginAndType(origin, type, true); |
58 ASSERT_TRUE(!target.empty()); | 58 ASSERT_TRUE(!target.empty()); |
59 ASSERT_TRUE(file_util::DirectoryExists(target)); | 59 ASSERT_TRUE(file_util::DirectoryExists(target)); |
60 } | 60 } |
61 | 61 |
62 ScopedTempDir data_dir_; | 62 base::ScopedTempDir data_dir_; |
63 MessageLoop message_loop_; | 63 MessageLoop message_loop_; |
64 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; | 64 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; |
65 }; | 65 }; |
66 | 66 |
67 TEST_F(SandboxMountPointProviderOriginEnumeratorTest, Empty) { | 67 TEST_F(SandboxMountPointProviderOriginEnumeratorTest, Empty) { |
68 scoped_ptr<SandboxMountPointProvider::OriginEnumerator> enumerator( | 68 scoped_ptr<SandboxMountPointProvider::OriginEnumerator> enumerator( |
69 CreateEnumerator()); | 69 CreateEnumerator()); |
70 ASSERT_TRUE(enumerator->Next().is_empty()); | 70 ASSERT_TRUE(enumerator->Next().is_empty()); |
71 } | 71 } |
72 | 72 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 const GURL& origin_url = test_case.origin; | 322 const GURL& origin_url = test_case.origin; |
323 ASSERT_TRUE(test_case.has_temporary || test_case.has_persistent); | 323 ASSERT_TRUE(test_case.has_temporary || test_case.has_persistent); |
324 if (test_case.has_temporary) | 324 if (test_case.has_temporary) |
325 ValidateDataInNewFileSystem(origin_url, kFileSystemTypeTemporary); | 325 ValidateDataInNewFileSystem(origin_url, kFileSystemTypeTemporary); |
326 if (test_case.has_persistent) | 326 if (test_case.has_persistent) |
327 ValidateDataInNewFileSystem(origin_url, kFileSystemTypePersistent); | 327 ValidateDataInNewFileSystem(origin_url, kFileSystemTypePersistent); |
328 } | 328 } |
329 } | 329 } |
330 | 330 |
331 protected: | 331 protected: |
332 ScopedTempDir data_dir_; | 332 base::ScopedTempDir data_dir_; |
333 MessageLoop message_loop_; | 333 MessageLoop message_loop_; |
334 scoped_refptr<FileSystemContext> file_system_context_; | 334 scoped_refptr<FileSystemContext> file_system_context_; |
335 base::WeakPtrFactory<SandboxMountPointProviderMigrationTest> weak_factory_; | 335 base::WeakPtrFactory<SandboxMountPointProviderMigrationTest> weak_factory_; |
336 }; | 336 }; |
337 | 337 |
338 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod0) { | 338 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod0) { |
339 RunMigrationTest(0); | 339 RunMigrationTest(0); |
340 } | 340 } |
341 | 341 |
342 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod1) { | 342 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod1) { |
(...skipping 14 matching lines...) Expand all Loading... |
357 | 357 |
358 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod5) { | 358 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod5) { |
359 RunMigrationTest(5); | 359 RunMigrationTest(5); |
360 } | 360 } |
361 | 361 |
362 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod6) { | 362 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod6) { |
363 RunMigrationTest(6); | 363 RunMigrationTest(6); |
364 } | 364 } |
365 | 365 |
366 } // namespace fileapi | 366 } // namespace fileapi |
OLD | NEW |