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

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

Issue 1120793007: [extensions] Replace MessageLoopProxy usage with ThreadTaskRunnerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Dependency over component module by removing file Created 5 years, 7 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/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace extensions { 13 namespace extensions {
13 14
14 namespace { 15 namespace {
15 16
16 void Increment(int* i) { ++*i; } 17 void Increment(int* i) { ++*i; }
17 18
18 TEST(OneShotEventTest, RecordsSignal) { 19 TEST(OneShotEventTest, RecordsSignal) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 EXPECT_EQ(0, runner_i); 70 EXPECT_EQ(0, runner_i);
70 runner->RunPendingTasks(); 71 runner->RunPendingTasks();
71 EXPECT_EQ(1, runner_i); 72 EXPECT_EQ(1, runner_i);
72 EXPECT_EQ(0, loop_i); 73 EXPECT_EQ(0, loop_i);
73 base::RunLoop().RunUntilIdle(); 74 base::RunLoop().RunUntilIdle();
74 EXPECT_EQ(1, loop_i); 75 EXPECT_EQ(1, loop_i);
75 } 76 }
76 77
77 void CheckSignaledAndPostIncrement( 78 void CheckSignaledAndPostIncrement(
78 OneShotEvent* event, 79 OneShotEvent* event,
79 const scoped_refptr<base::TaskRunner>& runner, 80 const scoped_refptr<base::SingleThreadTaskRunner>& runner,
80 int* i) { 81 int* i) {
81 EXPECT_TRUE(event->is_signaled()); 82 EXPECT_TRUE(event->is_signaled());
82 event->Post(FROM_HERE, base::Bind(&Increment, i), runner); 83 event->Post(FROM_HERE, base::Bind(&Increment, i), runner);
83 } 84 }
84 85
85 TEST(OneShotEventTest, IsSignaledAndPostsFromCallbackWork) { 86 TEST(OneShotEventTest, IsSignaledAndPostsFromCallbackWork) {
86 OneShotEvent event; 87 OneShotEvent event;
87 scoped_refptr<base::TestSimpleTaskRunner> runner( 88 scoped_refptr<base::TestSimpleTaskRunner> runner(
88 new base::TestSimpleTaskRunner); 89 new base::TestSimpleTaskRunner);
89 int i = 0; 90 int i = 0;
(...skipping 12 matching lines...) Expand all
102 EXPECT_EQ(1U, runner->GetPendingTasks().size()); 103 EXPECT_EQ(1U, runner->GetPendingTasks().size());
103 EXPECT_EQ(0, i); 104 EXPECT_EQ(0, i);
104 runner->RunPendingTasks(); 105 runner->RunPendingTasks();
105 // Increment has run. 106 // Increment has run.
106 EXPECT_EQ(0U, runner->GetPendingTasks().size()); 107 EXPECT_EQ(0U, runner->GetPendingTasks().size());
107 EXPECT_EQ(1, i); 108 EXPECT_EQ(1, i);
108 } 109 }
109 110
110 } // namespace 111 } // namespace
111 } // namespace extensions 112 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/one_shot_event.cc ('k') | extensions/renderer/api/serial/serial_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698