1 /*
2  * Copyright (c) 2023 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_stage.h"
17 #include <gtest/gtest.h>
18 #include "proto.h"
19 #include "util.h"
20 #include "window_manager_hilog.h"
21 
22 
23 using namespace testing;
24 using namespace testing::ext;
25 
26 namespace OHOS {
27 namespace Rosen {
28 class EventStageTest : public testing::Test {
29 public:
30     static void SetUpTestCase();
31     static void TearDownTestCase();
32     void SetUp() override;
33     void TearDown() override;
34     EventStage eventStage_;
35 };
36 
SetUpTestCase()37 void EventStageTest::SetUpTestCase()
38 {
39 }
40 
TearDownTestCase()41 void EventStageTest::TearDownTestCase()
42 {
43 }
44 
SetUp()45 void EventStageTest::SetUp()
46 {
47 }
48 
TearDown()49 void EventStageTest::TearDown()
50 {
51 }
52 
53 namespace {
54 /**
55  * @tc.name: SetAnrStatus
56  * @tc.desc: test function : SetAnrStatus
57  * @tc.type: FUNC
58  */
59 HWTEST_F(EventStageTest, SetAnrStatus, Function | SmallTest | Level1)
60 {
61     int32_t persistentId = 0;
62     bool status = false;
63     eventStage_.SetAnrStatus(persistentId, status);
64     status = true;
65     eventStage_.SetAnrStatus(persistentId, status);
66     ASSERT_EQ(status, true);
67 }
68 
69 /**
70  * @tc.name: CheckAnrStatus
71  * @tc.desc: test function : CheckAnrStatus
72  * @tc.type: FUNC
73  */
74 HWTEST_F(EventStageTest, CheckAnrStatus, Function | SmallTest | Level1)
75 {
76     int32_t persistentId = 0;
77     auto res  = eventStage_.CheckAnrStatus(persistentId);
78     ASSERT_EQ(res, false);
79 }
80 
81 /**
82  * @tc.name: SaveANREvent
83  * @tc.desc: test function : SaveANREvent
84  * @tc.type: FUNC
85  */
86 HWTEST_F(EventStageTest, SaveANREvent, Function | SmallTest | Level1)
87 {
88     int32_t persistentId = 0;
89     int32_t eventId = 0;
90     int32_t timerId = 0;
91     eventStage_.SaveANREvent(persistentId, eventId, timerId);
92     ASSERT_EQ(eventId, 0);
93 }
94 
95 /**
96  * @tc.name: GetTimerIds
97  * @tc.desc: test function : GetTimerIds
98  * @tc.type: FUNC
99  */
100 HWTEST_F(EventStageTest, GetTimerIds, Function | SmallTest | Level1)
101 {
102     int32_t persistentId = 0;
103     eventStage_.GetTimerIds(persistentId);
104     ASSERT_EQ(persistentId, 0);
105 }
106 
107 /**
108  * @tc.name: DelEvents
109  * @tc.desc: test function : DelEvents
110  * @tc.type: FUNC
111  */
112 HWTEST_F(EventStageTest, DelEvents, Function | SmallTest | Level1)
113 {
114     int32_t persistentId = 0;
115     int32_t eventId = 0;
116     eventStage_.DelEvents(persistentId, eventId);
117     ASSERT_EQ(eventId, 0);
118 }
119 
120 /**
121  * @tc.name: OnSessionLost
122  * @tc.desc: test function : OnSessionLost
123  * @tc.type: FUNC
124  */
125 HWTEST_F(EventStageTest, OnSessionLost, Function | SmallTest | Level1)
126 {
127     int32_t persistentId = 0;
128     eventStage_.OnSessionLost(persistentId);
129     ASSERT_EQ(false, eventStage_.CheckAnrStatus(persistentId));
130 }
131 }
132 }
133 }