Chromium Code Reviews| Index: webrtc/base/platform_thread_unittest.cc |
| diff --git a/webrtc/system_wrappers/source/thread_unittest.cc b/webrtc/base/platform_thread_unittest.cc |
| similarity index 56% |
| rename from webrtc/system_wrappers/source/thread_unittest.cc |
| rename to webrtc/base/platform_thread_unittest.cc |
| index c8e180ba32a2a88256770d9008fd03d3f4292979..7a101d6e6d063bd2267f215ca6cf26852344ae8a 100644 |
| --- a/webrtc/system_wrappers/source/thread_unittest.cc |
| +++ b/webrtc/base/platform_thread_unittest.cc |
| @@ -8,7 +8,7 @@ |
| * be found in the AUTHORS file in the root of the source tree. |
| */ |
| -#include "webrtc/system_wrappers/include/thread_wrapper.h" |
| +#include "webrtc/base/platform_thread.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "webrtc/base/scoped_ptr.h" |
| @@ -22,9 +22,9 @@ bool NullRunFunction(void* obj) { |
| return true; |
| } |
| -TEST(ThreadTest, StartStop) { |
| - rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread( |
| - &NullRunFunction, nullptr, "ThreadTest"); |
| +TEST(PlatformThreadTest, StartStop) { |
| + rtc::scoped_ptr<PlatformThread> thread = PlatformThread::CreateThread( |
| + &NullRunFunction, nullptr, "PlatformThreadTest"); |
| ASSERT_TRUE(thread->Start()); |
| EXPECT_TRUE(thread->Stop()); |
| } |
| @@ -37,9 +37,9 @@ bool SetFlagRunFunction(void* obj) { |
| return true; |
| } |
| -TEST(ThreadTest, RunFunctionIsCalled) { |
| +TEST(PlatformThreadTest, RunFunctionIsCalled) { |
| bool flag = false; |
| - rtc::scoped_ptr<ThreadWrapper> thread = ThreadWrapper::CreateThread( |
| + rtc::scoped_ptr<PlatformThread> thread = PlatformThread::CreateThread( |
|
tommi
2015/11/23 14:49:12
do we need CreateThread() now that the implementat
pbos-webrtc
2015/11/23 15:05:40
Nope, hence the TODO in the header. Preferring to
|
| &SetFlagRunFunction, &flag, "RunFunctionIsCalled"); |
| ASSERT_TRUE(thread->Start()); |
| @@ -50,4 +50,22 @@ TEST(ThreadTest, RunFunctionIsCalled) { |
| EXPECT_TRUE(flag); |
| } |
| +#if defined(WEBRTC_POSIX) |
| +TEST(PlatformThreadTestPosix, PrioritySettings) { |
|
tommi
2015/11/23 14:49:12
delete this test?
pbos-webrtc
2015/11/23 15:05:40
Done.
|
| + // API assumes that max_prio - min_prio > 2. Test the extreme case. |
| + const int kMinPrio = -1; |
| + const int kMaxPrio = 2; |
| + |
| + int last_priority = kMinPrio; |
| + for (int priority = webrtc::kLowPriority; |
| + priority <= webrtc::kRealtimePriority; ++priority) { |
| + int system_priority = PlatformThread::ConvertToSystemPriority( |
| + static_cast<webrtc::ThreadPriority>(priority), kMinPrio, kMaxPrio); |
| + EXPECT_GT(system_priority, kMinPrio); |
| + EXPECT_LT(system_priority, kMaxPrio); |
| + EXPECT_GE(system_priority, last_priority); |
| + last_priority = system_priority; |
| + } |
| +} |
| +#endif // defined(WEBRTC_POSIX) |
| } // namespace webrtc |