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