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

Side by Side Diff: jingle/glue/thread_wrapper_unittest.cc

Issue 10823224: Update JingleThreadWrapper to allow it to be created using task runner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
« no previous file with comments | « jingle/glue/thread_wrapper.cc ('k') | remoting/client/plugin/chromoting_instance.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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/threading/thread.h" 8 #include "base/threading/thread.h"
9 #include "jingle/glue/thread_wrapper.h" 9 #include "jingle/glue/thread_wrapper.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 .WillOnce(DeleteMessageData()); 74 .WillOnce(DeleteMessageData());
75 thread_->Send(&handler, kTestMessage2, data); 75 thread_->Send(&handler, kTestMessage2, data);
76 } 76 }
77 77
78 protected: 78 protected:
79 ThreadWrapperTest() 79 ThreadWrapperTest()
80 : thread_(NULL) { 80 : thread_(NULL) {
81 } 81 }
82 82
83 virtual void SetUp() OVERRIDE { 83 virtual void SetUp() OVERRIDE {
84 JingleThreadWrapper::EnsureForCurrentThread(); 84 JingleThreadWrapper::EnsureForCurrentMessageLoop();
85 thread_ = talk_base::Thread::Current(); 85 thread_ = talk_base::Thread::Current();
86 } 86 }
87 87
88 // ThreadWrapper destroyes itself when |message_loop_| is destroyed. 88 // ThreadWrapper destroyes itself when |message_loop_| is destroyed.
89 MessageLoop message_loop_; 89 MessageLoop message_loop_;
90 talk_base::Thread* thread_; 90 talk_base::Thread* thread_;
91 MockMessageHandler handler1_; 91 MockMessageHandler handler1_;
92 MockMessageHandler handler2_; 92 MockMessageHandler handler2_;
93 }; 93 };
94 94
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 talk_base::MessageData* data = new talk_base::MessageData(); 223 talk_base::MessageData* data = new talk_base::MessageData();
224 224
225 EXPECT_CALL(handler1_, OnMessage( 225 EXPECT_CALL(handler1_, OnMessage(
226 MatchMessage(&handler1_, kTestMessage1, data))) 226 MatchMessage(&handler1_, kTestMessage1, data)))
227 .WillOnce(DeleteMessageData()); 227 .WillOnce(DeleteMessageData());
228 thread_->Send(&handler1_, kTestMessage1, data); 228 thread_->Send(&handler1_, kTestMessage1, data);
229 } 229 }
230 230
231 void InitializeWrapperForNewThread(talk_base::Thread** thread, 231 void InitializeWrapperForNewThread(talk_base::Thread** thread,
232 base::WaitableEvent* done_event) { 232 base::WaitableEvent* done_event) {
233 JingleThreadWrapper::EnsureForCurrentThread(); 233 JingleThreadWrapper::EnsureForCurrentMessageLoop();
234 JingleThreadWrapper::current()->set_send_allowed(true); 234 JingleThreadWrapper::current()->set_send_allowed(true);
235 *thread = JingleThreadWrapper::current(); 235 *thread = JingleThreadWrapper::current();
236 done_event->Signal(); 236 done_event->Signal();
237 } 237 }
238 238
239 // Verify that Send() calls handler synchronously when called for a 239 // Verify that Send() calls handler synchronously when called for a
240 // different thread. 240 // different thread.
241 TEST_F(ThreadWrapperTest, SendToOtherThread) { 241 TEST_F(ThreadWrapperTest, SendToOtherThread) {
242 JingleThreadWrapper::current()->set_send_allowed(true); 242 JingleThreadWrapper::current()->set_send_allowed(true);
243 243
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 297
298 TEST_F(ThreadWrapperTest, Dispose) { 298 TEST_F(ThreadWrapperTest, Dispose) {
299 bool deleted_; 299 bool deleted_;
300 thread_->Dispose(new DeletableObject(&deleted_)); 300 thread_->Dispose(new DeletableObject(&deleted_));
301 EXPECT_FALSE(deleted_); 301 EXPECT_FALSE(deleted_);
302 message_loop_.RunAllPending(); 302 message_loop_.RunAllPending();
303 EXPECT_TRUE(deleted_); 303 EXPECT_TRUE(deleted_);
304 } 304 }
305 305
306 } // namespace jingle_glue 306 } // namespace jingle_glue
OLDNEW
« no previous file with comments | « jingle/glue/thread_wrapper.cc ('k') | remoting/client/plugin/chromoting_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698