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

Side by Side Diff: webrtc/base/signalthread_unittest.cc

Issue 2024813004: Improving the fake clock and using it to fix a flaky STUN timeout test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing another TSan warning. WebRtcSession wasn't completely shut down. Created 4 years, 6 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
OLDNEW
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
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
143 { 146 {
144 std::unique_ptr<OwnerThread> owner(new OwnerThread(this)); 147 std::unique_ptr<OwnerThread> owner(new OwnerThread(this));
145 main_thread_ = owner.get(); 148 main_thread_ = owner.get();
146 owner->Start(); 149 owner->Start();
147 while (!owner->has_run()) { 150 while (!owner->has_run()) {
148 Thread::Current()->socketserver()->Wait(10, false); 151 Thread::Current()->socketserver()->Wait(10, false);
149 } 152 }
150 } 153 }
151 // At this point the main thread has gone away. 154 // At this point the main thread has gone away.
152 // Give the SignalThread a little time to do its callback, 155 // Give the SignalThread a little time to do its callback,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 EXPECT_STATE(1, 0, 0, 1, 1); 196 EXPECT_STATE(1, 0, 0, 1, 1);
194 } 197 }
195 198
196 TEST_F(SignalThreadTest, DeferredDestroyedThreadCleansUp) { 199 TEST_F(SignalThreadTest, DeferredDestroyedThreadCleansUp) {
197 thread_->Start(); 200 thread_->Start();
198 EXPECT_STATE(1, 0, 0, 0, 0); 201 EXPECT_STATE(1, 0, 0, 0, 0);
199 thread_->Destroy(false); 202 thread_->Destroy(false);
200 EXPECT_STATE(1, 0, 0, 1, 0); 203 EXPECT_STATE(1, 0, 0, 1, 0);
201 EXPECT_STATE_WAIT(1, 1, 0, 1, 1, kTimeout); 204 EXPECT_STATE_WAIT(1, 1, 0, 1, 1, kTimeout);
202 } 205 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698