• 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 #define private public
17 #include "screen_client_window_adapter_test.h"
18 #undef private
19 
20 using namespace testing::ext;
21 
22 namespace OHOS {
23 namespace DistributedHardware {
SetUpTestCase(void)24 void ScreenClientWindowAdapterTest::SetUpTestCase(void) {}
25 
TearDownTestCase(void)26 void ScreenClientWindowAdapterTest::TearDownTestCase(void) {}
27 
SetUp()28 void ScreenClientWindowAdapterTest::SetUp() {}
29 
TearDown()30 void ScreenClientWindowAdapterTest::TearDown() {}
31 
32 /**
33  * @tc.name: CreateWindow_001
34  * @tc.desc: Verify the CreateWindow function.
35  * @tc.type: FUNC
36  * @tc.require: Issue Number
37  */
38 HWTEST_F(ScreenClientWindowAdapterTest, CreateWindow_001, TestSize.Level1)
39 {
40     std::shared_ptr<WindowProperty> windowProperty = nullptr;
41     int32_t windowId = 0;
42     sptr<Surface> actualSurface = ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId);
43     EXPECT_EQ(nullptr, actualSurface);
44 }
45 
46 /**
47  * @tc.name: CreateWindow_002
48  * @tc.desc: Verify the CreateWindow function.
49  * @tc.type: FUNC
50  * @tc.require: Issue Number
51  */
52 HWTEST_F(ScreenClientWindowAdapterTest, CreateWindow_002, TestSize.Level1)
53 {
54     std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
55     int32_t windowId = 2;
56     sptr<Surface> surface = nullptr;
57     sptr<Surface> actualSurface = ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId);
58     EXPECT_NE(surface, actualSurface);
59 }
60 
61 /**
62  * @tc.name: ShowWindow_001
63  * @tc.desc: Verify the ShowWindow function.
64  * @tc.type: FUNC
65  * @tc.require: Issue Number
66  */
67 HWTEST_F(ScreenClientWindowAdapterTest, ShowWindow_001, TestSize.Level1)
68 {
69     int32_t windowId = 0;
70     int32_t actual = ScreenClientWindowAdapter::GetInstance().ShowWindow(windowId);
71     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, actual);
72 }
73 
74 /**
75  * @tc.name: ShowWindow_002
76  * @tc.desc: Verify the ShowWindow function.
77  * @tc.type: FUNC
78  * @tc.require: Issue Number
79  */
80 HWTEST_F(ScreenClientWindowAdapterTest, ShowWindow_002, TestSize.Level1)
81 {
82     int32_t windowId = 1;
83     int32_t actual = ScreenClientWindowAdapter::GetInstance().ShowWindow(windowId);
84     EXPECT_EQ(DH_SUCCESS, actual);
85 }
86 
87 /**
88  * @tc.name: MoveWindow_001
89  * @tc.desc: Verify the MoveWindow function.
90  * @tc.type: FUNC
91  * @tc.require: Issue Number
92  */
93 HWTEST_F(ScreenClientWindowAdapterTest, MoveWindow_001, TestSize.Level1)
94 {
95     int32_t windowId = 0;
96     int32_t startX = 0;
97     int32_t startY = 0;
98     int32_t actual = ScreenClientWindowAdapter::GetInstance().MoveWindow(windowId, startX, startY);
99     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_MOVE_WINDOW_ERROR, actual);
100 }
101 
102 /**
103  * @tc.name: MoveWindow_002
104  * @tc.desc: Verify the MoveWindow function.
105  * @tc.type: FUNC
106  * @tc.require: Issue Number
107  */
108 HWTEST_F(ScreenClientWindowAdapterTest, MoveWindow_002, TestSize.Level1)
109 {
110     int32_t windowId = 1;
111     int32_t startX = 0;
112     int32_t startY = 0;
113     int32_t actual = ScreenClientWindowAdapter::GetInstance().MoveWindow(windowId, startX, startY);
114     EXPECT_EQ(DH_SUCCESS, actual);
115 }
116 
117 /**
118  * @tc.name: RemoveWindow_001
119  * @tc.desc: Verify the RemoveWindow function.
120  * @tc.type: FUNC
121  * @tc.require: Issue Number
122  */
123 HWTEST_F(ScreenClientWindowAdapterTest, RemoveWindow_001, TestSize.Level1)
124 {
125     int32_t windowId = 0;
126     int32_t actual = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId);
127     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, actual);
128 }
129 
130 /**
131  * @tc.name: RemoveWindow_002
132  * @tc.desc: Verify the RemoveWindow function.
133  * @tc.type: FUNC
134  * @tc.require: Issue Number
135  */
136 HWTEST_F(ScreenClientWindowAdapterTest, RemoveWindow_002, TestSize.Level1)
137 {
138     int32_t windowId = 1;
139     int32_t actual = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId);
140     EXPECT_EQ(DH_SUCCESS, actual);
141 }
142 }
143 }