henrike@webrtc.org | 5ba4411 | 2012-10-05 14:36:54 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include "system_wrappers/source/thread_posix.h" |
| 12 | |
| 13 | #include "gtest/gtest.h" |
| 14 | |
| 15 | TEST(ThreadTestPosix, PrioritySettings) { |
| 16 | // API assumes that maxPrio - minPrio > 2. Test the extreme case. |
| 17 | const int kMinPrio = -1; |
| 18 | const int kMaxPrio = 2; |
| 19 | |
| 20 | int last_priority = kMinPrio; |
| 21 | for (int priority = webrtc::kLowPriority; |
| 22 | priority <= webrtc::kRealtimePriority; ++priority) { |
| 23 | int system_priority = webrtc::ConvertToSystemPriority( |
| 24 | static_cast<webrtc::ThreadPriority>(priority), kMinPrio, kMaxPrio); |
| 25 | EXPECT_GT(system_priority, kMinPrio); |
| 26 | EXPECT_LT(system_priority, kMaxPrio); |
| 27 | EXPECT_GE(system_priority, last_priority); |
| 28 | last_priority = system_priority; |
| 29 | } |
| 30 | } |