| 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" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 EXPECT_EQ(priority_, PlatformThread::GetCurrentThreadPriority()); | 232 EXPECT_EQ(priority_, PlatformThread::GetCurrentThreadPriority()); |
| 233 } | 233 } |
| 234 | 234 |
| 235 const ThreadPriority priority_; | 235 const ThreadPriority priority_; |
| 236 | 236 |
| 237 DISALLOW_COPY_AND_ASSIGN(ThreadPriorityTestThread); | 237 DISALLOW_COPY_AND_ASSIGN(ThreadPriorityTestThread); |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 } // namespace | 240 } // namespace |
| 241 | 241 |
| 242 #if defined(OS_MACOSX) | |
| 243 // PlatformThread::GetCurrentThreadPriority() is not implemented on OS X. | |
| 244 #define MAYBE_ThreadPriorityCurrentThread DISABLED_ThreadPriorityCurrentThread | |
| 245 #else | |
| 246 #define MAYBE_ThreadPriorityCurrentThread ThreadPriorityCurrentThread | |
| 247 #endif | |
| 248 | |
| 249 // Test changing a created thread's priority (which has different semantics on | 242 // Test changing a created thread's priority (which has different semantics on |
| 250 // some platforms). | 243 // some platforms). |
| 251 TEST(PlatformThreadTest, MAYBE_ThreadPriorityCurrentThread) { | 244 TEST(PlatformThreadTest, ThreadPriorityCurrentThread) { |
| 252 const bool bumping_priority_allowed = IsBumpingPriorityAllowed(); | 245 const bool bumping_priority_allowed = IsBumpingPriorityAllowed(); |
| 253 if (bumping_priority_allowed) { | 246 if (bumping_priority_allowed) { |
| 254 // Bump the priority in order to verify that new threads are started with | 247 // Bump the priority in order to verify that new threads are started with |
| 255 // normal priority. | 248 // normal priority. |
| 256 PlatformThread::SetCurrentThreadPriority(ThreadPriority::DISPLAY); | 249 PlatformThread::SetCurrentThreadPriority(ThreadPriority::DISPLAY); |
| 257 } | 250 } |
| 258 | 251 |
| 259 // Toggle each supported priority on the thread and confirm it affects it. | 252 // Toggle each supported priority on the thread and confirm it affects it. |
| 260 for (size_t i = 0; i < arraysize(kThreadPriorityTestValues); ++i) { | 253 for (size_t i = 0; i < arraysize(kThreadPriorityTestValues); ++i) { |
| 261 if (!bumping_priority_allowed && | 254 if (!bumping_priority_allowed && |
| (...skipping 10 matching lines...) Expand all Loading... |
| 272 thread.WaitForTerminationReady(); | 265 thread.WaitForTerminationReady(); |
| 273 ASSERT_TRUE(thread.IsRunning()); | 266 ASSERT_TRUE(thread.IsRunning()); |
| 274 | 267 |
| 275 thread.MarkForTermination(); | 268 thread.MarkForTermination(); |
| 276 PlatformThread::Join(handle); | 269 PlatformThread::Join(handle); |
| 277 ASSERT_FALSE(thread.IsRunning()); | 270 ASSERT_FALSE(thread.IsRunning()); |
| 278 } | 271 } |
| 279 } | 272 } |
| 280 | 273 |
| 281 } // namespace base | 274 } // namespace base |
| OLD | NEW |