| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/test/thread_test_helper.h" |
| 12 #include "chrome/browser/browsing_data_helper_browsertest.h" | 13 #include "chrome/browser/browsing_data_helper_browsertest.h" |
| 13 #include "chrome/browser/browsing_data_local_storage_helper.h" | 14 #include "chrome/browser/browsing_data_local_storage_helper.h" |
| 14 #include "chrome/test/in_process_browser_test.h" | 15 #include "chrome/test/in_process_browser_test.h" |
| 15 #include "chrome/test/testing_profile.h" | 16 #include "chrome/test/testing_profile.h" |
| 16 #include "chrome/test/thread_test_helper.h" | |
| 17 #include "chrome/test/ui_test_utils.h" | 17 #include "chrome/test/ui_test_utils.h" |
| 18 #include "content/browser/in_process_webkit/webkit_context.h" | 18 #include "content/browser/in_process_webkit/webkit_context.h" |
| 19 #include "content/browser/in_process_webkit/webkit_thread.h" | 19 #include "content/browser/in_process_webkit/webkit_thread.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 typedef | 23 typedef |
| 24 BrowsingDataHelperCallback<BrowsingDataLocalStorageHelper::LocalStorageInfo> | 24 BrowsingDataHelperCallback<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
| 25 TestCompletionCallback; | 25 TestCompletionCallback; |
| 26 | 26 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // Blocks until StopTestOnCallback::Callback is notified. | 109 // Blocks until StopTestOnCallback::Callback is notified. |
| 110 ui_test_utils::RunMessageLoop(); | 110 ui_test_utils::RunMessageLoop(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, DeleteSingleFile) { | 113 IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, DeleteSingleFile) { |
| 114 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper( | 114 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper( |
| 115 new BrowsingDataLocalStorageHelper(&testing_profile_)); | 115 new BrowsingDataLocalStorageHelper(&testing_profile_)); |
| 116 CreateLocalStorageFilesForTest(); | 116 CreateLocalStorageFilesForTest(); |
| 117 local_storage_helper->DeleteLocalStorageFile( | 117 local_storage_helper->DeleteLocalStorageFile( |
| 118 GetLocalStoragePathForTestingProfile().Append(FilePath(kTestFile0))); | 118 GetLocalStoragePathForTestingProfile().Append(FilePath(kTestFile0))); |
| 119 scoped_refptr<ThreadTestHelper> wait_for_webkit_thread( | 119 scoped_refptr<base::ThreadTestHelper> wait_for_webkit_thread( |
| 120 new ThreadTestHelper(BrowserThread::WEBKIT)); | 120 new base::ThreadTestHelper( |
| 121 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::WEBKIT))); |
| 121 ASSERT_TRUE(wait_for_webkit_thread->Run()); | 122 ASSERT_TRUE(wait_for_webkit_thread->Run()); |
| 122 // Ensure the file has been deleted. | 123 // Ensure the file has been deleted. |
| 123 file_util::FileEnumerator file_enumerator( | 124 file_util::FileEnumerator file_enumerator( |
| 124 GetLocalStoragePathForTestingProfile(), | 125 GetLocalStoragePathForTestingProfile(), |
| 125 false, | 126 false, |
| 126 file_util::FileEnumerator::FILES); | 127 file_util::FileEnumerator::FILES); |
| 127 int num_files = 0; | 128 int num_files = 0; |
| 128 for (FilePath file_path = file_enumerator.Next(); | 129 for (FilePath file_path = file_enumerator.Next(); |
| 129 !file_path.empty(); | 130 !file_path.empty(); |
| 130 file_path = file_enumerator.Next()) { | 131 file_path = file_enumerator.Next()) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 helper->StartFetching( | 175 helper->StartFetching( |
| 175 NewCallback(&callback, &TestCompletionCallback::callback)); | 176 NewCallback(&callback, &TestCompletionCallback::callback)); |
| 176 | 177 |
| 177 std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> result = | 178 std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> result = |
| 178 callback.result(); | 179 callback.result(); |
| 179 | 180 |
| 180 ASSERT_EQ(1u, result.size()); | 181 ASSERT_EQ(1u, result.size()); |
| 181 EXPECT_EQ(FilePath(file).value(), result[0].file_path.BaseName().value()); | 182 EXPECT_EQ(FilePath(file).value(), result[0].file_path.BaseName().value()); |
| 182 } | 183 } |
| 183 } // namespace | 184 } // namespace |
| OLD | NEW |