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

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

Issue 2823103003: Introduce TaskRunner::RunsTasksInCurrentSequence() (Closed)
Patch Set: fixed build error and commments Created 3 years, 8 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 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 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 23 matching lines...) Expand all
34 base::OnceClosure task, 34 base::OnceClosure task,
35 base::TimeDelta delay) override { 35 base::TimeDelta delay) override {
36 ++posted_task_count_; 36 ++posted_task_count_;
37 return real_task_runner_->PostDelayedTask( 37 return real_task_runner_->PostDelayedTask(
38 from_here, 38 from_here,
39 base::BindOnce(&WrappedTaskRunner::RunWrappedTask, this, 39 base::BindOnce(&WrappedTaskRunner::RunWrappedTask, this,
40 std::move(task)), 40 std::move(task)),
41 base::TimeDelta()); // Squash all delays so our tests complete asap. 41 base::TimeDelta()); // Squash all delays so our tests complete asap.
42 } 42 }
43 43
44 bool RunsTasksOnCurrentThread() const override { 44 bool RunsTasksInCurrentSequence() const override {
45 return real_task_runner_->RunsTasksOnCurrentThread(); 45 return real_task_runner_->RunsTasksInCurrentSequence();
46 } 46 }
47 47
48 base::TaskRunner* real_runner() const { return real_task_runner_.get(); } 48 base::TaskRunner* real_runner() const { return real_task_runner_.get(); }
49 49
50 int total_task_count() const { return posted_task_count_ + ran_task_count_; } 50 int total_task_count() const { return posted_task_count_ + ran_task_count_; }
51 int posted_task_count() const { return posted_task_count_; } 51 int posted_task_count() const { return posted_task_count_; }
52 int ran_task_count() const { return ran_task_count_; } 52 int ran_task_count() const { return ran_task_count_; }
53 53
54 void reset_task_counts() { 54 void reset_task_counts() {
55 posted_task_count_ = 0; 55 posted_task_count_ = 0;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 AfterStartupTaskUtils::SetBrowserStartupIsCompleteForTesting(); 222 AfterStartupTaskUtils::SetBrowserStartupIsCompleteForTesting();
223 EXPECT_EQ(1, db_thread_->posted_task_count()); 223 EXPECT_EQ(1, db_thread_->posted_task_count());
224 224
225 FlushDBThread(); 225 FlushDBThread();
226 RunLoop().RunUntilIdle(); 226 RunLoop().RunUntilIdle();
227 EXPECT_EQ(1, db_thread_->ran_task_count()); 227 EXPECT_EQ(1, db_thread_->ran_task_count());
228 228
229 EXPECT_EQ(0, ui_thread_->total_task_count()); 229 EXPECT_EQ(0, ui_thread_->total_task_count());
230 } 230 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698