Index: base/threading/thread_unittest.cc |
diff --git a/base/threading/thread_unittest.cc b/base/threading/thread_unittest.cc |
index 3c3541657ebffbe5c2b0cbd5e37340509764598e..211875dffcd7022468181d86ef6ebdd5bab209b7 100644 |
--- a/base/threading/thread_unittest.cc |
+++ b/base/threading/thread_unittest.cc |
@@ -194,6 +194,33 @@ TEST_F(ThreadTest, ThreadName) { |
EXPECT_EQ("ThreadName", a.thread_name()); |
} |
+TEST_F(ThreadTest, ThreadId) { |
+ Thread a("ThreadId0"); |
+ Thread b("ThreadId1"); |
+ a.Start(); |
+ b.Start(); |
+ |
+ // A started thread should have a valid ID. |
+ EXPECT_NE(base::kInvalidThreadId, a.thread_id()); |
+ EXPECT_NE(base::kInvalidThreadId, b.thread_id()); |
+ |
+ // Each thread should have a different thread ID. |
+ EXPECT_NE(a.thread_id(), b.thread_id()); |
+} |
+ |
+TEST_F(ThreadTest, ThreadIdWithRestart) { |
+ Thread a("ThreadIdWithRestart"); |
+ base::PlatformThreadId previous_id = base::kInvalidThreadId; |
+ |
+ for (size_t i = 0; i < 16; ++i) { |
+ EXPECT_TRUE(a.Start()); |
+ base::PlatformThreadId current_id = a.thread_id(); |
+ EXPECT_NE(previous_id, current_id); |
+ previous_id = current_id; |
+ a.Stop(); |
+ } |
+} |
+ |
// Make sure Init() is called after Start() and before |
// WaitUntilThreadInitialized() returns. |
TEST_F(ThreadTest, SleepInsideInit) { |