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

Side by Side Diff: chrome/browser/after_startup_task_utils_unittest.cc

Issue 2238603002: Introduce AfterStartupTaskUtils::Runner for callsites that want to use AfterStartupTaskUtils but ne… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b9_sequenced_worker_pool_redirection
Patch Set: merge up to r411308 Created 4 years, 4 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
« no previous file with comments | « chrome/browser/after_startup_task_utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/after_startup_task_utils.h" 5 #include "chrome/browser/after_startup_task_utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 base::Bind(&base::DoNothing)); 191 base::Bind(&base::DoNothing));
192 PostAfterStartupTaskFromDBThread(FROM_HERE, db_thread_, 192 PostAfterStartupTaskFromDBThread(FROM_HERE, db_thread_,
193 base::Bind(&base::DoNothing)); 193 base::Bind(&base::DoNothing));
194 EXPECT_EQ(2, db_thread_->posted_task_count()); 194 EXPECT_EQ(2, db_thread_->posted_task_count());
195 EXPECT_EQ(2, ui_thread_->posted_task_count()); 195 EXPECT_EQ(2, ui_thread_->posted_task_count());
196 FlushDBThread(); 196 FlushDBThread();
197 RunLoop().RunUntilIdle(); 197 RunLoop().RunUntilIdle();
198 EXPECT_EQ(2, db_thread_->ran_task_count()); 198 EXPECT_EQ(2, db_thread_->ran_task_count());
199 EXPECT_EQ(2, ui_thread_->ran_task_count()); 199 EXPECT_EQ(2, ui_thread_->ran_task_count());
200 } 200 }
201
202 // Verify that posting to an AfterStartupTaskUtils::Runner bound to |db_thread_|
203 // results in the same behavior as posting via
204 // AfterStartupTaskUtils::PostTask(..., db_thread_, ...).
205 TEST_F(AfterStartupTaskTest, AfterStartupTaskUtilsRunner) {
206 scoped_refptr<base::TaskRunner> after_startup_runner =
207 make_scoped_refptr(new AfterStartupTaskUtils::Runner(db_thread_));
208
209 EXPECT_FALSE(AfterStartupTaskUtils::IsBrowserStartupComplete());
210 after_startup_runner->PostTask(
211 FROM_HERE, base::Bind(&AfterStartupTaskTest::VerifyExpectedThread,
212 BrowserThread::DB));
213
214 RunLoop().RunUntilIdle();
215 EXPECT_FALSE(AfterStartupTaskUtils::IsBrowserStartupComplete());
216 EXPECT_EQ(0, db_thread_->total_task_count());
217
218 AfterStartupTaskUtils::SetBrowserStartupIsCompleteForTesting();
219 EXPECT_EQ(1, db_thread_->posted_task_count());
220
221 FlushDBThread();
222 RunLoop().RunUntilIdle();
223 EXPECT_EQ(1, db_thread_->ran_task_count());
224
225 EXPECT_EQ(0, ui_thread_->total_task_count());
226 }
OLDNEW
« no previous file with comments | « chrome/browser/after_startup_task_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698