1 /*
2 * Copyright (c) 2022 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 <cinttypes>
17 #include <sys/resource.h>
18 #include <sched.h>
19 #include <linux/sched.h>
20 #include "gtest/gtest.h"
21 #include "parameters.h"
22 #define private public
23 #include "concurrent_task_controller_interface.h"
24 #include "rtg_interface.h"
25 #include "ipc_skeleton.h"
26 #include "concurrent_task_log.h"
27 #undef private
28
29 namespace OHOS {
30 namespace FFRT_TEST {
31 using namespace testing;
32 using namespace testing::ext;
33 using namespace OHOS::ConcurrentTask;
34 using namespace std;
35
36 class ConcurrentTaskControllerInterfaceTest : public testing::Test {
37 public:
38 static void SetUpTestCase();
39 static void TearDownTestCase();
40 void SetUp();
41 void TearDown();
42 };
43
SetUpTestCase()44 void ConcurrentTaskControllerInterfaceTest::SetUpTestCase() {}
45
TearDownTestCase()46 void ConcurrentTaskControllerInterfaceTest::TearDownTestCase() {}
47
SetUp()48 void ConcurrentTaskControllerInterfaceTest::SetUp() {}
49
TearDown()50 void ConcurrentTaskControllerInterfaceTest::TearDown() {}
51
52 /**
53 * @tc.name: RequestAuthTest
54 * @tc.desc: Test whether the ReportDataTest interface are normal.
55 * @tc.type: FUNC
56 */
57 HWTEST_F(ConcurrentTaskControllerInterfaceTest, RequestAuthTest, TestSize.Level1)
58 {
59 const Json::Value payload;
60 TaskControllerInterface repData;
61 repData.RequestAuth(payload);
62 EXPECT_TRUE(payload.empty());
63 }
64
65 /**
66 * @tc.name: ReportDataTest
67 * @tc.desc: Test whether the ReportDataTest interface are normal.
68 * @tc.type: FUNC
69 */
70 HWTEST_F(ConcurrentTaskControllerInterfaceTest, ReportDataTest, TestSize.Level1)
71 {
72 uint32_t resType = 0;
73 int64_t value = 0;
74 const Json::Value payload;
75 TaskControllerInterface repData;
76 repData.ReportData(resType, value, payload);
77 EXPECT_TRUE(payload.empty());
78 }
79
80 /**
81 * @tc.name: ReportSceneInfoTest
82 * @tc.desc: Test whether the ReportSceneInfoTest interface are normal.
83 * @tc.type: FUNC
84 */
85 HWTEST_F(ConcurrentTaskControllerInterfaceTest, ReportSceneInfoTest, TestSize.Level1)
86 {
87 uint32_t resType = 0;
88 const Json::Value payload;
89 TaskControllerInterface repData;
90 repData.ReportSceneInfo(resType, payload);
91 EXPECT_TRUE(payload.empty());
92 }
93
94 /**
95 * @tc.name: QueryDeadlineTest
96 * @tc.desc: Test whether the QueryDeadlineTest interface are normal.
97 * @tc.type: FUNC
98 */
99 HWTEST_F(ConcurrentTaskControllerInterfaceTest, QueryDeadlineTest, TestSize.Level1)
100 {
101 int queryItem = DDL_RATE;
102 DeadlineReply ddlReply = {false};
103 const Json::Value payload;
104 TaskControllerInterface::GetInstance().QueryDeadline(queryItem, ddlReply, payload);
105 EXPECT_TRUE(payload.empty());
106 }
107
108 /**
109 * @tc.name: PushTaskTest
110 * @tc.desc: Test whether the PushTask interface are normal.
111 * @tc.type: FUNC
112 */
113 HWTEST_F(ConcurrentTaskControllerInterfaceTest, QueryIntervalTest, TestSize.Level1)
114 {
115 TaskControllerInterface queInt;
116 int queryItem = QUERY_UI;
117 IntervalReply queryRs = {87, 657, 357, 214};
118 queInt.QueryInterval(queryItem, queryRs);
119 queryItem = QUERY_RENDER;
120 queInt.QueryInterval(queryItem, queryRs);
121 queryItem = QUERY_RENDER_SERVICE;
122 queInt.QueryInterval(queryItem, queryRs);
123 queryItem = QUERY_COMPOSER;
124 queInt.QueryInterval(queryItem, queryRs);
125 queryItem = QURRY_TYPE_MAX;
126 queInt.QueryInterval(queryItem, queryRs);
127 EXPECT_FALSE(queInt.inited_);
128 }
129
130 /**
131 * @tc.name: PushTaskTest
132 * @tc.desc: Test whether the PushTask interface are normal.
133 * @tc.type: FUNC
134 */
135 HWTEST_F(ConcurrentTaskControllerInterfaceTest, InitTest, TestSize.Level1)
136 {
137 TaskControllerInterface::GetInstance().Init();
138 EXPECT_FALSE(TaskControllerInterface::GetInstance().inited_);
139 }
140
141 /**
142 * @tc.name: PushTaskTest
143 * @tc.desc: Test whether the PushTask interface are normal.
144 * @tc.type: FUNC
145 */
146 HWTEST_F(ConcurrentTaskControllerInterfaceTest, ReleaseTest, TestSize.Level1)
147 {
148 TaskControllerInterface::GetInstance().Release();
149 EXPECT_FALSE(TaskControllerInterface::GetInstance().inited_);
150 }
151 } // namespace FFRT_TEST
152 } // namespace OHOS