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

Side by Side Diff: components/safe_browsing_db/v4_database_unittest.cc

Issue 2053913002: Remove MessageLoop::current()->RunUntilIdle() in components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/debug/leak_annotations.h" 6 #include "base/debug/leak_annotations.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h"
9 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
10 #include "components/safe_browsing_db/v4_database.h" 11 #include "components/safe_browsing_db/v4_database.h"
11 #include "components/safe_browsing_db/v4_store.h" 12 #include "components/safe_browsing_db/v4_store.h"
12 #include "content/public/test/test_browser_thread_bundle.h" 13 #include "content/public/test/test_browser_thread_bundle.h"
13 #include "testing/platform_test.h" 14 #include "testing/platform_test.h"
14 15
15 namespace safe_browsing { 16 namespace safe_browsing {
16 17
17 class FakeV4Store : public V4Store { 18 class FakeV4Store : public V4Store {
18 public: 19 public:
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 TEST_F(SafeBrowsingV4DatabaseTest, TestSetupDatabaseWithNoStores) { 130 TEST_F(SafeBrowsingV4DatabaseTest, TestSetupDatabaseWithNoStores) {
130 NewDatabaseReadyCallback callback_db_ready = base::Bind( 131 NewDatabaseReadyCallback callback_db_ready = base::Bind(
131 &SafeBrowsingV4DatabaseTest::NewDatabaseReadyWithExpectedStorePathsAndIds, 132 &SafeBrowsingV4DatabaseTest::NewDatabaseReadyWithExpectedStorePathsAndIds,
132 base::Unretained(this), expected_store_paths_, expected_identifiers_, 133 base::Unretained(this), expected_store_paths_, expected_identifiers_,
133 true); 134 true);
134 V4Database::Create(task_runner_, database_dirname_, list_info_map_, 135 V4Database::Create(task_runner_, database_dirname_, list_info_map_,
135 callback_db_ready); 136 callback_db_ready);
136 created_but_not_called_back_ = true; 137 created_but_not_called_back_ = true;
137 task_runner_->RunPendingTasks(); 138 task_runner_->RunPendingTasks();
138 139
139 base::MessageLoop::current()->RunUntilIdle(); 140 base::RunLoop().RunUntilIdle();
140 EXPECT_EQ(true, created_and_called_back_); 141 EXPECT_EQ(true, created_and_called_back_);
141 } 142 }
142 143
143 // Test to set up the database with fake stores. 144 // Test to set up the database with fake stores.
144 TEST_F(SafeBrowsingV4DatabaseTest, TestSetupDatabaseWithFakeStores) { 145 TEST_F(SafeBrowsingV4DatabaseTest, TestSetupDatabaseWithFakeStores) {
145 SetupInfoMapAndExpectedState(); 146 SetupInfoMapAndExpectedState();
146 147
147 NewDatabaseReadyCallback callback_db_ready = base::Bind( 148 NewDatabaseReadyCallback callback_db_ready = base::Bind(
148 &SafeBrowsingV4DatabaseTest::NewDatabaseReadyWithExpectedStorePathsAndIds, 149 &SafeBrowsingV4DatabaseTest::NewDatabaseReadyWithExpectedStorePathsAndIds,
149 base::Unretained(this), expected_store_paths_, expected_identifiers_, 150 base::Unretained(this), expected_store_paths_, expected_identifiers_,
150 true); 151 true);
151 152
152 FakeV4StoreFactory* factory = new FakeV4StoreFactory(false); 153 FakeV4StoreFactory* factory = new FakeV4StoreFactory(false);
153 ANNOTATE_LEAKING_OBJECT_PTR(factory); 154 ANNOTATE_LEAKING_OBJECT_PTR(factory);
154 V4Database::RegisterStoreFactoryForTest(factory); 155 V4Database::RegisterStoreFactoryForTest(factory);
155 V4Database::Create(task_runner_, database_dirname_, list_info_map_, 156 V4Database::Create(task_runner_, database_dirname_, list_info_map_,
156 callback_db_ready); 157 callback_db_ready);
157 created_but_not_called_back_ = true; 158 created_but_not_called_back_ = true;
158 task_runner_->RunPendingTasks(); 159 task_runner_->RunPendingTasks();
159 160
160 base::MessageLoop::current()->RunUntilIdle(); 161 base::RunLoop().RunUntilIdle();
161 EXPECT_EQ(true, created_and_called_back_); 162 EXPECT_EQ(true, created_and_called_back_);
162 } 163 }
163 164
164 // Test to set up the database with fake stores that fail to reset. 165 // Test to set up the database with fake stores that fail to reset.
165 TEST_F(SafeBrowsingV4DatabaseTest, TestSetupDatabaseWithFakeStoresFailsReset) { 166 TEST_F(SafeBrowsingV4DatabaseTest, TestSetupDatabaseWithFakeStoresFailsReset) {
166 SetupInfoMapAndExpectedState(); 167 SetupInfoMapAndExpectedState();
167 168
168 NewDatabaseReadyCallback callback_db_ready = base::Bind( 169 NewDatabaseReadyCallback callback_db_ready = base::Bind(
169 &SafeBrowsingV4DatabaseTest::NewDatabaseReadyWithExpectedStorePathsAndIds, 170 &SafeBrowsingV4DatabaseTest::NewDatabaseReadyWithExpectedStorePathsAndIds,
170 base::Unretained(this), expected_store_paths_, expected_identifiers_, 171 base::Unretained(this), expected_store_paths_, expected_identifiers_,
171 false); 172 false);
172 173
173 FakeV4StoreFactory* factory = new FakeV4StoreFactory(true); 174 FakeV4StoreFactory* factory = new FakeV4StoreFactory(true);
174 ANNOTATE_LEAKING_OBJECT_PTR(factory); 175 ANNOTATE_LEAKING_OBJECT_PTR(factory);
175 V4Database::RegisterStoreFactoryForTest(factory); 176 V4Database::RegisterStoreFactoryForTest(factory);
176 V4Database::Create(task_runner_, database_dirname_, list_info_map_, 177 V4Database::Create(task_runner_, database_dirname_, list_info_map_,
177 callback_db_ready); 178 callback_db_ready);
178 created_but_not_called_back_ = true; 179 created_but_not_called_back_ = true;
179 task_runner_->RunPendingTasks(); 180 task_runner_->RunPendingTasks();
180 181
181 base::MessageLoop::current()->RunUntilIdle(); 182 base::RunLoop().RunUntilIdle();
182 EXPECT_EQ(true, created_and_called_back_); 183 EXPECT_EQ(true, created_and_called_back_);
183 } 184 }
184 185
185 } // namespace safe_browsing 186 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/rappor/log_uploader_unittest.cc ('k') | components/search_engines/search_engine_data_type_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698