• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "input_window_monitor.h"
18 
19 using namespace testing;
20 using namespace testing::ext;
21 
22 namespace OHOS {
23 namespace Rosen {
24 class InputWindowMonitorTest : public testing::Test {
25 public:
26     static void SetUpTestCase();
27     static void TearDownTestCase();
28     void SetUp() override;
29     void TearDown() override;
30 
31     sptr<WindowRoot> root_;
32     sptr<InputWindowMonitor> input_monitor_;
33 };
34 
SetUpTestCase()35 void InputWindowMonitorTest::SetUpTestCase()
36 {
37 }
38 
TearDownTestCase()39 void InputWindowMonitorTest::TearDownTestCase()
40 {
41 }
42 
SetUp()43 void InputWindowMonitorTest::SetUp()
44 {
45     root_ = new WindowRoot([](Event event, const sptr<IRemoteObject>& remoteObject) {});
46     input_monitor_ = new InputWindowMonitor(root_);
47 }
48 
TearDown()49 void InputWindowMonitorTest::TearDown()
50 {
51     root_ = nullptr;
52     input_monitor_->InputWindowMonitor::~InputWindowMonitor();
53 }
54 
55 namespace {
56 /**
57  * @tc.name: UpdateInputWindow
58  * @tc.desc: Update Input Window
59  * @tc.type: FUNC
60  */
61 HWTEST_F(InputWindowMonitorTest, UpdateInputWindow01, Function | SmallTest | Level2)
62 {
63     input_monitor_->windowRoot_ = nullptr;
64     input_monitor_->UpdateInputWindow(0);
65     ASSERT_EQ(nullptr, input_monitor_->windowRoot_);
66 
__anon862baf9d0302(Event event, const sptr<IRemoteObject>& remoteObject) 67     input_monitor_->windowRoot_ = new WindowRoot([](Event event, const sptr<IRemoteObject>& remoteObject) {});
68     input_monitor_->windowRoot_->windowNodeMap_.insert(std::make_pair(0, nullptr));
69     input_monitor_->UpdateInputWindow(0);
70     ASSERT_EQ(nullptr, input_monitor_->windowRoot_->windowNodeMap_[0]);
71 }
72 /**
73  * @tc.name: GetDisplayDirectionForMmi
74  * @tc.desc: get display direction
75  * @tc.type: FUNC
76  */
77 HWTEST_F(InputWindowMonitorTest, GetDisplayDirectionForMmi01, Function | SmallTest | Level2)
78 {
79     Rotation rotate = Rotation::ROTATION_0;
80     ASSERT_EQ(MMI::DIRECTION0, input_monitor_->GetDisplayDirectionForMmi(rotate));
81 }
82 /**
83  * @tc.name: UpdateDisplayInfo
84  * @tc.desc: update displayinfo
85  * @tc.type: FUNC
86  */
87 HWTEST_F(InputWindowMonitorTest, UpdateDisplayInfo01, Function | SmallTest | Level2)
88 {
89     std::vector<sptr<DisplayInfo>> displayInfos;
90     std::vector<MMI::DisplayInfo> displayInfoVector;
91     displayInfos.clear();
92     displayInfoVector.clear();
93     sptr<DisplayInfo> displayinfo = nullptr;
94     displayInfos.emplace_back(displayinfo);
95     input_monitor_->UpdateDisplayInfo(displayInfos, displayInfoVector);
96     ASSERT_EQ(0, displayInfoVector.size());
97 }
98 }
99 }
100 }
101