| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2  *  Copyright 2004 The WebRTC Project Authors. All rights reserved. | 
| 3  * | 3  * | 
| 4  *  Use of this source code is governed by a BSD-style license | 4  *  Use of this source code is governed by a BSD-style license | 
| 5  *  that can be found in the LICENSE file in the root of the source | 5  *  that can be found in the LICENSE file in the root of the source | 
| 6  *  tree. An additional intellectual property rights grant can be found | 6  *  tree. An additional intellectual property rights grant can be found | 
| 7  *  in the file PATENTS.  All contributing project authors may | 7  *  in the file PATENTS.  All contributing project authors may | 
| 8  *  be found in the AUTHORS file in the root of the source tree. | 8  *  be found in the AUTHORS file in the root of the source tree. | 
| 9  */ | 9  */ | 
| 10 | 10 | 
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 406 }; | 406 }; | 
| 407 | 407 | 
| 408 TEST(ThreadTest, SetNameOnSignalQueueDestroyed) { | 408 TEST(ThreadTest, SetNameOnSignalQueueDestroyed) { | 
| 409   Thread* thread1 = new Thread(); | 409   Thread* thread1 = new Thread(); | 
| 410   SetNameOnSignalQueueDestroyedTester tester1(thread1); | 410   SetNameOnSignalQueueDestroyedTester tester1(thread1); | 
| 411   delete thread1; | 411   delete thread1; | 
| 412 | 412 | 
| 413   Thread* thread2 = new AutoThread(); | 413   Thread* thread2 = new AutoThread(); | 
| 414   SetNameOnSignalQueueDestroyedTester tester2(thread2); | 414   SetNameOnSignalQueueDestroyedTester tester2(thread2); | 
| 415   delete thread2; | 415   delete thread2; | 
| 416 |  | 
| 417 #if defined(WEBRTC_WIN) |  | 
| 418   Thread* thread3 = new ComThread(); |  | 
| 419   SetNameOnSignalQueueDestroyedTester tester3(thread3); |  | 
| 420   delete thread3; |  | 
| 421 #endif |  | 
| 422 } | 416 } | 
| 423 | 417 | 
| 424 class AsyncInvokeTest : public testing::Test { | 418 class AsyncInvokeTest : public testing::Test { | 
| 425  public: | 419  public: | 
| 426   void IntCallback(int value) { | 420   void IntCallback(int value) { | 
| 427     EXPECT_EQ(expected_thread_, Thread::Current()); | 421     EXPECT_EQ(expected_thread_, Thread::Current()); | 
| 428     int_value_ = value; | 422     int_value_ = value; | 
| 429   } | 423   } | 
| 430   void AsyncInvokeIntCallback(AsyncInvoker* invoker, Thread* thread) { | 424   void AsyncInvokeIntCallback(AsyncInvoker* invoker, Thread* thread) { | 
| 431     expected_thread_ = thread; | 425     expected_thread_ = thread; | 
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 774   // Execute pending calls with id == 5. | 768   // Execute pending calls with id == 5. | 
| 775   EXPECT_TRUE(invoker.Flush(5)); | 769   EXPECT_TRUE(invoker.Flush(5)); | 
| 776   EXPECT_TRUE(flag1.get()); | 770   EXPECT_TRUE(flag1.get()); | 
| 777   EXPECT_FALSE(flag2.get()); | 771   EXPECT_FALSE(flag2.get()); | 
| 778   flag1 = false; | 772   flag1 = false; | 
| 779   // Execute all pending calls. The id == 5 call should not execute again. | 773   // Execute all pending calls. The id == 5 call should not execute again. | 
| 780   EXPECT_TRUE(invoker.Flush()); | 774   EXPECT_TRUE(invoker.Flush()); | 
| 781   EXPECT_FALSE(flag1.get()); | 775   EXPECT_FALSE(flag1.get()); | 
| 782   EXPECT_TRUE(flag2.get()); | 776   EXPECT_TRUE(flag2.get()); | 
| 783 } | 777 } | 
| 784 |  | 
| 785 #if defined(WEBRTC_WIN) |  | 
| 786 class ComThreadTest : public testing::Test, public MessageHandler { |  | 
| 787  public: |  | 
| 788   ComThreadTest() : done_(false) {} |  | 
| 789  protected: |  | 
| 790   virtual void OnMessage(Message* message) { |  | 
| 791     HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); |  | 
| 792     // S_FALSE means the thread was already inited for a multithread apartment. |  | 
| 793     EXPECT_EQ(S_FALSE, hr); |  | 
| 794     if (SUCCEEDED(hr)) { |  | 
| 795       CoUninitialize(); |  | 
| 796     } |  | 
| 797     done_ = true; |  | 
| 798   } |  | 
| 799   bool done_; |  | 
| 800 }; |  | 
| 801 |  | 
| 802 TEST_F(ComThreadTest, ComInited) { |  | 
| 803   Thread* thread = new ComThread(); |  | 
| 804   EXPECT_TRUE(thread->Start()); |  | 
| 805   thread->Post(RTC_FROM_HERE, this, 0); |  | 
| 806   EXPECT_TRUE_WAIT(done_, 1000); |  | 
| 807   delete thread; |  | 
| 808 } |  | 
| 809 #endif |  | 
| OLD | NEW | 
|---|