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

Side by Side Diff: chromecast/base/bind_to_task_runner_unittest.cc

Issue 2043303004: More WaitableEvent stragglers migrated to enum-based constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@d_4_misc
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chromecast/base/bind_to_task_runner.h" 5 #include "chromecast/base/bind_to_task_runner.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/free_deleter.h" 9 #include "base/memory/free_deleter.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 // Various tests that check that the bound function is only actually executed 43 // Various tests that check that the bound function is only actually executed
44 // on the message loop, not during the original Run. 44 // on the message loop, not during the original Run.
45 class BindToTaskRunnerTest : public ::testing::Test { 45 class BindToTaskRunnerTest : public ::testing::Test {
46 protected: 46 protected:
47 base::MessageLoop loop_; 47 base::MessageLoop loop_;
48 }; 48 };
49 49
50 TEST_F(BindToTaskRunnerTest, Closure) { 50 TEST_F(BindToTaskRunnerTest, Closure) {
51 // Test the closure is run inside the loop, not outside it. 51 // Test the closure is run inside the loop, not outside it.
52 base::WaitableEvent waiter(false, false); 52 base::WaitableEvent waiter(base::WaitableEvent::ResetPolicy::AUTOMATIC,
53 base::WaitableEvent::InitialState::NOT_SIGNALED);
53 base::Closure cb = BindToCurrentThread( 54 base::Closure cb = BindToCurrentThread(
54 base::Bind(&base::WaitableEvent::Signal, Unretained(&waiter))); 55 base::Bind(&base::WaitableEvent::Signal, Unretained(&waiter)));
55 cb.Run(); 56 cb.Run();
56 EXPECT_FALSE(waiter.IsSignaled()); 57 EXPECT_FALSE(waiter.IsSignaled());
57 loop_.RunUntilIdle(); 58 loop_.RunUntilIdle();
58 EXPECT_TRUE(waiter.IsSignaled()); 59 EXPECT_TRUE(waiter.IsSignaled());
59 } 60 }
60 61
61 TEST_F(BindToTaskRunnerTest, Bool) { 62 TEST_F(BindToTaskRunnerTest, Bool) {
62 bool bool_var = false; 63 bool bool_var = false;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 BindToCurrentThread(base::Bind(&BoundIntegersSet, &a, &b)); 163 BindToCurrentThread(base::Bind(&BoundIntegersSet, &a, &b));
163 cb.Run(1, -1); 164 cb.Run(1, -1);
164 EXPECT_EQ(a, 0); 165 EXPECT_EQ(a, 0);
165 EXPECT_EQ(b, 0); 166 EXPECT_EQ(b, 0);
166 loop_.RunUntilIdle(); 167 loop_.RunUntilIdle();
167 EXPECT_EQ(a, 1); 168 EXPECT_EQ(a, 1);
168 EXPECT_EQ(b, -1); 169 EXPECT_EQ(b, -1);
169 } 170 }
170 171
171 } // namespace chromecast 172 } // namespace chromecast
OLDNEW
« no previous file with comments | « chrome/browser/android/provider/run_on_ui_thread_blocking.h ('k') | chromecast/media/base/media_resource_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698