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

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

Issue 16092013: Use base::MessageLoop in more files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again, sigh Created 7 years, 6 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 | Annotate | Revision Log
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/test/test_simple_task_runner.h" 9 #include "base/test/test_simple_task_runner.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 EXPECT_EQ(1U, runner->GetPendingTasks().size()); 51 EXPECT_EQ(1U, runner->GetPendingTasks().size());
52 EXPECT_EQ(0, i); 52 EXPECT_EQ(0, i);
53 runner->RunPendingTasks(); 53 runner->RunPendingTasks();
54 EXPECT_EQ(1, i); 54 EXPECT_EQ(1, i);
55 } 55 }
56 56
57 TEST(OneShotEventTest, PostDefaultsToCurrentMessageLoop) { 57 TEST(OneShotEventTest, PostDefaultsToCurrentMessageLoop) {
58 OneShotEvent event; 58 OneShotEvent event;
59 scoped_refptr<base::TestSimpleTaskRunner> runner( 59 scoped_refptr<base::TestSimpleTaskRunner> runner(
60 new base::TestSimpleTaskRunner); 60 new base::TestSimpleTaskRunner);
61 MessageLoop loop; 61 base::MessageLoop loop;
62 int runner_i = 0; 62 int runner_i = 0;
63 int loop_i = 0; 63 int loop_i = 0;
64 64
65 event.Post(FROM_HERE, base::Bind(&Increment, &runner_i), runner); 65 event.Post(FROM_HERE, base::Bind(&Increment, &runner_i), runner);
66 event.Post(FROM_HERE, base::Bind(&Increment, &loop_i)); 66 event.Post(FROM_HERE, base::Bind(&Increment, &loop_i));
67 event.Signal(); 67 event.Signal();
68 EXPECT_EQ(1U, runner->GetPendingTasks().size()); 68 EXPECT_EQ(1U, runner->GetPendingTasks().size());
69 EXPECT_EQ(0, runner_i); 69 EXPECT_EQ(0, runner_i);
70 runner->RunPendingTasks(); 70 runner->RunPendingTasks();
71 EXPECT_EQ(1, runner_i); 71 EXPECT_EQ(1, runner_i);
(...skipping 30 matching lines...) Expand all
102 EXPECT_EQ(1U, runner->GetPendingTasks().size()); 102 EXPECT_EQ(1U, runner->GetPendingTasks().size());
103 EXPECT_EQ(0, i); 103 EXPECT_EQ(0, i);
104 runner->RunPendingTasks(); 104 runner->RunPendingTasks();
105 // Increment has run. 105 // Increment has run.
106 EXPECT_EQ(0U, runner->GetPendingTasks().size()); 106 EXPECT_EQ(0U, runner->GetPendingTasks().size());
107 EXPECT_EQ(1, i); 107 EXPECT_EQ(1, i);
108 } 108 }
109 109
110 } // namespace 110 } // namespace
111 } // namespace extensions 111 } // namespace extensions
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_profile_chromeos_unittest.cc ('k') | media/base/android/media_source_player.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698