1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "audio_qosmanager.h" 17 #include <gtest/gtest.h> 18 #include <chrono> 19 #include <thread> 20 21 using namespace testing::ext; 22 using namespace std; 23 24 namespace { 25 static constexpr int32_t WAIT_FOR_SET_QOS_TIME_MS = 500; // 500ms 26 static constexpr int32_t SET_PRIORITY_1 = 1; 27 static constexpr int32_t SET_PRIORITY_4 = 4; 28 } 29 30 class AudioQosmanagerUnitTest : public ::testing::Test { 31 public: SetUpTestCase()32 static void SetUpTestCase(){}; TearDownTestCase()33 static void TearDownTestCase(){}; SetUp()34 virtual void SetUp(){}; TearDown()35 virtual void TearDown(){}; 36 }; 37 38 /** 39 * @tc.name : Test SetThreadQosLevelAsync 40 * @tc.number : SetThreadQosLevelAsync_001 41 * @tc.desc : Verify SetThreadQosLevelAsync function returns success and maintains thread ID 42 */ 43 HWTEST_F(AudioQosmanagerUnitTest, SetThreadQosLevelAsync_001, TestSize.Level4) 44 { 45 SetThreadQosLevelAsync(SET_PRIORITY_1); 46 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_FOR_SET_QOS_TIME_MS)); 47 ResetThreadQosLevel(); 48 EXPECT_TRUE(gettid()); 49 SetThreadQosLevelAsync(SET_PRIORITY_4); 50 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_FOR_SET_QOS_TIME_MS)); 51 ResetThreadQosLevel(); 52 EXPECT_TRUE(gettid()); 53 } 54