Index: webrtc/base/platform_thread_unittest.cc |
diff --git a/webrtc/base/platform_thread_unittest.cc b/webrtc/base/platform_thread_unittest.cc |
index f9db8e34a305f3fd821280f7549f942742632c78..a0d03bfbefb1956d23f939b91b55b5a687d5f8ad 100644 |
--- a/webrtc/base/platform_thread_unittest.cc |
+++ b/webrtc/base/platform_thread_unittest.cc |
@@ -14,31 +14,36 @@ |
#include "webrtc/base/scoped_ptr.h" |
#include "webrtc/system_wrappers/include/sleep.h" |
-namespace webrtc { |
- |
+namespace rtc { |
+namespace { |
// Function that does nothing, and reports success. |
bool NullRunFunction(void* obj) { |
- SleepMs(0); // Hand over timeslice, prevents busy looping. |
+ webrtc::SleepMs(0); // Hand over timeslice, prevents busy looping. |
return true; |
} |
-TEST(PlatformThreadTest, StartStop) { |
- rtc::PlatformThread thread(&NullRunFunction, nullptr, "PlatformThreadTest"); |
- thread.Start(); |
- thread.Stop(); |
-} |
- |
// Function that sets a boolean. |
bool SetFlagRunFunction(void* obj) { |
bool* obj_as_bool = static_cast<bool*>(obj); |
*obj_as_bool = true; |
- SleepMs(0); // Hand over timeslice, prevents busy looping. |
+ webrtc::SleepMs(0); // Hand over timeslice, prevents busy looping. |
return true; |
} |
+} // namespace |
+ |
+TEST(PlatformThreadTest, StartStop) { |
+ PlatformThread thread(&NullRunFunction, nullptr, "PlatformThreadTest"); |
+ EXPECT_TRUE(thread.name() == "PlatformThreadTest"); |
+ EXPECT_TRUE(thread.GetThreadRef() == 0); |
+ thread.Start(); |
+ EXPECT_TRUE(thread.GetThreadRef() != 0); |
+ thread.Stop(); |
+ EXPECT_TRUE(thread.GetThreadRef() == 0); |
+} |
perkj_webrtc
2016/04/22 13:32:20
To show the usage- can you add another test with t
tommi
2016/04/22 14:47:11
Done.
|
TEST(PlatformThreadTest, RunFunctionIsCalled) { |
bool flag = false; |
- rtc::PlatformThread thread(&SetFlagRunFunction, &flag, "RunFunctionIsCalled"); |
+ PlatformThread thread(&SetFlagRunFunction, &flag, "RunFunctionIsCalled"); |
thread.Start(); |
// At this point, the flag may be either true or false. |
@@ -47,5 +52,4 @@ TEST(PlatformThreadTest, RunFunctionIsCalled) { |
// We expect the thread to have run at least once. |
EXPECT_TRUE(flag); |
} |
- |
-} // namespace webrtc |
+} // rtc |