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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 } | 50 } |
51 | 51 |
52 virtual void DoWork() { | 52 virtual void DoWork() { |
53 EXPECT_NE(harness_->main_thread_, Thread::Current()); | 53 EXPECT_NE(harness_->main_thread_, Thread::Current()); |
54 EXPECT_EQ(worker(), Thread::Current()); | 54 EXPECT_EQ(worker(), Thread::Current()); |
55 Thread::Current()->socketserver()->Wait(250, false); | 55 Thread::Current()->socketserver()->Wait(250, false); |
56 } | 56 } |
57 | 57 |
58 private: | 58 private: |
59 SignalThreadTest* harness_; | 59 SignalThreadTest* harness_; |
60 DISALLOW_COPY_AND_ASSIGN(SlowSignalThread); | 60 RTC_DISALLOW_COPY_AND_ASSIGN(SlowSignalThread); |
61 }; | 61 }; |
62 | 62 |
63 void OnWorkComplete(rtc::SignalThread* thread) { | 63 void OnWorkComplete(rtc::SignalThread* thread) { |
64 SlowSignalThread* t = static_cast<SlowSignalThread*>(thread); | 64 SlowSignalThread* t = static_cast<SlowSignalThread*>(thread); |
65 EXPECT_EQ(t->harness(), this); | 65 EXPECT_EQ(t->harness(), this); |
66 EXPECT_EQ(main_thread_, Thread::Current()); | 66 EXPECT_EQ(main_thread_, Thread::Current()); |
67 | 67 |
68 ++thread_completed_; | 68 ++thread_completed_; |
69 if (!called_release_) { | 69 if (!called_release_) { |
70 thread->Release(); | 70 thread->Release(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 121 } |
122 | 122 |
123 bool has_run() { return has_run_; } | 123 bool has_run() { return has_run_; } |
124 void OnWorkDone(SignalThread* signal_thread) { | 124 void OnWorkDone(SignalThread* signal_thread) { |
125 FAIL() << " This shouldn't get called."; | 125 FAIL() << " This shouldn't get called."; |
126 } | 126 } |
127 | 127 |
128 private: | 128 private: |
129 SignalThreadTest* harness_; | 129 SignalThreadTest* harness_; |
130 bool has_run_; | 130 bool has_run_; |
131 DISALLOW_COPY_AND_ASSIGN(OwnerThread); | 131 RTC_DISALLOW_COPY_AND_ASSIGN(OwnerThread); |
132 }; | 132 }; |
133 | 133 |
134 // Test for when the main thread goes away while the | 134 // Test for when the main thread goes away while the |
135 // signal thread is still working. This may happen | 135 // signal thread is still working. This may happen |
136 // when shutting down the process. | 136 // when shutting down the process. |
137 TEST_F(SignalThreadTest, OwnerThreadGoesAway) { | 137 TEST_F(SignalThreadTest, OwnerThreadGoesAway) { |
138 { | 138 { |
139 scoped_ptr<OwnerThread> owner(new OwnerThread(this)); | 139 scoped_ptr<OwnerThread> owner(new OwnerThread(this)); |
140 main_thread_ = owner.get(); | 140 main_thread_ = owner.get(); |
141 owner->Start(); | 141 owner->Start(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 TEST_F(SignalThreadTest, DeferredDestroyedThreadCleansUp) { | 190 TEST_F(SignalThreadTest, DeferredDestroyedThreadCleansUp) { |
191 thread_->Start(); | 191 thread_->Start(); |
192 EXPECT_STATE(1, 0, 0, 0, 0); | 192 EXPECT_STATE(1, 0, 0, 0, 0); |
193 thread_->Destroy(false); | 193 thread_->Destroy(false); |
194 EXPECT_STATE(1, 0, 0, 1, 0); | 194 EXPECT_STATE(1, 0, 0, 1, 0); |
195 Thread::SleepMs(500); | 195 Thread::SleepMs(500); |
196 EXPECT_STATE(1, 0, 0, 1, 0); | 196 EXPECT_STATE(1, 0, 0, 1, 0); |
197 Thread::Current()->ProcessMessages(0); | 197 Thread::Current()->ProcessMessages(0); |
198 EXPECT_STATE(1, 1, 0, 1, 1); | 198 EXPECT_STATE(1, 1, 0, 1, 1); |
199 } | 199 } |
OLD | NEW |