blob: fadab57389873aef0e114116e53fd6f6b50278d2 [file] [log] [blame]
henrike@webrtc.org5ba44112012-10-05 14:36:54 +00001/*
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
phoglund@webrtc.orgec9c9422013-01-02 08:45:03 +000011#include "webrtc/system_wrappers/source/thread_posix.h"
henrike@webrtc.org5ba44112012-10-05 14:36:54 +000012
13#include "gtest/gtest.h"
14
15TEST(ThreadTestPosix, PrioritySettings) {
phoglund@webrtc.orgec9c9422013-01-02 08:45:03 +000016 // API assumes that max_prio - min_prio > 2. Test the extreme case.
henrike@webrtc.org5ba44112012-10-05 14:36:54 +000017 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}