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

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

Issue 1097753002: patch from 1011683002 w/o audio thread fix (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@1011683002_thread
Patch Set: Created 5 years, 8 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 | « base/threading/thread_id_name_manager_unittest.cc ('k') | chrome/browser/io_thread.h » ('j') | 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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 EXPECT_FALSE(a.message_loop()); 188 EXPECT_FALSE(a.message_loop());
189 EXPECT_FALSE(a.IsRunning()); 189 EXPECT_FALSE(a.IsRunning());
190 } 190 }
191 191
192 TEST_F(ThreadTest, ThreadName) { 192 TEST_F(ThreadTest, ThreadName) {
193 Thread a("ThreadName"); 193 Thread a("ThreadName");
194 EXPECT_TRUE(a.Start()); 194 EXPECT_TRUE(a.Start());
195 EXPECT_EQ("ThreadName", a.thread_name()); 195 EXPECT_EQ("ThreadName", a.thread_name());
196 } 196 }
197 197
198 // Make sure we can't use a thread between Start() and Init(). 198 // Make sure Init() is called after Start() and before
199 // WaitUntilThreadInitialized() returns.
199 TEST_F(ThreadTest, SleepInsideInit) { 200 TEST_F(ThreadTest, SleepInsideInit) {
200 SleepInsideInitThread t; 201 SleepInsideInitThread t;
201 EXPECT_FALSE(t.InitCalled()); 202 EXPECT_FALSE(t.InitCalled());
202 t.Start(); 203 t.StartAndWait();
203 EXPECT_TRUE(t.InitCalled()); 204 EXPECT_TRUE(t.InitCalled());
204 } 205 }
205 206
206 // Make sure that the destruction sequence is: 207 // Make sure that the destruction sequence is:
207 // 208 //
208 // (1) Thread::CleanUp() 209 // (1) Thread::CleanUp()
209 // (2) MessageLoop::~MessageLoop() 210 // (2) MessageLoop::~MessageLoop()
210 // MessageLoop::DestructionObservers called. 211 // MessageLoop::DestructionObservers called.
211 TEST_F(ThreadTest, CleanUp) { 212 TEST_F(ThreadTest, CleanUp) {
212 EventList captured_events; 213 EventList captured_events;
(...skipping 14 matching lines...) Expand all
227 228
228 // Upon leaving this scope, the thread is deleted. 229 // Upon leaving this scope, the thread is deleted.
229 } 230 }
230 231
231 // Check the order of events during shutdown. 232 // Check the order of events during shutdown.
232 ASSERT_EQ(static_cast<size_t>(THREAD_NUM_EVENTS), captured_events.size()); 233 ASSERT_EQ(static_cast<size_t>(THREAD_NUM_EVENTS), captured_events.size());
233 EXPECT_EQ(THREAD_EVENT_INIT, captured_events[0]); 234 EXPECT_EQ(THREAD_EVENT_INIT, captured_events[0]);
234 EXPECT_EQ(THREAD_EVENT_CLEANUP, captured_events[1]); 235 EXPECT_EQ(THREAD_EVENT_CLEANUP, captured_events[1]);
235 EXPECT_EQ(THREAD_EVENT_MESSAGE_LOOP_DESTROYED, captured_events[2]); 236 EXPECT_EQ(THREAD_EVENT_MESSAGE_LOOP_DESTROYED, captured_events[2]);
236 } 237 }
OLDNEW
« no previous file with comments | « base/threading/thread_id_name_manager_unittest.cc ('k') | chrome/browser/io_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698