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 using namespace testing;
24 #ifdef HWTEST_TESTING_EXT_ENABLE
25 using namespace testing::ext;
26 #endif
27 using namespace ffrt;
28 using namespace std;
29 
30 class TaskCtxTest : public testing::Test {
31 protected:
SetUpTestCase()32     static void SetUpTestCase()
33     {
34     }
35 
TearDownTestCase()36     static void TearDownTestCase()
37     {
38     }
39 
SetUp()40     virtual void SetUp()
41     {
42     }
43 
TearDown()44     virtual void TearDown()
45     {
46     }
47 };
48 
49 /**
50  * @tc.name: ChargeQoSSubmit
51  * @tc.desc: Test whether the ChargeQoSSubmit interface are normal.
52  * @tc.type: FUNC
53  */
54 
55 HWTEST_F(TaskCtxTest, ChargeQoSSubmit, TestSize.Level1)
56 {
__anon1de5ba840102() 57     auto func = ([]() {std::cout << std::endl << " push a task " << std::endl;});
58     SCPUEUTask *task = new SCPUEUTask(nullptr, nullptr, 0, QoS());
59     QoS qos = QoS(static_cast<int>(qos_inherit));
60     task->SetQos(qos);
61     EXPECT_EQ(task->qos, qos_default);
62     delete task;
63 
__anon1de5ba840202() 64     auto func1 = ([]() {std::cout << std::endl << " push a task " << std::endl;});
65     SCPUEUTask *task1 = new SCPUEUTask(nullptr, nullptr, 0, QoS(static_cast<int>(qos_user_interactive)));
__anon1de5ba840302() 66     auto func2 = ([]() {std::cout << std::endl << " push a task " << std::endl;});
67     SCPUEUTask *task2 = new SCPUEUTask(nullptr, task1, 0, QoS());
68     QoS qos2 = QoS(static_cast<int>(qos_inherit));
69     task2->SetQos(qos2);
70     EXPECT_EQ(task2->qos, static_cast<int>(qos_user_interactive));
71     delete task1;
72     delete task2;
73 
__anon1de5ba840402() 74     auto func3 = ([]() {std::cout << std::endl << " push a task " << std::endl;});
75     SCPUEUTask *task3 = new SCPUEUTask(nullptr, nullptr, 0, QoS());
76     QoS qos3 = QoS(static_cast<int>(qos_user_interactive));
77     task3->SetQos(qos3);
78     EXPECT_EQ(task3->qos, static_cast<int>(qos_user_interactive));
79     delete task3;
80 }
81