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_test.h"
18 #undef private
19
20 using namespace testing::ext;
21
22 namespace OHOS {
23 namespace DistributedHardware {
SetUpTestCase(void)24 void ScreenClientTest::SetUpTestCase(void) {}
25
TearDownTestCase(void)26 void ScreenClientTest::TearDownTestCase(void) {}
27
SetUp()28 void ScreenClientTest::SetUp() {}
29
TearDown()30 void ScreenClientTest::TearDown() {}
31
32 /**
33 * @tc.name: ShowWindow_001
34 * @tc.desc: Verify the ShowWindow function.
35 * @tc.type: FUNC
36 * @tc.require: Issue Number
37 */
38 HWTEST_F(ScreenClientTest, ShowWindow_001, TestSize.Level1)
39 {
40 int32_t windowId = 0;
41 int32_t actual = ScreenClient::GetInstance().ShowWindow(windowId);
42 EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, actual);
43 }
44
45 /**
46 * @tc.name: ShowWindow_002
47 * @tc.desc: Verify the ShowWindow function.
48 * @tc.type: FUNC
49 * @tc.require: Issue Number
50 */
51 HWTEST_F(ScreenClientTest, ShowWindow_002, TestSize.Level1)
52 {
53 std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
54 ScreenClient::GetInstance().windowId_ = 0;
55 int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty);
56 int32_t actual = ScreenClient::GetInstance().ShowWindow(windowId);
57 EXPECT_EQ(DH_SUCCESS, actual);
58 }
59
60 /**
61 * @tc.name: AddWindow_001
62 * @tc.desc: Verify the AddWindow function.
63 * @tc.type: FUNC
64 * @tc.require: Issue Number
65 */
66 HWTEST_F(ScreenClientTest, AddWindow_001, TestSize.Level1)
67 {
68 std::shared_ptr<WindowProperty> windowProperty = nullptr;
69 int32_t actual = ScreenClient::GetInstance().AddWindow(windowProperty);
70 EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_ADD_WINDOW_ERROR, actual);
71 }
72
73 /**
74 * @tc.name: AddWindow_002
75 * @tc.desc: Verify the AddWindow function.
76 * @tc.type: FUNC
77 * @tc.require: Issue Number
78 */
79 HWTEST_F(ScreenClientTest, AddWindow_002, TestSize.Level1)
80 {
81 std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
82 ScreenClient::GetInstance().windowId_ = 2;
83 int32_t actual = ScreenClient::GetInstance().AddWindow(windowProperty);
84 EXPECT_EQ(3, 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(ScreenClientTest, MoveWindow_001, TestSize.Level1)
94 {
95 int32_t windowId = 0;
96 int32_t startX = 0;
97 int32_t startY = 0;
98 int32_t actual = ScreenClient::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(ScreenClientTest, MoveWindow_002, TestSize.Level1)
109 {
110 int32_t windowId = 1;
111 int32_t startX = 0;
112 int32_t startY = 0;
113 int32_t actual = ScreenClient::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(ScreenClientTest, RemoveWindow_001, TestSize.Level1)
124 {
125 int32_t windowId = 0;
126 int32_t actual = ScreenClient::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(ScreenClientTest, RemoveWindow_002, TestSize.Level1)
137 {
138 int32_t windowId = 1;
139 int32_t actual = ScreenClient::GetInstance().RemoveWindow(windowId);
140 EXPECT_EQ(DH_SUCCESS, actual);
141 }
142
143 /**
144 * @tc.name: GetSurface_001
145 * @tc.desc: Verify the GetSurface function.
146 * @tc.type: FUNC
147 * @tc.require: Issue Number
148 */
149 HWTEST_F(ScreenClientTest, GetSurface_001, TestSize.Level1)
150 {
151 int32_t windowId = 0;
152 sptr<Surface> actualSurface = ScreenClient::GetInstance().GetSurface(windowId);
153 EXPECT_EQ(nullptr, actualSurface);
154 }
155
156 /**
157 * @tc.name: GetSurface_002
158 * @tc.desc: Verify the GetSurface function.
159 * @tc.type: FUNC
160 * @tc.require: Issue Number
161 */
162 HWTEST_F(ScreenClientTest, GetSurface_002, TestSize.Level1)
163 {
164 std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
165 ScreenClient::GetInstance().windowId_ = 0;
166 int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty);
167 sptr<Surface> actualSurface = ScreenClient::GetInstance().GetSurface(windowId);
168 EXPECT_NE(nullptr, actualSurface);
169 }
170 }
171 }