OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 #if defined(OS_POSIX) | 14 #if defined(OS_POSIX) |
15 #include <sys/types.h> | 15 #include <sys/types.h> |
16 #include <unistd.h> | 16 #include <unistd.h> |
17 #include "base/threading/platform_thread_internal_posix.h" | |
17 #elif defined(OS_WIN) | 18 #elif defined(OS_WIN) |
18 #include <windows.h> | 19 #include <windows.h> |
19 #endif | 20 #endif |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 | 23 |
23 // Trivial tests that thread runs and doesn't crash on create and join --------- | 24 // Trivial tests that thread runs and doesn't crash on create and join --------- |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 ASSERT_TRUE(PlatformThread::Create(0, &thread, &handle)); | 265 ASSERT_TRUE(PlatformThread::Create(0, &thread, &handle)); |
265 thread.WaitForTerminationReady(); | 266 thread.WaitForTerminationReady(); |
266 ASSERT_TRUE(thread.IsRunning()); | 267 ASSERT_TRUE(thread.IsRunning()); |
267 | 268 |
268 thread.MarkForTermination(); | 269 thread.MarkForTermination(); |
269 PlatformThread::Join(handle); | 270 PlatformThread::Join(handle); |
270 ASSERT_FALSE(thread.IsRunning()); | 271 ASSERT_FALSE(thread.IsRunning()); |
271 } | 272 } |
272 } | 273 } |
273 | 274 |
275 #if defined(OS_LINUX) | |
276 TEST(PlatformThreadTest, GetNiceValueToThreadPriority) { | |
277 using internal::NiceValueToThreadPriority; | |
278 EXPECT_EQ(ThreadPriority::BACKGROUND, NiceValueToThreadPriority(19)); | |
gab
2016/04/08 15:52:51
To make these cross-platform (well on OS_POSIX) yo
Yuta Kitamura
2016/04/12 10:19:00
Yeah, updated the tests so they work on OS_POSIX.
| |
279 EXPECT_EQ(ThreadPriority::BACKGROUND, NiceValueToThreadPriority(11)); | |
280 EXPECT_EQ(ThreadPriority::BACKGROUND, NiceValueToThreadPriority(10)); | |
281 EXPECT_EQ(ThreadPriority::BACKGROUND, NiceValueToThreadPriority(9)); | |
282 EXPECT_EQ(ThreadPriority::BACKGROUND, NiceValueToThreadPriority(1)); | |
283 EXPECT_EQ(ThreadPriority::NORMAL, NiceValueToThreadPriority(0)); | |
284 EXPECT_EQ(ThreadPriority::NORMAL, NiceValueToThreadPriority(-7)); | |
285 EXPECT_EQ(ThreadPriority::DISPLAY, NiceValueToThreadPriority(-8)); | |
286 EXPECT_EQ(ThreadPriority::DISPLAY, NiceValueToThreadPriority(-9)); | |
287 EXPECT_EQ(ThreadPriority::REALTIME_AUDIO, NiceValueToThreadPriority(-10)); | |
288 EXPECT_EQ(ThreadPriority::REALTIME_AUDIO, NiceValueToThreadPriority(-20)); | |
289 } | |
290 #endif | |
291 | |
274 } // namespace base | 292 } // namespace base |
OLD | NEW |