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

Unified Diff: base/thread_unittest.cc

Issue 18508: Moved Init() startup_data_->event.Signal() because derived classes may... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/thread.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/thread_unittest.cc
===================================================================
--- base/thread_unittest.cc (revision 8282)
+++ base/thread_unittest.cc (working copy)
@@ -37,6 +37,20 @@
int msec_;
};
+class SleepInsideInitThread : public Thread {
+ public:
+ SleepInsideInitThread() : Thread("none") { init_called_ = false; }
Mark Mentovai 2009/01/22 19:36:10 Prefer |init_called_(false) { }| for constructors.
+ virtual ~SleepInsideInitThread() { }
+
+ virtual void Init() {
+ PlatformThread::Sleep(1000);
+ init_called_ = true;
+ }
+ bool InitCalled() { return init_called_; }
Mark Mentovai 2009/01/22 19:36:10 It's almost not worth mentioning for this because
+ private:
+ bool init_called_;
+};
+
} // namespace
TEST_F(ThreadTest, Restart) {
@@ -107,3 +121,12 @@
EXPECT_TRUE(a.Start());
EXPECT_EQ("ThreadName", a.thread_name());
}
+
+// Make sure we can't use a thread between Start() and Init().
+TEST_F(ThreadTest, SleepInsideInit) {
+ SleepInsideInitThread t;
+ EXPECT_FALSE(t.InitCalled());
+ t.Start();
+ EXPECT_TRUE(t.InitCalled());
+}
+
Mark Mentovai 2009/01/22 19:36:10 Nit: kill trailing blank line.
« no previous file with comments | « base/thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698