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 23namespace OHOS { 24namespace FFRT_TEST { 25using namespace testing; 26#ifdef HWTEST_TESTING_EXT_ENABLE 27using namespace testing::ext; 28#endif 29using namespace OHOS::FFRT_TEST; 30using namespace ffrt; 31using namespace std; 32 33class TaskCtxTest : public testing::Test { 34protected: 35 static void SetUpTestCase() 36 { 37 } 38 39 static void TearDownTestCase() 40 { 41 } 42 43 virtual void SetUp() 44 { 45 } 46 47 virtual void TearDown() 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 58HWTEST_F(TaskCtxTest, ChargeQoSSubmit, TestSize.Level1) 59{ 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 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))); 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 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