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

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

Issue 27420004: Remove threading from RendererGpuVideoAcceleratorFactories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dthread
Patch Set: f77fc38a Unittest fixes. Created 7 years, 1 month 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 (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_loop.h" 5 #include "media/base/bind_to_loop.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/synchronization/waitable_event.h" 8 #include "base/synchronization/waitable_event.h"
9 #include "base/threading/thread.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 namespace media { 12 namespace media {
12 13
13 void BoundBoolSet(bool* var, bool val) { 14 void BoundBoolSet(bool* var, bool val) {
14 *var = val; 15 *var = val;
15 } 16 }
16 17
17 void BoundBoolSetFromScopedPtr(bool* var, scoped_ptr<bool> val) { 18 void BoundBoolSetFromScopedPtr(bool* var, scoped_ptr<bool> val) {
18 *var = *val; 19 *var = *val;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 base::Callback<void(int, int)> cb = BindToLoop(proxy_, base::Bind( 160 base::Callback<void(int, int)> cb = BindToLoop(proxy_, base::Bind(
160 &BoundIntegersSet, &a, &b)); 161 &BoundIntegersSet, &a, &b));
161 cb.Run(1, -1); 162 cb.Run(1, -1);
162 EXPECT_EQ(a, 0); 163 EXPECT_EQ(a, 0);
163 EXPECT_EQ(b, 0); 164 EXPECT_EQ(b, 0);
164 loop_.RunUntilIdle(); 165 loop_.RunUntilIdle();
165 EXPECT_EQ(a, 1); 166 EXPECT_EQ(a, 1);
166 EXPECT_EQ(b, -1); 167 EXPECT_EQ(b, -1);
167 } 168 }
168 169
170 TEST_F(BindToLoopTest, BindSyncDeadlock) {
171 // Check that we don't deadlock using BindToLoopSync().
172 bool bool_val = false;
173 base::Thread thread("SyncDeadlock");
174 thread.Start();
175 scoped_refptr<base::MessageLoopProxy> thread_proxy =
176 thread.message_loop_proxy();
177 base::Closure cb = BindToLoopSync(
178 thread_proxy,
179 base::Bind(&BoundBoolSet, &bool_val, true));
180 EXPECT_FALSE(bool_val);
181 cb.Run();
182 EXPECT_TRUE(bool_val);
183 thread.Stop();
184 }
185
169 } // namespace media 186 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698