1 /* 2 * Copyright (c) 2023 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 #include <gtest/gtest.h> 16 #include <thread> 17 #include "dm/dependence_manager.h" 18 #include "qos.h" 19 #include "ffrt_inner.h" 20 #include "internal_inc/types.h" 21 #include "common.h" 22 23 namespace OHOS { 24 namespace FFRT_TEST { 25 using namespace testing; 26 #ifdef HWTEST_TESTING_EXT_ENABLE 27 using namespace testing::ext; 28 #endif 29 using namespace OHOS::FFRT_TEST; 30 using namespace ffrt; 31 using namespace std; 32 33 class TaskCtxTest : public testing::Test { 34 protected: SetUpTestCase()35 static void SetUpTestCase() 36 { 37 } 38 TearDownTestCase()39 static void TearDownTestCase() 40 { 41 } 42 SetUp()43 void SetUp() override 44 { 45 } 46 TearDown()47 void TearDown() override 48 { 49 } 50 }; 51 52 /** 53 * @tc.name: ChargeQoSSubmit 54 * @tc.desc: Test whether the ChargeQoSSubmit interface are normal. 55 * @tc.type: FUNC 56 */ 57 58 HWTEST_F(TaskCtxTest, ChargeQoSSubmit, TestSize.Level1) 59 { __anona8c2e08c0102() 60 auto func = ([]() {std::cout << std::endl << " push a task " << std::endl;}); 61 SCPUEUTask *task = new SCPUEUTask(nullptr, nullptr, 0, QoS()); 62 QoS qos = QoS(static_cast<int>(qos_inherit)); 63 task->SetQos(qos); 64 EXPECT_EQ(task->qos_, qos_default); 65 delete task; 66 __anona8c2e08c0202() 67 auto func1 = ([]() {std::cout << std::endl << " push a task " << std::endl;}); 68 SCPUEUTask *task1 = new SCPUEUTask(nullptr, nullptr, 0, QoS(static_cast<int>(qos_user_interactive))); __anona8c2e08c0302() 69 auto func2 = ([]() {std::cout << std::endl << " push a task " << std::endl;}); 70 SCPUEUTask *task2 = new SCPUEUTask(nullptr, task1, 0, QoS()); 71 QoS qos2 = QoS(static_cast<int>(qos_inherit)); 72 task2->SetQos(qos2); 73 EXPECT_EQ(task2->qos_, static_cast<int>(qos_user_interactive)); 74 delete task1; 75 delete task2; 76 __anona8c2e08c0402() 77 auto func3 = ([]() {std::cout << std::endl << " push a task " << std::endl;}); 78 SCPUEUTask *task3 = new SCPUEUTask(nullptr, nullptr, 0, QoS()); 79 QoS qos3 = QoS(static_cast<int>(qos_user_interactive)); 80 task3->SetQos(qos3); 81 EXPECT_EQ(task3->qos_, static_cast<int>(qos_user_interactive)); 82 delete task3; 83 } 84 } 85 } 86