| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/files/file_enumerator.h" |
| 12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/test/thread_test_helper.h" | 15 #include "base/test/thread_test_helper.h" |
| 15 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
| 16 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_helper_browsertest.h" | 18 #include "chrome/browser/browsing_data/browsing_data_helper_browsertest.h" |
| 18 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 19 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/test/base/in_process_browser_test.h" | 22 #include "chrome/test/base/in_process_browser_test.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 } | 122 } |
| 122 | 123 |
| 123 IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, DeleteSingleFile) { | 124 IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, DeleteSingleFile) { |
| 124 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper( | 125 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper( |
| 125 new BrowsingDataLocalStorageHelper(browser()->profile())); | 126 new BrowsingDataLocalStorageHelper(browser()->profile())); |
| 126 CreateLocalStorageFilesForTest(); | 127 CreateLocalStorageFilesForTest(); |
| 127 local_storage_helper->DeleteOrigin(GURL(kOriginOfTestFile0)); | 128 local_storage_helper->DeleteOrigin(GURL(kOriginOfTestFile0)); |
| 128 BrowserThread::GetBlockingPool()->FlushForTesting(); | 129 BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 129 | 130 |
| 130 // Ensure the file has been deleted. | 131 // Ensure the file has been deleted. |
| 131 file_util::FileEnumerator file_enumerator( | 132 base::FileEnumerator file_enumerator( |
| 132 GetLocalStoragePathForTestingProfile(), | 133 GetLocalStoragePathForTestingProfile(), |
| 133 false, | 134 false, |
| 134 file_util::FileEnumerator::FILES); | 135 base::FileEnumerator::FILES); |
| 135 int num_files = 0; | 136 int num_files = 0; |
| 136 for (base::FilePath file_path = file_enumerator.Next(); | 137 for (base::FilePath file_path = file_enumerator.Next(); |
| 137 !file_path.empty(); | 138 !file_path.empty(); |
| 138 file_path = file_enumerator.Next()) { | 139 file_path = file_enumerator.Next()) { |
| 139 ASSERT_FALSE(base::FilePath(kTestFile0) == file_path.BaseName()); | 140 ASSERT_FALSE(base::FilePath(kTestFile0) == file_path.BaseName()); |
| 140 ++num_files; | 141 ++num_files; |
| 141 } | 142 } |
| 142 ASSERT_EQ(3, num_files); | 143 ASSERT_EQ(3, num_files); |
| 143 } | 144 } |
| 144 | 145 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 base::Bind(&TestCompletionCallback::callback, | 182 base::Bind(&TestCompletionCallback::callback, |
| 182 base::Unretained(&callback))); | 183 base::Unretained(&callback))); |
| 183 | 184 |
| 184 std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> result = | 185 std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> result = |
| 185 callback.result(); | 186 callback.result(); |
| 186 | 187 |
| 187 ASSERT_EQ(1u, result.size()); | 188 ASSERT_EQ(1u, result.size()); |
| 188 EXPECT_EQ(origin, result.begin()->origin_url); | 189 EXPECT_EQ(origin, result.begin()->origin_url); |
| 189 } | 190 } |
| 190 } // namespace | 191 } // namespace |
| OLD | NEW |