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

Side by Side Diff: extensions/common/one_shot_event_unittest.cc

Issue 2331423002: Replace TestSimpleTaskRunner::GetPendingTasks with TakePendingTasks (Closed)
Patch Set: fix Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "extensions/common/one_shot_event.h" 5 #include "extensions/common/one_shot_event.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
(...skipping 15 matching lines...) Expand all
26 TEST(OneShotEventTest, CallsQueue) { 26 TEST(OneShotEventTest, CallsQueue) {
27 OneShotEvent event; 27 OneShotEvent event;
28 scoped_refptr<base::TestSimpleTaskRunner> runner( 28 scoped_refptr<base::TestSimpleTaskRunner> runner(
29 new base::TestSimpleTaskRunner); 29 new base::TestSimpleTaskRunner);
30 int i = 0; 30 int i = 0;
31 event.Post(FROM_HERE, base::Bind(&Increment, &i), runner); 31 event.Post(FROM_HERE, base::Bind(&Increment, &i), runner);
32 event.Post(FROM_HERE, base::Bind(&Increment, &i), runner); 32 event.Post(FROM_HERE, base::Bind(&Increment, &i), runner);
33 EXPECT_EQ(0U, runner->NumPendingTasks()); 33 EXPECT_EQ(0U, runner->NumPendingTasks());
34 event.Signal(); 34 event.Signal();
35 ASSERT_EQ(2U, runner->NumPendingTasks()); 35 ASSERT_EQ(2U, runner->NumPendingTasks());
36 EXPECT_NE(runner->GetPendingTasks()[0].location.line_number(), 36 EXPECT_NE(runner->GetPendingTaskLocationAt(0).line_number(),
37 runner->GetPendingTasks()[1].location.line_number()) 37 runner->GetPendingTaskLocationAt(1).line_number())
38 << "Make sure FROM_HERE is propagated."; 38 << "Make sure FROM_HERE is propagated.";
39 EXPECT_EQ(0, i); 39 EXPECT_EQ(0, i);
40 runner->RunPendingTasks(); 40 runner->RunPendingTasks();
41 EXPECT_EQ(2, i); 41 EXPECT_EQ(2, i);
42 } 42 }
43 43
44 TEST(OneShotEventTest, CallsAfterSignalDontRunInline) { 44 TEST(OneShotEventTest, CallsAfterSignalDontRunInline) {
45 OneShotEvent event; 45 OneShotEvent event;
46 scoped_refptr<base::TestSimpleTaskRunner> runner( 46 scoped_refptr<base::TestSimpleTaskRunner> runner(
47 new base::TestSimpleTaskRunner); 47 new base::TestSimpleTaskRunner);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 EXPECT_EQ(1U, runner->NumPendingTasks()); 103 EXPECT_EQ(1U, runner->NumPendingTasks());
104 EXPECT_EQ(0, i); 104 EXPECT_EQ(0, i);
105 runner->RunPendingTasks(); 105 runner->RunPendingTasks();
106 // Increment has run. 106 // Increment has run.
107 EXPECT_EQ(0U, runner->NumPendingTasks()); 107 EXPECT_EQ(0U, runner->NumPendingTasks());
108 EXPECT_EQ(1, i); 108 EXPECT_EQ(1, i);
109 } 109 }
110 110
111 } // namespace 111 } // namespace
112 } // namespace extensions 112 } // namespace extensions
OLDNEW
« base/test/test_simple_task_runner.h ('K') | « device/bluetooth/test/bluetooth_test_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698