Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: chrome/browser/browsing_data/browsing_data_local_storage_helper_browsertest.cc

Issue 409743003: Use content::RunBlockingPoolTask() in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
6
5 #include <string> 7 #include <string>
6 8
7 #include "base/basictypes.h" 9 #include "base/basictypes.h"
8 #include "base/bind.h" 10 #include "base/bind.h"
9 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
10 #include "base/callback.h" 12 #include "base/callback.h"
11 #include "base/files/file_enumerator.h" 13 #include "base/files/file_enumerator.h"
12 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
14 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
15 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
16 #include "base/test/thread_test_helper.h" 18 #include "base/test/thread_test_helper.h"
17 #include "base/threading/sequenced_worker_pool.h" 19 #include "base/threading/sequenced_worker_pool.h"
18 #include "chrome/browser/browsing_data/browsing_data_helper_browsertest.h" 20 #include "chrome/browser/browsing_data/browsing_data_helper_browsertest.h"
19 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
20 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
22 #include "chrome/test/base/in_process_browser_test.h" 23 #include "chrome/test/base/in_process_browser_test.h"
23 #include "chrome/test/base/ui_test_utils.h" 24 #include "chrome/test/base/ui_test_utils.h"
24 #include "content/public/browser/dom_storage_context.h" 25 #include "content/public/browser/dom_storage_context.h"
26 #include "content/public/test/test_utils.h"
25 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
26 28
27 using content::BrowserContext; 29 using content::BrowserContext;
28 using content::BrowserThread; 30 using content::BrowserThread;
29 using content::DOMStorageContext; 31 using content::DOMStorageContext;
30 32
31 namespace { 33 namespace {
32 typedef 34 typedef
33 BrowsingDataHelperCallback<BrowsingDataLocalStorageHelper::LocalStorageInfo> 35 BrowsingDataHelperCallback<BrowsingDataLocalStorageHelper::LocalStorageInfo>
34 TestCompletionCallback; 36 TestCompletionCallback;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 &StopTestOnCallback::Callback, base::Unretained(&stop_test_on_callback))); 121 &StopTestOnCallback::Callback, base::Unretained(&stop_test_on_callback)));
120 // Blocks until StopTestOnCallback::Callback is notified. 122 // Blocks until StopTestOnCallback::Callback is notified.
121 content::RunMessageLoop(); 123 content::RunMessageLoop();
122 } 124 }
123 125
124 IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, DeleteSingleFile) { 126 IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, DeleteSingleFile) {
125 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper( 127 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper(
126 new BrowsingDataLocalStorageHelper(browser()->profile())); 128 new BrowsingDataLocalStorageHelper(browser()->profile()));
127 CreateLocalStorageFilesForTest(); 129 CreateLocalStorageFilesForTest();
128 local_storage_helper->DeleteOrigin(GURL(kOriginOfTestFile0)); 130 local_storage_helper->DeleteOrigin(GURL(kOriginOfTestFile0));
129 BrowserThread::GetBlockingPool()->FlushForTesting(); 131 content::RunAllBlockingPoolTasksUntilIdle();
130 132
131 // Ensure the file has been deleted. 133 // Ensure the file has been deleted.
132 base::FileEnumerator file_enumerator( 134 base::FileEnumerator file_enumerator(
133 GetLocalStoragePathForTestingProfile(), 135 GetLocalStoragePathForTestingProfile(),
134 false, 136 false,
135 base::FileEnumerator::FILES); 137 base::FileEnumerator::FILES);
136 int num_files = 0; 138 int num_files = 0;
137 for (base::FilePath file_path = file_enumerator.Next(); 139 for (base::FilePath file_path = file_enumerator.Next();
138 !file_path.empty(); 140 !file_path.empty();
139 file_path = file_enumerator.Next()) { 141 file_path = file_enumerator.Next()) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 base::Bind(&TestCompletionCallback::callback, 184 base::Bind(&TestCompletionCallback::callback,
183 base::Unretained(&callback))); 185 base::Unretained(&callback)));
184 186
185 std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> result = 187 std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> result =
186 callback.result(); 188 callback.result();
187 189
188 ASSERT_EQ(1u, result.size()); 190 ASSERT_EQ(1u, result.size());
189 EXPECT_EQ(origin, result.begin()->origin_url); 191 EXPECT_EQ(origin, result.begin()->origin_url);
190 } 192 }
191 } // namespace 193 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698