• 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 "inner_window.h"
18 
19 using namespace testing;
20 using namespace testing::ext;
21 namespace OHOS {
22 namespace Rosen {
23 class WindowInnerWindowTest : public testing::Test {
24 public:
25     static void SetUpTestCase();
26     static void TearDownTestCase();
27     void SetUp() override;
28     void TearDown() override;
29     sptr<PlaceHolderWindow> holderWindow_;
30     sptr<PlaceholderWindowListener> windowListener_;
31     std::shared_ptr<IInputEventConsumer> inputEventConsumer_;
32     sptr<DividerWindow> dividerWindow_;
33 };
34 
SetUpTestCase()35 void WindowInnerWindowTest::SetUpTestCase()
36 {
37 }
38 
TearDownTestCase()39 void WindowInnerWindowTest::TearDownTestCase()
40 {
41 }
42 
SetUp()43 void WindowInnerWindowTest::SetUp()
44 {
45     holderWindow_ = new PlaceHolderWindow();
46     windowListener_ = new PlaceholderWindowListener();
47     inputEventConsumer_ = std::make_shared<PlaceholderInputEventConsumer> ();
48     dividerWindow_ = new DividerWindow();
49 }
50 
TearDown()51 void WindowInnerWindowTest::TearDown()
52 {
53 }
54 
55 namespace {
56 /**
57  * @tc.name: PlaceHolderWindow01
58  * @tc.desc: test PlaceHolderWindow create/destroy
59  * @tc.type: FUNC
60  */
61 HWTEST_F(WindowInnerWindowTest, CreatePlaceHolderWindow01, Function | SmallTest | Level2)
62 {
63     Rect rect = { 100, 100, 200, 200 };
64     holderWindow_->Create("test01", 0, rect, WindowMode::WINDOW_MODE_FULLSCREEN);
65     holderWindow_->Destroy();
66 
67     rect = { 100, 100, 200, 200 };
68     holderWindow_->Create("test02", 0, rect, WindowMode::WINDOW_MODE_FULLSCREEN);
69     holderWindow_->Create("test02", 0, rect, WindowMode::WINDOW_MODE_FULLSCREEN);
70     holderWindow_->Destroy();
71 
72     rect = { 100, 100, 200, 200 };
73     holderWindow_->Create("", 0, rect, WindowMode::WINDOW_MODE_FULLSCREEN);
74     holderWindow_->Destroy();
75 
76     rect = { 0, 0, 0, 0 };
77     holderWindow_->Create("test03", 0, rect, WindowMode::WINDOW_MODE_FULLSCREEN);
78     holderWindow_->Destroy();
79 
80     holderWindow_->Destroy();
81 
82     ASSERT_EQ(true, true);
83 }
84 
85 /**
86  * @tc.name: PlaceholderWindowListener01
87  * @tc.desc: test PlaceholderWindowListener OnTouchOutside/AfterUnfocused
88  * @tc.type: FUNC
89  */
90 HWTEST_F(WindowInnerWindowTest, PlaceholderWindowListener01, Function | SmallTest | Level2)
91 {
92     windowListener_->OnTouchOutside();
93     windowListener_->AfterUnfocused();
94 
95     ASSERT_EQ(true, true);
96 }
97 
98 /**
99  * @tc.name: PlaceholderInputEventConsumer01
100  * @tc.desc: test PlaceholderInputEventConsumer OnInputEvent
101  * @tc.type: FUNC
102  */
103 HWTEST_F(WindowInnerWindowTest, PlaceholderInputEventConsumer01, Function | SmallTest | Level2)
104 {
105     std::shared_ptr<MMI::KeyEvent> keyEvent = nullptr;
106     std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
107     std::shared_ptr<MMI::AxisEvent> axisEvent = nullptr;
108 
109     inputEventConsumer_->OnInputEvent(keyEvent);
110     inputEventConsumer_->OnInputEvent(pointerEvent);
111     inputEventConsumer_->OnInputEvent(axisEvent);
112 
113     ASSERT_EQ(true, true);
114 }
115 
116 /**
117  * @tc.name: DividerWindow01
118  * @tc.desc: test DividerWindow create/update/destroy
119  * @tc.type: FUNC
120  */
121 HWTEST_F(WindowInnerWindowTest, DividerWindow01, Function | SmallTest | Level2)
122 {
123     Rect rect = { 100, 100, 200, 200 };
124     dividerWindow_->Create("test04", 0, rect, WindowMode::WINDOW_MODE_FULLSCREEN);
125     dividerWindow_->Update(100, 100);
126     dividerWindow_->Destroy();
127 
128     dividerWindow_->Update(100, 100);
129     dividerWindow_->Destroy();
130 
131     ASSERT_EQ(true, true);
132 }
133 }
134 }
135 }
136