| 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 13 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
| 14 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
| 15 #include "content/public/browser/storage_partition.h" |
| 15 #include "content/public/test/test_browser_thread.h" | 16 #include "content/public/test/test_browser_thread.h" |
| 16 #include "webkit/fileapi/file_system_context.h" | 17 #include "webkit/fileapi/file_system_context.h" |
| 17 #include "webkit/fileapi/file_system_types.h" | 18 #include "webkit/fileapi/file_system_types.h" |
| 18 #include "webkit/fileapi/file_system_usage_cache.h" | 19 #include "webkit/fileapi/file_system_usage_cache.h" |
| 19 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 20 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 20 | 21 |
| 21 using content::BrowserContext; | 22 using content::BrowserContext; |
| 22 using content::BrowserThread; | 23 using content::BrowserThread; |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 public: | 63 public: |
| 63 BrowsingDataFileSystemHelperTest() | 64 BrowsingDataFileSystemHelperTest() |
| 64 : ui_thread_(BrowserThread::UI, &message_loop_), | 65 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 65 db_thread_(BrowserThread::DB, &message_loop_), | 66 db_thread_(BrowserThread::DB, &message_loop_), |
| 66 webkit_thread_(BrowserThread::WEBKIT_DEPRECATED, &message_loop_), | 67 webkit_thread_(BrowserThread::WEBKIT_DEPRECATED, &message_loop_), |
| 67 file_thread_(BrowserThread::FILE, &message_loop_), | 68 file_thread_(BrowserThread::FILE, &message_loop_), |
| 68 file_user_blocking_thread_( | 69 file_user_blocking_thread_( |
| 69 BrowserThread::FILE_USER_BLOCKING, &message_loop_), | 70 BrowserThread::FILE_USER_BLOCKING, &message_loop_), |
| 70 io_thread_(BrowserThread::IO, &message_loop_) { | 71 io_thread_(BrowserThread::IO, &message_loop_) { |
| 71 profile_.reset(new TestingProfile()); | 72 profile_.reset(new TestingProfile()); |
| 72 helper_ = BrowsingDataFileSystemHelper::Create(profile_.get()); | 73 |
| 74 helper_ = BrowsingDataFileSystemHelper::Create( |
| 75 BrowserContext::GetDefaultStoragePartition(profile_.get())-> |
| 76 GetFileSystemContext()); |
| 73 message_loop_.RunAllPending(); | 77 message_loop_.RunAllPending(); |
| 74 canned_helper_ = new CannedBrowsingDataFileSystemHelper(profile_.get()); | 78 canned_helper_ = new CannedBrowsingDataFileSystemHelper(profile_.get()); |
| 75 } | 79 } |
| 76 virtual ~BrowsingDataFileSystemHelperTest() { | 80 virtual ~BrowsingDataFileSystemHelperTest() { |
| 77 // Avoid memory leaks. | 81 // Avoid memory leaks. |
| 78 profile_.reset(); | 82 profile_.reset(); |
| 79 message_loop_.RunAllPending(); | 83 message_loop_.RunAllPending(); |
| 80 } | 84 } |
| 81 | 85 |
| 82 TestingProfile* GetProfile() { | 86 TestingProfile* GetProfile() { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 void FetchCannedFileSystems() { | 145 void FetchCannedFileSystems() { |
| 142 canned_helper_->StartFetching( | 146 canned_helper_->StartFetching( |
| 143 base::Bind(&BrowsingDataFileSystemHelperTest::CallbackStartFetching, | 147 base::Bind(&BrowsingDataFileSystemHelperTest::CallbackStartFetching, |
| 144 base::Unretained(this))); | 148 base::Unretained(this))); |
| 145 BlockUntilNotified(); | 149 BlockUntilNotified(); |
| 146 } | 150 } |
| 147 | 151 |
| 148 // Sets up kOrigin1 with a temporary file system, kOrigin2 with a persistent | 152 // Sets up kOrigin1 with a temporary file system, kOrigin2 with a persistent |
| 149 // file system, and kOrigin3 with both. | 153 // file system, and kOrigin3 with both. |
| 150 virtual void PopulateTestFileSystemData() { | 154 virtual void PopulateTestFileSystemData() { |
| 151 sandbox_ = BrowserContext::GetFileSystemContext(profile_.get())-> | 155 sandbox_ = BrowserContext::GetDefaultStoragePartition(profile_.get())-> |
| 152 sandbox_provider(); | 156 GetFileSystemContext()->sandbox_provider(); |
| 153 | 157 |
| 154 CreateDirectoryForOriginAndType(kOrigin1, kTemporary); | 158 CreateDirectoryForOriginAndType(kOrigin1, kTemporary); |
| 155 CreateDirectoryForOriginAndType(kOrigin2, kPersistent); | 159 CreateDirectoryForOriginAndType(kOrigin2, kPersistent); |
| 156 CreateDirectoryForOriginAndType(kOrigin3, kTemporary); | 160 CreateDirectoryForOriginAndType(kOrigin3, kTemporary); |
| 157 CreateDirectoryForOriginAndType(kOrigin3, kPersistent); | 161 CreateDirectoryForOriginAndType(kOrigin3, kPersistent); |
| 158 | 162 |
| 159 EXPECT_FALSE(FileSystemContainsOriginAndType(kOrigin1, kPersistent)); | 163 EXPECT_FALSE(FileSystemContainsOriginAndType(kOrigin1, kPersistent)); |
| 160 EXPECT_TRUE(FileSystemContainsOriginAndType(kOrigin1, kTemporary)); | 164 EXPECT_TRUE(FileSystemContainsOriginAndType(kOrigin1, kTemporary)); |
| 161 EXPECT_TRUE(FileSystemContainsOriginAndType(kOrigin2, kPersistent)); | 165 EXPECT_TRUE(FileSystemContainsOriginAndType(kOrigin2, kPersistent)); |
| 162 EXPECT_FALSE(FileSystemContainsOriginAndType(kOrigin2, kTemporary)); | 166 EXPECT_FALSE(FileSystemContainsOriginAndType(kOrigin2, kTemporary)); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 // extension and devtools schemes. | 313 // extension and devtools schemes. |
| 310 TEST_F(BrowsingDataFileSystemHelperTest, IgnoreExtensionsAndDevTools) { | 314 TEST_F(BrowsingDataFileSystemHelperTest, IgnoreExtensionsAndDevTools) { |
| 311 ASSERT_TRUE(canned_helper_->empty()); | 315 ASSERT_TRUE(canned_helper_->empty()); |
| 312 canned_helper_->AddFileSystem(kOriginExt, kTemporary, 0); | 316 canned_helper_->AddFileSystem(kOriginExt, kTemporary, 0); |
| 313 ASSERT_TRUE(canned_helper_->empty()); | 317 ASSERT_TRUE(canned_helper_->empty()); |
| 314 canned_helper_->AddFileSystem(kOriginDevTools, kTemporary, 0); | 318 canned_helper_->AddFileSystem(kOriginDevTools, kTemporary, 0); |
| 315 ASSERT_TRUE(canned_helper_->empty()); | 319 ASSERT_TRUE(canned_helper_->empty()); |
| 316 } | 320 } |
| 317 | 321 |
| 318 } // namespace | 322 } // namespace |
| OLD | NEW |