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

Side by Side Diff: media/base/bind_to_current_loop_unittest.cc

Issue 2023343002: Migrate WaitableEvent to enum-based constructor in media/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WEvent_enums
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
« no previous file with comments | « media/base/audio_renderer_mixer_unittest.cc ('k') | media/base/pipeline_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/base/bind_to_current_loop.h" 5 #include "media/base/bind_to_current_loop.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/free_deleter.h" 10 #include "base/memory/free_deleter.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 // Various tests that check that the bound function is only actually executed 44 // Various tests that check that the bound function is only actually executed
45 // on the message loop, not during the original Run. 45 // on the message loop, not during the original Run.
46 class BindToCurrentLoopTest : public ::testing::Test { 46 class BindToCurrentLoopTest : public ::testing::Test {
47 protected: 47 protected:
48 base::MessageLoop loop_; 48 base::MessageLoop loop_;
49 }; 49 };
50 50
51 TEST_F(BindToCurrentLoopTest, Closure) { 51 TEST_F(BindToCurrentLoopTest, Closure) {
52 // Test the closure is run inside the loop, not outside it. 52 // Test the closure is run inside the loop, not outside it.
53 base::WaitableEvent waiter(false, false); 53 base::WaitableEvent waiter(base::WaitableEvent::ResetPolicy::AUTOMATIC,
54 base::WaitableEvent::InitialState::NOT_SIGNALED);
54 base::Closure cb = BindToCurrentLoop(base::Bind( 55 base::Closure cb = BindToCurrentLoop(base::Bind(
55 &base::WaitableEvent::Signal, base::Unretained(&waiter))); 56 &base::WaitableEvent::Signal, base::Unretained(&waiter)));
56 cb.Run(); 57 cb.Run();
57 EXPECT_FALSE(waiter.IsSignaled()); 58 EXPECT_FALSE(waiter.IsSignaled());
58 loop_.RunUntilIdle(); 59 loop_.RunUntilIdle();
59 EXPECT_TRUE(waiter.IsSignaled()); 60 EXPECT_TRUE(waiter.IsSignaled());
60 } 61 }
61 62
62 TEST_F(BindToCurrentLoopTest, Bool) { 63 TEST_F(BindToCurrentLoopTest, Bool) {
63 bool bool_var = false; 64 bool bool_var = false;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 &BoundIntegersSet, &a, &b)); 164 &BoundIntegersSet, &a, &b));
164 cb.Run(1, -1); 165 cb.Run(1, -1);
165 EXPECT_EQ(a, 0); 166 EXPECT_EQ(a, 0);
166 EXPECT_EQ(b, 0); 167 EXPECT_EQ(b, 0);
167 loop_.RunUntilIdle(); 168 loop_.RunUntilIdle();
168 EXPECT_EQ(a, 1); 169 EXPECT_EQ(a, 1);
169 EXPECT_EQ(b, -1); 170 EXPECT_EQ(b, -1);
170 } 171 }
171 172
172 } // namespace media 173 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_renderer_mixer_unittest.cc ('k') | media/base/pipeline_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698