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

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

Issue 2627863002: Split Closure part of TestPendingTask out of the struct (Closed)
Patch Set: rebase Created 3 years, 11 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 17 matching lines...) Expand all
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 35
36 auto pending_tasks = runner->TakePendingTasks(); 36 auto pending_tasks = runner->TakePendingTasks();
37 ASSERT_EQ(2U, pending_tasks.size()); 37 ASSERT_EQ(2U, pending_tasks.size());
38 EXPECT_NE(pending_tasks[0].location.line_number(), 38 EXPECT_NE(pending_tasks[0].first.location.line_number(),
39 pending_tasks[1].location.line_number()) 39 pending_tasks[1].first.location.line_number())
40 << "Make sure FROM_HERE is propagated."; 40 << "Make sure FROM_HERE is propagated.";
41 } 41 }
42 42
43 TEST(OneShotEventTest, CallsQueue) { 43 TEST(OneShotEventTest, CallsQueue) {
44 OneShotEvent event; 44 OneShotEvent event;
45 scoped_refptr<base::TestSimpleTaskRunner> runner( 45 scoped_refptr<base::TestSimpleTaskRunner> runner(
46 new base::TestSimpleTaskRunner); 46 new base::TestSimpleTaskRunner);
47 int i = 0; 47 int i = 0;
48 event.Post(FROM_HERE, base::Bind(&Increment, &i), runner); 48 event.Post(FROM_HERE, base::Bind(&Increment, &i), runner);
49 event.Post(FROM_HERE, base::Bind(&Increment, &i), runner); 49 event.Post(FROM_HERE, base::Bind(&Increment, &i), runner);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 EXPECT_EQ(1U, runner->NumPendingTasks()); 118 EXPECT_EQ(1U, runner->NumPendingTasks());
119 EXPECT_EQ(0, i); 119 EXPECT_EQ(0, i);
120 runner->RunPendingTasks(); 120 runner->RunPendingTasks();
121 // Increment has run. 121 // Increment has run.
122 EXPECT_EQ(0U, runner->NumPendingTasks()); 122 EXPECT_EQ(0U, runner->NumPendingTasks());
123 EXPECT_EQ(1, i); 123 EXPECT_EQ(1, i);
124 } 124 }
125 125
126 } // namespace 126 } // namespace
127 } // namespace extensions 127 } // namespace extensions
OLDNEW
« no previous file with comments | « device/bluetooth/test/bluetooth_test_win.cc ('k') | media/cast/test/skewed_single_thread_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698