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

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

Issue 2331423002: Replace TestSimpleTaskRunner::GetPendingTasks with TakePendingTasks (Closed)
Patch Set: make a Location result base::Optional Created 4 years, 2 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 | « device/bluetooth/test/bluetooth_test_win.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 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
37 runner->GetPendingTasks()[1].location.line_number()) 37 base::Optional<tracked_objects::Location> first_item_location =
38 runner->GetPendingTaskLocationAt(0);
danakj 2016/09/29 19:42:13 Proposal: Rewrite this test to TakePendingTasks in
tzik 2016/09/30 04:00:26 SG. Updated.
39 base::Optional<tracked_objects::Location> second_item_location =
40 runner->GetPendingTaskLocationAt(1);
41 ASSERT_TRUE(first_item_location);
42 ASSERT_TRUE(second_item_location);
43 EXPECT_NE(first_item_location->line_number(),
44 second_item_location->line_number())
38 << "Make sure FROM_HERE is propagated."; 45 << "Make sure FROM_HERE is propagated.";
39 EXPECT_EQ(0, i); 46 EXPECT_EQ(0, i);
40 runner->RunPendingTasks(); 47 runner->RunPendingTasks();
41 EXPECT_EQ(2, i); 48 EXPECT_EQ(2, i);
42 } 49 }
43 50
44 TEST(OneShotEventTest, CallsAfterSignalDontRunInline) { 51 TEST(OneShotEventTest, CallsAfterSignalDontRunInline) {
45 OneShotEvent event; 52 OneShotEvent event;
46 scoped_refptr<base::TestSimpleTaskRunner> runner( 53 scoped_refptr<base::TestSimpleTaskRunner> runner(
47 new base::TestSimpleTaskRunner); 54 new base::TestSimpleTaskRunner);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 EXPECT_EQ(1U, runner->NumPendingTasks()); 110 EXPECT_EQ(1U, runner->NumPendingTasks());
104 EXPECT_EQ(0, i); 111 EXPECT_EQ(0, i);
105 runner->RunPendingTasks(); 112 runner->RunPendingTasks();
106 // Increment has run. 113 // Increment has run.
107 EXPECT_EQ(0U, runner->NumPendingTasks()); 114 EXPECT_EQ(0U, runner->NumPendingTasks());
108 EXPECT_EQ(1, i); 115 EXPECT_EQ(1, i);
109 } 116 }
110 117
111 } // namespace 118 } // namespace
112 } // namespace extensions 119 } // namespace extensions
OLDNEW
« no previous file with comments | « 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