1 /*
2 * Copyright (c) 2024 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
18 #include "intention_event/dfx/include/dfx_hisysevent.h"
19 #include "window_manager_hilog.h"
20
21 using namespace testing;
22 using namespace testing::ext;
23
24 namespace OHOS {
25 namespace Rosen {
26
27 class DfxHisyseventTest : public testing::Test {
28 public:
29 static void SetUpTestCase();
30 static void TearDownTestCase();
31 void SetUp() override;
32 void TearDown() override;
33 };
34
SetUpTestCase()35 void DfxHisyseventTest::SetUpTestCase() {}
36
TearDownTestCase()37 void DfxHisyseventTest::TearDownTestCase() {}
38
SetUp()39 void DfxHisyseventTest::SetUp() {}
40
TearDown()41 void DfxHisyseventTest::TearDown() {}
42
43 namespace {
44 /**
45 * @tc.name: ApplicationBlockInput
46 * @tc.desc: ApplicationBlockInput test Succ
47 * @tc.type: FUNC
48 * @tc.require: #I6JLSI
49 */
50
TEST_F(DfxHisyseventTest,ApplicationBlockInput_Success)51 TEST_F(DfxHisyseventTest, ApplicationBlockInput_Success)
52 {
53 DfxHisysevent dfxHisysevent;
54 int32_t eventId = 1;
55 int32_t pid = 2;
56 std::string bundleName = "TestBundleName";
57 int32_t persistentId = 4;
58 int result = 0;
59 std::function<void()> func = [&]() {
60 dfxHisysevent.ApplicationBlockInput(eventId, pid, bundleName, persistentId);
61 result = 1;
62 };
63 func();
64 ASSERT_EQ(result, 1);
65 }
66
67 /**
68 * @tc.name: ApplicationBlockInput
69 * @tc.desc: ApplicationBlockInput test Fail1
70 * @tc.type: FUNC
71 * @tc.require: #I6JLSI
72 */
73
TEST_F(DfxHisyseventTest,ApplicationBlockInput_Fail1)74 TEST_F(DfxHisyseventTest, ApplicationBlockInput_Fail1)
75 {
76 DfxHisysevent dfxHisysevent;
77 int32_t eventId = 1;
78 int32_t pid = -5;
79 std::string bundleName = "TestBundleName";
80 int32_t persistentId = 2;
81 int result = 0;
82 std::function<void()> func = [&]() {
83 dfxHisysevent.ApplicationBlockInput(eventId, pid, bundleName, persistentId);
84 result = 1;
85 };
86 func();
87 ASSERT_EQ(result, 1);
88 }
89
90 /**
91 * @tc.name: ApplicationBlockInput
92 * @tc.desc: ApplicationBlockInput test Fail2
93 * @tc.type: FUNC
94 * @tc.require: #I6JLSI
95 */
96
TEST_F(DfxHisyseventTest,ApplicationBlockInput_Fail2)97 TEST_F(DfxHisyseventTest, ApplicationBlockInput_Fail2)
98 {
99 DfxHisysevent dfxHisysevent;
100 int32_t eventId = 1;
101 int32_t pid = 5;
102 std::string bundleName = "TestBundleName";
103 int32_t persistentId = -2;
104 int result = 0;
105 std::function<void()> func = [&]() {
106 dfxHisysevent.ApplicationBlockInput(eventId, pid, bundleName, persistentId);
107 result = 1;
108 };
109 func();
110 ASSERT_EQ(result, 1);
111 }
112
113 /**
114 * @tc.name: ApplicationBlockInput
115 * @tc.desc: ApplicationBlockInput test Fail3
116 * @tc.type: FUNC
117 * @tc.require: #I6JLSI
118 */
119
TEST_F(DfxHisyseventTest,ApplicationBlockInput_Fail3)120 TEST_F(DfxHisyseventTest, ApplicationBlockInput_Fail3)
121 {
122 DfxHisysevent dfxHisysevent;
123 int32_t eventId = 1;
124 int32_t pid = -5;
125 std::string bundleName = "TestBundleName";
126 int32_t persistentId = -2;
127 int result = 0;
128 std::function<void()> func = [&]() {
129 dfxHisysevent.ApplicationBlockInput(eventId, pid, bundleName, persistentId);
130 result = 1;
131 };
132 func();
133 ASSERT_EQ(result, 1);
134 }
135
136 } // namespace
137 } // namespace Rosen
138 } // namespace OHOS
139