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/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_path.h" | 11 #include "base/file_path.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/test/thread_test_helper.h" | 14 #include "base/test/thread_test_helper.h" |
15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "chrome/browser/browsing_data_helper_browsertest.h" | 17 #include "chrome/browser/browsing_data_helper_browsertest.h" |
18 #include "chrome/browser/browsing_data_local_storage_helper.h" | 18 #include "chrome/browser/browsing_data_local_storage_helper.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
23 #include "content/public/browser/dom_storage_context.h" | 23 #include "content/public/browser/dom_storage_context.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "webkit/dom_storage/dom_storage_types.h" // For the ENABLE flag. | |
26 | 25 |
27 using content::BrowserContext; | 26 using content::BrowserContext; |
28 using content::BrowserThread; | 27 using content::BrowserThread; |
29 using content::DOMStorageContext; | 28 using content::DOMStorageContext; |
30 | 29 |
31 namespace { | 30 namespace { |
32 typedef | 31 typedef |
33 BrowsingDataHelperCallback<BrowsingDataLocalStorageHelper::LocalStorageInfo> | 32 BrowsingDataHelperCallback<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
34 TestCompletionCallback; | 33 TestCompletionCallback; |
35 | 34 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // Blocks until StopTestOnCallback::Callback is notified. | 117 // Blocks until StopTestOnCallback::Callback is notified. |
119 ui_test_utils::RunMessageLoop(); | 118 ui_test_utils::RunMessageLoop(); |
120 } | 119 } |
121 | 120 |
122 IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, DeleteSingleFile) { | 121 IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, DeleteSingleFile) { |
123 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper( | 122 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper( |
124 new BrowsingDataLocalStorageHelper(browser()->profile())); | 123 new BrowsingDataLocalStorageHelper(browser()->profile())); |
125 CreateLocalStorageFilesForTest(); | 124 CreateLocalStorageFilesForTest(); |
126 local_storage_helper->DeleteLocalStorageFile( | 125 local_storage_helper->DeleteLocalStorageFile( |
127 GetLocalStoragePathForTestingProfile().Append(FilePath(kTestFile0))); | 126 GetLocalStoragePathForTestingProfile().Append(FilePath(kTestFile0))); |
128 #ifdef ENABLE_NEW_DOM_STORAGE_BACKEND | |
129 BrowserThread::GetBlockingPool()->FlushForTesting(); | 127 BrowserThread::GetBlockingPool()->FlushForTesting(); |
130 #else | 128 |
131 scoped_refptr<base::ThreadTestHelper> wait_for_webkit_thread( | |
132 new base::ThreadTestHelper( | |
133 BrowserThread::GetMessageLoopProxyForThread( | |
134 BrowserThread::WEBKIT_DEPRECATED))); | |
135 ASSERT_TRUE(wait_for_webkit_thread->Run()); | |
136 #endif | |
137 // Ensure the file has been deleted. | 129 // Ensure the file has been deleted. |
138 file_util::FileEnumerator file_enumerator( | 130 file_util::FileEnumerator file_enumerator( |
139 GetLocalStoragePathForTestingProfile(), | 131 GetLocalStoragePathForTestingProfile(), |
140 false, | 132 false, |
141 file_util::FileEnumerator::FILES); | 133 file_util::FileEnumerator::FILES); |
142 int num_files = 0; | 134 int num_files = 0; |
143 for (FilePath file_path = file_enumerator.Next(); | 135 for (FilePath file_path = file_enumerator.Next(); |
144 !file_path.empty(); | 136 !file_path.empty(); |
145 file_path = file_enumerator.Next()) { | 137 file_path = file_enumerator.Next()) { |
146 ASSERT_FALSE(FilePath(kTestFile0) == file_path.BaseName()); | 138 ASSERT_FALSE(FilePath(kTestFile0) == file_path.BaseName()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 base::Unretained(&callback))); | 187 base::Unretained(&callback))); |
196 | 188 |
197 std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> result = | 189 std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> result = |
198 callback.result(); | 190 callback.result(); |
199 | 191 |
200 ASSERT_EQ(1u, result.size()); | 192 ASSERT_EQ(1u, result.size()); |
201 EXPECT_EQ(FilePath(file).value(), | 193 EXPECT_EQ(FilePath(file).value(), |
202 result.begin()->file_path.BaseName().value()); | 194 result.begin()->file_path.BaseName().value()); |
203 } | 195 } |
204 } // namespace | 196 } // namespace |
OLD | NEW |