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 "gtest/gtest.h"
17 #include "concurrent_task_client.h"
18
19 namespace OHOS {
20 namespace FFRT_TEST {
21 using namespace testing;
22 using namespace testing::ext;
23 using namespace OHOS::ConcurrentTask;
24
25
26 class ConcurrentTaskClientTest : public testing::Test {
27 public:
28 static void SetUpTestCase();
29 static void TearDownTestCase();
30 void SetUp();
31 void TearDown();
32 };
33
SetUpTestCase()34 void ConcurrentTaskClientTest::SetUpTestCase()
35 {
36 }
37
TearDownTestCase()38 void ConcurrentTaskClientTest::TearDownTestCase()
39 {
40 }
41
SetUp()42 void ConcurrentTaskClientTest::SetUp()
43 {
44 }
45
TearDown()46 void ConcurrentTaskClientTest::TearDown()
47 {
48 }
49
50 /**
51 * @tc.name: PushTaskTest
52 * @tc.desc: Test whether the PushTask interface are normal.
53 * @tc.type: FUNC
54 */
55 HWTEST_F(ConcurrentTaskClientTest, ReportDataTest, TestSize.Level1)
56 {
57 uint32_t resType = 0;
58 int64_t value = 3587;
59 std::unordered_map<std::string, std::string> payload;
60 payload["uid"] = "3587";
61 payload["pid"] = "12345";
62 payload["type"] = "appStart";
63 ConcurrentTaskClient::GetInstance().ReportData(resType, value, payload);
64 }
65
66 /**
67 * @tc.name: PushTaskTest
68 * @tc.desc: Test whether the PushTask interface are normal.
69 * @tc.type: FUNC
70 */
71 HWTEST_F(ConcurrentTaskClientTest, QueryIntervalTest, TestSize.Level1)
72 {
73 int queryItem = 3;
74 IntervalReply queryRs = {87, 657, 357, 214};
75 ConcurrentTaskClient::GetInstance().QueryInterval(queryItem, queryRs);
76 }
77
78 /**
79 * @tc.name: PushTaskTest
80 * @tc.desc: Test whether the PushTask interface are normal.
81 * @tc.type: FUNC
82 */
83 HWTEST_F(ConcurrentTaskClientTest, StopRemoteObjectTest, TestSize.Level1)
84 {
85 ConcurrentTaskClient::GetInstance().StopRemoteObject();
86 }
87
88 /**
89 * @tc.name: PushTaskTest
90 * @tc.desc: Test whether the PushTask interface are normal.
91 * @tc.type: FUNC
92 */
93 HWTEST_F(ConcurrentTaskClientTest, QueryDeadlineTest, TestSize.Level1)
94 {
95 int queryItem = 0;
96 DeadlineReply ddlReply = { false };
97 std::unordered_map<pid_t, uint32_t> payload;
98 payload[1111] = 60;
99 payload[2222] = 90;
100 ConcurrentTaskClient::GetInstance().QueryDeadline(queryItem, ddlReply, payload);
101 }
102
103 /**
104 * @tc.name: RequestAuthTest
105 * @tc.desc: Test whether the RequestAuth interface are normal.
106 * @tc.type: FUNC
107 */
108 HWTEST_F(ConcurrentTaskClientTest, RequestAuthTest, TestSize.Level1)
109 {
110 std::unordered_map<std::string, std::string> payload;
111 payload["uid"] = "3587";
112 payload["pid"] = "12345";
113 ConcurrentTaskClient::GetInstance().RequestAuth(payload);
114 }
115 }
116 }