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

Unified Diff: extensions/common/one_shot_event_unittest.cc

Issue 2331423002: Replace TestSimpleTaskRunner::GetPendingTasks with TakePendingTasks (Closed)
Patch Set: split test 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/test/bluetooth_test_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/one_shot_event_unittest.cc
diff --git a/extensions/common/one_shot_event_unittest.cc b/extensions/common/one_shot_event_unittest.cc
index db0bca9fc8846c62f84b6a6b2c85d21b15cffc95..6393f9a640ce2bf0e152b235eb1e6e0169022e42 100644
--- a/extensions/common/one_shot_event_unittest.cc
+++ b/extensions/common/one_shot_event_unittest.cc
@@ -23,6 +23,23 @@ TEST(OneShotEventTest, RecordsSignal) {
EXPECT_TRUE(event.is_signaled());
}
+TEST(OneShotEventTest, CallsQueueAsDistinctTask) {
+ OneShotEvent event;
+ scoped_refptr<base::TestSimpleTaskRunner> runner(
+ new base::TestSimpleTaskRunner);
+ int i = 0;
+ event.Post(FROM_HERE, base::Bind(&Increment, &i), runner);
+ event.Post(FROM_HERE, base::Bind(&Increment, &i), runner);
+ EXPECT_EQ(0U, runner->NumPendingTasks());
+ event.Signal();
+
+ auto pending_tasks = runner->TakePendingTasks();
+ ASSERT_EQ(2U, pending_tasks.size());
+ EXPECT_NE(pending_tasks[0].location.line_number(),
+ pending_tasks[1].location.line_number())
+ << "Make sure FROM_HERE is propagated.";
+}
+
TEST(OneShotEventTest, CallsQueue) {
OneShotEvent event;
scoped_refptr<base::TestSimpleTaskRunner> runner(
@@ -33,9 +50,7 @@ TEST(OneShotEventTest, CallsQueue) {
EXPECT_EQ(0U, runner->NumPendingTasks());
event.Signal();
ASSERT_EQ(2U, runner->NumPendingTasks());
- EXPECT_NE(runner->GetPendingTasks()[0].location.line_number(),
- runner->GetPendingTasks()[1].location.line_number())
- << "Make sure FROM_HERE is propagated.";
+
EXPECT_EQ(0, i);
runner->RunPendingTasks();
EXPECT_EQ(2, i);
« 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