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 #define private public
18 #include "user_event_handler.h"
19 #undef private
20
21 using namespace testing::ext;
22 using namespace OHOS::AppExecFwk;
23
24 namespace OHOS {
25 namespace AAFwk {
26 class UserEventHandlerTest : public testing::Test {
27 public:
28 static void SetUpTestCase(void);
29 static void TearDownTestCase(void);
30 void SetUp();
31 void TearDown();
32 };
33
SetUpTestCase(void)34 void UserEventHandlerTest::SetUpTestCase(void)
35 {}
TearDownTestCase(void)36 void UserEventHandlerTest::TearDownTestCase(void)
37 {}
SetUp(void)38 void UserEventHandlerTest::SetUp(void)
39 {}
TearDown(void)40 void UserEventHandlerTest::TearDown(void)
41 {}
42
43 /*
44 * Feature: UserEventHandler
45 * Function: ProcessEvent
46 * SubFunction: NA
47 * FunctionPoints: UserEventHandler ProcessEvent
48 * EnvConditions: NA
49 * CaseDescription: Verify ProcessEvent
50 */
51 HWTEST_F(UserEventHandlerTest, ProcessEvent_001, TestSize.Level1)
52 {
53 std::shared_ptr<EventRunner> runner;
54 std::weak_ptr<UserController> owner;
55 std::shared_ptr<UserEventHandler> handler = std::make_shared<UserEventHandler>(runner, owner);
56 InnerEvent::Pointer event = InnerEvent::Get();
57 event.reset();
58 handler->ProcessEvent(event);
59 }
60
61 /*
62 * Feature: UserEventHandler
63 * Function: ProcessEvent
64 * SubFunction: NA
65 * FunctionPoints: UserEventHandler ProcessEvent
66 * EnvConditions: NA
67 * CaseDescription: Verify ProcessEvent
68 */
69 HWTEST_F(UserEventHandlerTest, ProcessEvent_002, TestSize.Level1)
70 {
71 std::shared_ptr<EventRunner> runner;
72 std::weak_ptr<UserController> owner;
73 std::shared_ptr<UserEventHandler> handler = std::make_shared<UserEventHandler>(runner, owner);
74 InnerEvent::Pointer event = InnerEvent::Get();
75 handler->ProcessEvent(event);
76 }
77 } // namespace AAFwk
78 } // namespace OHOS
79