• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 std::unordered_map<std::string, std::string> 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 std::unordered_map<std::string, std::string> 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 std::unordered_map<std::string, std::string> 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 std::unordered_map<std::string, std::string> 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 = QUERY_HARDWARE;
126     queInt.QueryInterval(queryItem, queryRs);
127     queryItem = QUERY_EXECUTOR_START;
128     queInt.QueryInterval(queryItem, queryRs);
129     queryItem = QUERY_RENDER_SERVICE_MAIN;
130     queInt.QueryInterval(queryItem, queryRs);
131     queryItem = QUERY_RENDER_SERVICE_RENDER;
132     queInt.QueryInterval(queryItem, queryRs);
133     queryItem = QURRY_TYPE_MAX;
134     queInt.QueryInterval(queryItem, queryRs);
135     EXPECT_FALSE(queInt.inited_);
136 }
137 
138 /**
139  * @tc.name: PushTaskTest
140  * @tc.desc: Test whether the PushTask interface are normal.
141  * @tc.type: FUNC
142  */
143 HWTEST_F(ConcurrentTaskControllerInterfaceTest, SetAudioDeadlineTest, TestSize.Level1)
144 {
145     TaskControllerInterface queInt;
146     int queryItem = AUDIO_DDL_CREATE_GRP;
147     IntervalReply queryRs = {0};
148     queInt.SetAudioDeadline(queryItem, -1, -1, queryRs);
149     queryItem = AUDIO_DDL_ADD_THREAD;
150     queInt.SetAudioDeadline(queryItem, gettid(), queryRs.rtgId, queryRs);
151     queryItem = AUDIO_DDL_REMOVE_THREAD;
152     queInt.SetAudioDeadline(queryItem, gettid(), queryRs.rtgId, queryRs);
153     queryItem = AUDIO_DDL_DESTROY_GRP;
154     queInt.SetAudioDeadline(queryItem, -1, queryRs.rtgId, queryRs);
155     EXPECT_FALSE(queInt.inited_);
156 }
157 
158 /**
159  * @tc.name: PushTaskTest
160  * @tc.desc: Test whether the PushTask interface are normal.
161  * @tc.type: FUNC
162  */
163 HWTEST_F(ConcurrentTaskControllerInterfaceTest, InitTest, TestSize.Level1)
164 {
165     TaskControllerInterface::GetInstance().Init();
166     EXPECT_FALSE(TaskControllerInterface::GetInstance().inited_);
167 }
168 
169 /**
170  * @tc.name: PushTaskTest
171  * @tc.desc: Test whether the PushTask interface are normal.
172  * @tc.type: FUNC
173  */
174 HWTEST_F(ConcurrentTaskControllerInterfaceTest, ReleaseTest, TestSize.Level1)
175 {
176     TaskControllerInterface::GetInstance().Release();
177     EXPECT_FALSE(TaskControllerInterface::GetInstance().inited_);
178 }
179 } // namespace FFRT_TEST
180 } // namespace OHOS