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

Side by Side Diff: base/threading/thread_unittest.cc

Issue 2186703002: Remove ThreadTest.Restart (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | 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/threading/thread.h" 5 #include "base/threading/thread.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // signal |event|. 113 // signal |event|.
114 void ReturnThreadId(base::Thread* thread, 114 void ReturnThreadId(base::Thread* thread,
115 base::PlatformThreadId* id, 115 base::PlatformThreadId* id,
116 base::WaitableEvent* event) { 116 base::WaitableEvent* event) {
117 *id = thread->GetThreadId(); 117 *id = thread->GetThreadId();
118 event->Signal(); 118 event->Signal();
119 } 119 }
120 120
121 } // namespace 121 } // namespace
122 122
123 TEST_F(ThreadTest, Restart) {
124 Thread a("Restart");
125 a.Stop();
126 EXPECT_FALSE(a.message_loop());
127 EXPECT_FALSE(a.IsRunning());
128 EXPECT_TRUE(a.Start());
129 EXPECT_TRUE(a.message_loop());
130 EXPECT_TRUE(a.IsRunning());
131 a.Stop();
132 EXPECT_FALSE(a.message_loop());
133 EXPECT_FALSE(a.IsRunning());
134 EXPECT_TRUE(a.Start());
135 EXPECT_TRUE(a.message_loop());
136 EXPECT_TRUE(a.IsRunning());
137 a.Stop();
138 EXPECT_FALSE(a.message_loop());
139 EXPECT_FALSE(a.IsRunning());
140 a.Stop();
141 EXPECT_FALSE(a.message_loop());
142 EXPECT_FALSE(a.IsRunning());
143 }
144
145 TEST_F(ThreadTest, StartWithOptions_StackSize) { 123 TEST_F(ThreadTest, StartWithOptions_StackSize) {
146 Thread a("StartWithStackSize"); 124 Thread a("StartWithStackSize");
147 // Ensure that the thread can work with only 12 kb and still process a 125 // Ensure that the thread can work with only 12 kb and still process a
148 // message. 126 // message.
149 Thread::Options options; 127 Thread::Options options;
150 #if defined(ADDRESS_SANITIZER) 128 #if defined(ADDRESS_SANITIZER)
151 // ASan bloats the stack variables and overflows the 12 kb stack. 129 // ASan bloats the stack variables and overflows the 12 kb stack.
152 options.stack_size = 24*1024; 130 options.stack_size = 24*1024;
153 #else 131 #else
154 options.stack_size = 12*1024; 132 options.stack_size = 12*1024;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 EXPECT_FALSE(a.message_loop()); 187 EXPECT_FALSE(a.message_loop());
210 EXPECT_FALSE(a.IsRunning()); 188 EXPECT_FALSE(a.IsRunning());
211 // Calling them when not running should also nop. 189 // Calling them when not running should also nop.
212 a.StopSoon(); 190 a.StopSoon();
213 a.Stop(); 191 a.Stop();
214 } 192 }
215 193
216 TEST_F(ThreadTest, StartTwice) { 194 TEST_F(ThreadTest, StartTwice) {
217 Thread a("StartTwice"); 195 Thread a("StartTwice");
218 196
219 EXPECT_TRUE(a.Start()); 197 EXPECT_TRUE(a.Start());
danakj 2016/07/26 19:41:09 can you check messageloop/IsRunning before calling
gab 2016/07/26 20:32:49 Done.
220 EXPECT_TRUE(a.message_loop()); 198 EXPECT_TRUE(a.message_loop());
221 EXPECT_TRUE(a.IsRunning()); 199 EXPECT_TRUE(a.IsRunning());
222 a.Stop(); 200 a.Stop();
223 EXPECT_FALSE(a.message_loop()); 201 EXPECT_FALSE(a.message_loop());
224 EXPECT_FALSE(a.IsRunning()); 202 EXPECT_FALSE(a.IsRunning());
225 203
226 EXPECT_TRUE(a.Start()); 204 EXPECT_TRUE(a.Start());
227 EXPECT_TRUE(a.message_loop()); 205 EXPECT_TRUE(a.message_loop());
228 EXPECT_TRUE(a.IsRunning()); 206 EXPECT_TRUE(a.IsRunning());
229 a.Stop(); 207 a.Stop();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 EXPECT_FALSE(a.task_runner()); 303 EXPECT_FALSE(a.task_runner());
326 } 304 }
327 305
328 TEST_F(ThreadTest, MultipleWaitUntilThreadStarted) { 306 TEST_F(ThreadTest, MultipleWaitUntilThreadStarted) {
329 Thread a("MultipleWaitUntilThreadStarted"); 307 Thread a("MultipleWaitUntilThreadStarted");
330 EXPECT_TRUE(a.Start()); 308 EXPECT_TRUE(a.Start());
331 // It's OK to call WaitUntilThreadStarted() multiple times. 309 // It's OK to call WaitUntilThreadStarted() multiple times.
332 EXPECT_TRUE(a.WaitUntilThreadStarted()); 310 EXPECT_TRUE(a.WaitUntilThreadStarted());
333 EXPECT_TRUE(a.WaitUntilThreadStarted()); 311 EXPECT_TRUE(a.WaitUntilThreadStarted());
334 } 312 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698