| 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..d06a738a337a4af09fb102ca34264f967e832c2e 100644
|
| --- a/webrtc/base/platform_thread_unittest.cc
|
| +++ b/webrtc/base/platform_thread_unittest.cc
|
| @@ -14,31 +14,47 @@
|
| #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);
|
| +}
|
| +
|
| +TEST(PlatformThreadTest, StartStop2) {
|
| + PlatformThread thread1(&NullRunFunction, nullptr, "PlatformThreadTest1");
|
| + PlatformThread thread2(&NullRunFunction, nullptr, "PlatformThreadTest2");
|
| + EXPECT_TRUE(thread1.GetThreadRef() == thread2.GetThreadRef());
|
| + thread1.Start();
|
| + thread2.Start();
|
| + EXPECT_TRUE(thread1.GetThreadRef() != thread2.GetThreadRef());
|
| + thread2.Stop();
|
| + thread1.Stop();
|
| +}
|
|
|
| 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 +63,4 @@ TEST(PlatformThreadTest, RunFunctionIsCalled) {
|
| // We expect the thread to have run at least once.
|
| EXPECT_TRUE(flag);
|
| }
|
| -
|
| -} // namespace webrtc
|
| +} // rtc
|
|
|