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 "event_checker_test.h"
17
18 #include "parameter_ex.h"
19 #include "compliant_event_checker.h"
20
21 namespace OHOS {
22 namespace HiviewDFX {
23
SetUpTestCase()24 void EventCheckerTest::SetUpTestCase() {}
25
TearDownTestCase()26 void EventCheckerTest::TearDownTestCase() {}
27
SetUp()28 void EventCheckerTest::SetUp() {}
29
TearDown()30 void EventCheckerTest::TearDown() {}
31
32 /**
33 * @tc.name: EventCheckerTest001
34 * @tc.desc: Test isCompliantRule apis of RuleChecker
35 * @tc.type: FUNC
36 * @tc.require: issueIAPJKN
37 */
38 HWTEST_F(EventCheckerTest, EventCheckerTest001, testing::ext::TestSize.Level3)
39 {
40 CompliantEventChecker eventChecker;
41 if (Parameter::GetInteger("const.secure", 1) == 0) { // 1 and 0 is test value
42 ASSERT_TRUE(eventChecker.IsCompliantEvent("AAFWK", ""));
43 ASSERT_TRUE(eventChecker.IsCompliantEvent("AAFWK", "START_ABILITY"));
44 ASSERT_TRUE(eventChecker.IsCompliantEvent("ACE", "INTERACTION_COMPLETED_LATENCY"));
45 ASSERT_TRUE(eventChecker.IsCompliantEvent("AV_CODEC", "CODEC_START_INFO"));
46 ASSERT_TRUE(eventChecker.IsCompliantEvent("GRAPHIC", "INTERACTION_COMPLETED_LATENCY"));
47 ASSERT_TRUE(eventChecker.IsCompliantEvent("LOCATION", "GNSS_STATE"));
48 ASSERT_TRUE(eventChecker.IsCompliantEvent("PERFORMANCE", ""));
49 ASSERT_TRUE(eventChecker.IsCompliantEvent("RELIBILITY", ""));
50 ASSERT_TRUE(eventChecker.IsCompliantEvent("STABILITY", "JS_ERROR"));
51 ASSERT_TRUE(eventChecker.IsCompliantEvent("STABILITY", "JS_ERROR_INVALID"));
52 ASSERT_TRUE(eventChecker.IsCompliantEvent("WORKSCHEDULER", "WORK_ADD"));
53 ASSERT_TRUE(eventChecker.IsCompliantEvent("STABILITY", "WORK_ADD_INVALID"));
54 } else {
55 ASSERT_TRUE(eventChecker.IsCompliantEvent("AAFWK", ""));
56 ASSERT_FALSE(eventChecker.IsCompliantEvent("AAFWK", "START_ABILITY"));
57 ASSERT_FALSE(eventChecker.IsCompliantEvent("ACE", "INTERACTION_COMPLETED_LATENCY"));
58 ASSERT_FALSE(eventChecker.IsCompliantEvent("AV_CODEC", "CODEC_START_INFO"));
59 ASSERT_FALSE(eventChecker.IsCompliantEvent("GRAPHIC", "INTERACTION_COMPLETED_LATENCY"));
60 ASSERT_FALSE(eventChecker.IsCompliantEvent("LOCATION", "GNSS_STATE"));
61 ASSERT_FALSE(eventChecker.IsCompliantEvent("PERFORMANCE", ""));
62 ASSERT_FALSE(eventChecker.IsCompliantEvent("RELIBILITY", ""));
63 ASSERT_FALSE(eventChecker.IsCompliantEvent("STABILITY", "JS_ERROR"));
64 ASSERT_TRUE(eventChecker.IsCompliantEvent("STABILITY", "JS_ERROR_INVALID"));
65 ASSERT_FALSE(eventChecker.IsCompliantEvent("WORKSCHEDULER", "WORK_ADD"));
66 ASSERT_TRUE(eventChecker.IsCompliantEvent("STABILITY", "WORK_ADD_INVALID"));
67 }
68 }
69 } //
70 } //