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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 private: | 133 private: |
134 SignalThreadTest* harness_; | 134 SignalThreadTest* harness_; |
135 bool has_run_; | 135 bool has_run_; |
136 RTC_DISALLOW_COPY_AND_ASSIGN(OwnerThread); | 136 RTC_DISALLOW_COPY_AND_ASSIGN(OwnerThread); |
137 }; | 137 }; |
138 | 138 |
139 // Test for when the main thread goes away while the | 139 // Test for when the main thread goes away while the |
140 // signal thread is still working. This may happen | 140 // signal thread is still working. This may happen |
141 // when shutting down the process. | 141 // when shutting down the process. |
142 TEST_F(SignalThreadTest, OwnerThreadGoesAway) { | 142 TEST_F(SignalThreadTest, OwnerThreadGoesAway) { |
143 // We don't use |thread_| for this test, so destroy it. | |
144 thread_->Destroy(true); | |
145 | |
146 { | 143 { |
147 std::unique_ptr<OwnerThread> owner(new OwnerThread(this)); | 144 std::unique_ptr<OwnerThread> owner(new OwnerThread(this)); |
148 main_thread_ = owner.get(); | 145 main_thread_ = owner.get(); |
149 owner->Start(); | 146 owner->Start(); |
150 while (!owner->has_run()) { | 147 while (!owner->has_run()) { |
151 Thread::Current()->socketserver()->Wait(10, false); | 148 Thread::Current()->socketserver()->Wait(10, false); |
152 } | 149 } |
153 } | 150 } |
154 // At this point the main thread has gone away. | 151 // At this point the main thread has gone away. |
155 // Give the SignalThread a little time to do its callback, | 152 // Give the SignalThread a little time to do its callback, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 EXPECT_STATE(1, 0, 0, 1, 1); | 193 EXPECT_STATE(1, 0, 0, 1, 1); |
197 } | 194 } |
198 | 195 |
199 TEST_F(SignalThreadTest, DeferredDestroyedThreadCleansUp) { | 196 TEST_F(SignalThreadTest, DeferredDestroyedThreadCleansUp) { |
200 thread_->Start(); | 197 thread_->Start(); |
201 EXPECT_STATE(1, 0, 0, 0, 0); | 198 EXPECT_STATE(1, 0, 0, 0, 0); |
202 thread_->Destroy(false); | 199 thread_->Destroy(false); |
203 EXPECT_STATE(1, 0, 0, 1, 0); | 200 EXPECT_STATE(1, 0, 0, 1, 0); |
204 EXPECT_STATE_WAIT(1, 1, 0, 1, 1, kTimeout); | 201 EXPECT_STATE_WAIT(1, 1, 0, 1, 1, kTimeout); |
205 } | 202 } |
OLD | NEW |