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
18 #include "display_manager_adapter.h"
19 #include "display_manager_config.h"
20 #include "display_manager_service.h"
21 #include "display_manager_agent_default.h"
22 #include "common_test_utils.h"
23 #include "mock_rs_display_node.h"
24 #include "scene_board_judgement.h"
25
26
27 using namespace testing;
28 using namespace testing::ext;
29
30 namespace OHOS {
31 namespace Rosen {
32 class DisplayManagerServiceTest : public testing::Test {
33 public:
34 static void SetUpTestCase();
35 static void TearDownTestCase();
36 void SetUp() override;
37 void TearDown() override;
38
39 void SetAceessTokenPermission(const std::string processName);
40 static sptr<DisplayManagerService> dms_;
41 static constexpr DisplayId DEFAULT_DISPLAY = 0ULL;
42 static constexpr DisplayId DEFAULT_SCREEN = 0ULL;
43 };
44
45 sptr<DisplayManagerService> DisplayManagerServiceTest::dms_ = nullptr;
46
SetUpTestCase()47 void DisplayManagerServiceTest::SetUpTestCase()
48 {
49 dms_ = new DisplayManagerService();
50
51 dms_->abstractScreenController_->defaultRsScreenId_ = 0;
52 dms_->abstractScreenController_->screenIdManager_.rs2DmsScreenIdMap_.clear();
53 dms_->abstractScreenController_->screenIdManager_.rs2DmsScreenIdMap_ = {
54 {0, 0}
55 };
56 dms_->abstractScreenController_->screenIdManager_.dms2RsScreenIdMap_.clear();
57 dms_->abstractScreenController_->screenIdManager_.dms2RsScreenIdMap_ = {
58 {0, 0}
59 };
60 const char** perms = new const char *[1];
61 perms[0] = "ohos.permission.CAPTURE_SCREEN";
62 CommonTestUtils::SetAceessTokenPermission("DisplayManagerServiceTest", perms, 1);
63 }
64
TearDownTestCase()65 void DisplayManagerServiceTest::TearDownTestCase()
66 {
67 dms_ = nullptr;
68 }
69
SetUp()70 void DisplayManagerServiceTest::SetUp()
71 {
72 }
73
TearDown()74 void DisplayManagerServiceTest::TearDown()
75 {
76 }
77
78 class DisplayChangeListenerTest : public IDisplayChangeListener {
79 public:
OnDisplayStateChange(DisplayId defaultDisplayId,sptr<DisplayInfo> displayInfo,const std::map<DisplayId,sptr<DisplayInfo>> & displayInfoMap,DisplayStateChangeType type)80 void OnDisplayStateChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo,
81 const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type) override {};
OnScreenshot(DisplayId displayId)82 void OnScreenshot(DisplayId displayId) override {};
83 };
84
85 class WindowInfoQueriedListenerTest : public IWindowInfoQueriedListener {
86 public:
HasPrivateWindow(DisplayId id,bool & hasPrivateWindow)87 void HasPrivateWindow(DisplayId id, bool& hasPrivateWindow) override {};
88 };
89
90 namespace {
91 /**
92 * @tc.name: OnStart
93 * @tc.desc: DMS OnStart
94 * @tc.type: FUNC
95 */
96 HWTEST_F(DisplayManagerServiceTest, OnStart, Function | SmallTest | Level3)
97 {
98 dms_->OnStart();
99 bool result = dms_->Init();
100 EXPECT_TRUE(result);
101 }
102
103 /**
104 * @tc.name: Dump
105 * @tc.desc: DMS dump
106 * @tc.type: FUNC
107 */
108 HWTEST_F(DisplayManagerServiceTest, Dump, Function | SmallTest | Level3)
109 {
110 std::vector<std::u16string> args;
111 ASSERT_EQ(static_cast<int>(DMError::DM_ERROR_INVALID_PARAM), dms_->Dump(-1, args));
112 }
113
114 /**
115 * @tc.name: Config
116 * @tc.desc: DMS config
117 * @tc.type: FUNC
118 */
119 HWTEST_F(DisplayManagerServiceTest, Config, Function | SmallTest | Level3)
120 {
121 DisplayManagerConfig::intNumbersConfig_.clear();
122 DisplayManagerConfig::enableConfig_.clear();
123 DisplayManagerConfig::stringConfig_.clear();
124 dms_->ConfigureDisplayManagerService();
125
126 DisplayManagerConfig::intNumbersConfig_ = {
127 {"dpi", {320}},
128 {"defaultDeviceRotationOffset", {90}},
129 {"curvedScreenBoundary", {20, 30, 40, 50}},
130 {"buildInDefaultOrientation", {90}},
131 {"waterfallAreaCompressionSizeWhenHorzontal", {90}}
132 };
133 DisplayManagerConfig::enableConfig_ = {
134 {"isWaterfallDisplay", false},
135 {"isWaterfallAreaCompressionEnableWhenHorizontal", false}
136 };
137 DisplayManagerConfig::stringConfig_ = {
138 {"defaultDisplayCutoutPath", "/path"}
139 };
140
141 dms_->ConfigureDisplayManagerService();
142
143 ASSERT_NE(dms_->displayCutoutController_, nullptr);
144 ASSERT_FALSE(dms_->displayCutoutController_->isWaterfallDisplay_);
145 ASSERT_EQ(dms_->displayCutoutController_->curvedScreenBoundary_[0],
146 DisplayManagerConfig::intNumbersConfig_["curvedScreenBoundary"][0]);
147 }
148
149 /**
150 * @tc.name: DisplayChange
151 * @tc.desc: DMS display change
152 * @tc.type: FUNC
153 */
154 HWTEST_F(DisplayManagerServiceTest, DisplayChange, Function | SmallTest | Level3)
155 {
156 std::map<DisplayId, sptr<DisplayInfo>> displayInfoMap;
157 sptr<DisplayInfo> displayInfo = new DisplayInfo();
158
159 dms_->RegisterDisplayChangeListener(nullptr);
160 dms_->NotifyDisplayStateChange(0, nullptr, displayInfoMap, DisplayStateChangeType::SIZE_CHANGE);
161 dms_->NotifyScreenshot(0);
162
163 sptr<DisplayChangeListenerTest> displayChangeListener = new DisplayChangeListenerTest();
164 ASSERT_NE(nullptr, displayChangeListener);
165 dms_->RegisterDisplayChangeListener(displayChangeListener);
166 dms_->NotifyDisplayStateChange(0, displayInfo, displayInfoMap, DisplayStateChangeType::SIZE_CHANGE);
167 dms_->NotifyScreenshot(0);
168
169 dms_->NotifyDisplayEvent(DisplayEvent::UNLOCK);
170
171 std::vector<DisplayId> displayIds;
172 dms_->SetFreeze(displayIds, false);
173 }
174
175 /**
176 * @tc.name: HasPrivateWindow
177 * @tc.desc: DMS has private window
178 * @tc.type: FUNC
179 */
180 HWTEST_F(DisplayManagerServiceTest, HasPrivateWindow, Function | SmallTest | Level3)
181 {
182 bool hasPrivateWindow = false;
183 dms_->abstractDisplayController_->abstractDisplayMap_.clear();
184 dms_->abstractDisplayController_->abstractDisplayMap_ = {
185 {1, nullptr}
186 };
187 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->HasPrivateWindow(0, hasPrivateWindow));
188
189 dms_->RegisterWindowInfoQueriedListener(nullptr);
190 ASSERT_EQ(DMError::DM_ERROR_NULLPTR, dms_->HasPrivateWindow(1, hasPrivateWindow));
191
192 sptr<WindowInfoQueriedListenerTest> windowInfoQueriedListener = new WindowInfoQueriedListenerTest();
193 ASSERT_NE(nullptr, windowInfoQueriedListener);
194 dms_->RegisterWindowInfoQueriedListener(windowInfoQueriedListener);
195 ASSERT_EQ(DMError::DM_OK, dms_->HasPrivateWindow(1, hasPrivateWindow));
196 }
197
198 /**
199 * @tc.name: GetDisplayInfo
200 * @tc.desc: DMS get display info
201 * @tc.type: FUNC
202 */
203 HWTEST_F(DisplayManagerServiceTest, GetDisplayInfo, Function | SmallTest | Level2)
204 {
205 // build abstractDisplayController_ env
206 std::string name = "testDisplay";
207 sptr<SupportedScreenModes> info = new SupportedScreenModes();
208 sptr<AbstractScreen> absScreen = new AbstractScreen(dms_->abstractScreenController_, name, 0, 0);
209 sptr<AbstractDisplay> absDisplay = new AbstractDisplay(0, info, absScreen);
210
211 dms_->abstractDisplayController_->abstractDisplayMap_.clear();
212 ASSERT_EQ(nullptr, dms_->GetDefaultDisplayInfo());
213
214 dms_->abstractDisplayController_->abstractDisplayMap_ = {
215 {0, absDisplay}
216 };
217 ASSERT_EQ(absDisplay->name_, dms_->GetDefaultDisplayInfo()->name_);
218
219 ASSERT_EQ(nullptr, dms_->GetDisplayInfoById(1));
220 ASSERT_EQ(absDisplay->name_, dms_->GetDisplayInfoById(0)->name_);
221
222 ASSERT_EQ(nullptr, dms_->GetDisplayInfoByScreen(1));
223 ASSERT_EQ(absDisplay->name_, dms_->GetDisplayInfoByScreen(0)->name_);
224
225 absDisplay->screenId_ = 0;
226
227 ASSERT_EQ(SCREEN_ID_INVALID, dms_->GetScreenIdByDisplayId(1));
228 ASSERT_EQ(0, dms_->GetScreenIdByDisplayId(0));
229
230 ASSERT_EQ(nullptr, dms_->GetScreenInfoById(1));
231 ASSERT_EQ(nullptr, dms_->GetScreenInfoById(0));
232
233 ASSERT_EQ(nullptr, dms_->GetScreenGroupInfoById(1));
234 ASSERT_EQ(nullptr, dms_->GetScreenGroupInfoById(0));
235
236 ASSERT_EQ(SCREEN_ID_INVALID, dms_->GetScreenGroupIdByScreenId(1));
237 ASSERT_EQ(SCREEN_ID_INVALID, dms_->GetScreenGroupIdByScreenId(0));
238
239 dms_->GetAllDisplayIds();
240 std::vector<sptr<ScreenInfo>> screenInfos;
241 dms_->GetAllScreenInfos(screenInfos);
242
243 dms_->abstractDisplayController_->abstractDisplayMap_.clear();
244 }
245
246 /**
247 * @tc.name: VirtualScreen
248 * @tc.desc: DMS virtual screen
249 * @tc.type: FUNC
250 */
251 HWTEST_F(DisplayManagerServiceTest, VirtualScreen, Function | SmallTest | Level3)
252 {
253 VirtualScreenOption option;
254 ASSERT_EQ(-1, dms_->CreateVirtualScreen(option, nullptr));
255
256 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->SetVirtualScreenSurface(-1, nullptr));
257 ASSERT_EQ(DMError::DM_ERROR_RENDER_SERVICE_FAILED, dms_->SetVirtualScreenSurface(0, nullptr));
258
259 std::vector<ScreenId> screens;
260 dms_->RemoveVirtualScreenFromGroup(screens);
261
262 DMError result = dms_->DestroyVirtualScreen(10086);
263 EXPECT_EQ(result, DMError::DM_ERROR_INVALID_CALLING);
264 }
265
266 /**
267 * @tc.name: GetDisplaySnapshot
268 * @tc.desc: DMS get display snapshot
269 * @tc.type: FUNC
270 */
271 HWTEST_F(DisplayManagerServiceTest, GetDisplaySnapshot, Function | SmallTest | Level3)
272 {
273 DisplayId displayId = 10086;
274 DmErrorCode* errorCode = nullptr;
275 std::shared_ptr<Media::PixelMap> result = dms_->GetDisplaySnapshot(displayId, errorCode);
276 EXPECT_EQ(result, nullptr);
277 }
278
279 /**
280 * @tc.name: OrientationAndRotation
281 * @tc.desc: DMS set oritation and rotation
282 * @tc.type: FUNC
283 */
284 HWTEST_F(DisplayManagerServiceTest, OrientationAndRotation, Function | SmallTest | Level3)
285 {
286 Orientation orientation = Orientation::UNSPECIFIED;
287 ASSERT_TRUE(DMError::DM_OK != dms_->SetOrientation(0, orientation));
288 ASSERT_EQ(DMError::DM_ERROR_NULLPTR, dms_->SetOrientationFromWindow(0, orientation, true));
289 Rotation rotation = Rotation::ROTATION_0;
290 ASSERT_EQ(false, dms_->SetRotationFromWindow(0, rotation, true));
291 }
292
293 /**
294 * @tc.name: ScreenColor
295 * @tc.desc: DMS screen color
296 * @tc.type: FUNC
297 */
298 HWTEST_F(DisplayManagerServiceTest, ScreenColor, Function | SmallTest | Level3)
299 {
300 std::vector<ScreenColorGamut> colorGamuts;
301 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->GetScreenSupportedColorGamuts(SCREEN_ID_INVALID, colorGamuts));
302 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->GetScreenSupportedColorGamuts(0, colorGamuts));
303
304 ScreenColorGamut colorGamut = ScreenColorGamut::COLOR_GAMUT_SRGB;
305 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->GetScreenColorGamut(SCREEN_ID_INVALID, colorGamut));
306 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->GetScreenColorGamut(0, colorGamut));
307
308 colorGamut = ScreenColorGamut::COLOR_GAMUT_SRGB;
309 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->SetScreenColorGamut(SCREEN_ID_INVALID, colorGamut));
310 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->SetScreenColorGamut(0, colorGamut));
311
312 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->SetScreenColorGamut(SCREEN_ID_INVALID, 0));
313 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->SetScreenColorGamut(0, 0));
314
315 ScreenGamutMap gamutMap;
316 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->GetScreenGamutMap(SCREEN_ID_INVALID, gamutMap));
317 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->GetScreenGamutMap(0, gamutMap));
318
319 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->SetScreenGamutMap(SCREEN_ID_INVALID, gamutMap));
320 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->SetScreenGamutMap(0, gamutMap));
321
322 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->SetScreenColorTransform(SCREEN_ID_INVALID));
323 ASSERT_EQ(DMError::DM_ERROR_INVALID_PARAM, dms_->SetScreenColorTransform(0));
324 }
325
326 /**
327 * @tc.name: RegisterDisplayManagerAgent
328 * @tc.desc: DMS rigister display manager agent
329 * @tc.type: FUNC
330 */
331 HWTEST_F(DisplayManagerServiceTest, RegisterDisplayManagerAgent, Function | SmallTest | Level3)
332 {
333 sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
334 DisplayManagerAgentType type = DisplayManagerAgentType::DISPLAY_STATE_LISTENER;
335
336 ASSERT_EQ(DMError::DM_ERROR_NULLPTR, dms_->RegisterDisplayManagerAgent(nullptr, type));
337 ASSERT_EQ(DMError::DM_ERROR_NULLPTR, dms_->UnregisterDisplayManagerAgent(nullptr, type));
338
339 ASSERT_EQ(DMError::DM_ERROR_NULLPTR, dms_->UnregisterDisplayManagerAgent(displayManagerAgent, type));
340
341 ASSERT_EQ(DMError::DM_OK, dms_->RegisterDisplayManagerAgent(displayManagerAgent, type));
342 ASSERT_EQ(DMError::DM_OK, dms_->UnregisterDisplayManagerAgent(displayManagerAgent, type));
343 }
344
345 /**
346 * @tc.name: ScreenPower
347 * @tc.desc: DMS screen power
348 * @tc.type: FUNC
349 */
350 HWTEST_F(DisplayManagerServiceTest, ScreenPower, Function | SmallTest | Level3)
351 {
352 PowerStateChangeReason reason = PowerStateChangeReason::POWER_BUTTON;
353 ScreenPowerState state = ScreenPowerState::POWER_ON;
354 DisplayState displayState = DisplayState::ON;
355
356 ASSERT_EQ(false, dms_->WakeUpBegin(reason));
357 ASSERT_EQ(false, dms_->WakeUpEnd());
358
359 ASSERT_EQ(false, dms_->SuspendBegin(reason));
360 ASSERT_EQ(false, dms_->SuspendEnd());
361
362 ASSERT_EQ(false, dms_->SetScreenPowerForAll(state, reason));
363
364 ScreenId dmsScreenId = 2;
365 ScreenPowerState result = dms_->GetScreenPower(dmsScreenId);
366 EXPECT_EQ(result, ScreenPowerState::INVALID_STATE);
367
368 ASSERT_EQ(true, dms_->SetDisplayState(displayState));
369 ASSERT_EQ(DisplayState::ON, dms_->GetDisplayState(0));
370 }
371
372 /**
373 * @tc.name: RsDisplayNode
374 * @tc.desc: DMS rs display node
375 * @tc.type: FUNC
376 */
377 HWTEST_F(DisplayManagerServiceTest, RsDisplayNode, Function | SmallTest | Level3)
378 {
379 struct RSSurfaceNodeConfig config;
380 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Create(config);
381 dms_->UpdateRSTree(DISPLAY_ID_INVALID, DISPLAY_ID_INVALID, surfaceNode, true, false);
382 dms_->UpdateRSTree(0, 0, surfaceNode, true, false);
383 }
384
385 /**
386 * @tc.name: MirrorAndExpand
387 * @tc.desc: DMS mirror
388 * @tc.type: FUNC
389 */
390 HWTEST_F(DisplayManagerServiceTest, MirrorAndExpand, Function | SmallTest | Level3)
391 {
392 std::vector<ScreenId> mirrorScreenIds;
393 ScreenId screenGroupId1 = DISPLAY_ID_INVALID;
394 dms_->MakeMirror(DISPLAY_ID_INVALID, mirrorScreenIds, screenGroupId1);
395 ASSERT_EQ(SCREEN_ID_INVALID, screenGroupId1);
396 ASSERT_EQ(DMError::DM_OK, dms_->StopMirror(mirrorScreenIds));
397
398 std::vector<ScreenId> expandScreenIds;
399 std::vector<Point> startPoints;
400 ScreenId screenGroupId2 = DISPLAY_ID_INVALID;
401 dms_->MakeExpand(expandScreenIds, startPoints, screenGroupId2);
402 ASSERT_EQ(SCREEN_ID_INVALID, screenGroupId2);
403 ASSERT_EQ(DMError::DM_OK, dms_->StopExpand(expandScreenIds));
404 }
405
406 /**
407 * @tc.name: ScreenActiveMode
408 * @tc.desc: DMS mirror
409 * @tc.type: FUNC
410 */
411 HWTEST_F(DisplayManagerServiceTest, ScreenActiveMode, Function | SmallTest | Level3)
412 {
413 ASSERT_EQ(DMError::DM_ERROR_NULLPTR, dms_->SetScreenActiveMode(SCREEN_ID_INVALID, 0));
414 }
415
416 /**
417 * @tc.name: VirtualPixelRatio
418 * @tc.desc: DMS mirror
419 * @tc.type: FUNC
420 */
421 HWTEST_F(DisplayManagerServiceTest, VirtualPixelRatio, Function | SmallTest | Level3)
422 {
423 ASSERT_TRUE(DMError::DM_OK != dms_->SetVirtualPixelRatio(SCREEN_ID_INVALID, 0.f));
424 }
425
426 /**
427 * @tc.name: ScreenRotationLock
428 * @tc.desc: DMS mirror
429 * @tc.type: FUNC
430 */
431 HWTEST_F(DisplayManagerServiceTest, ScreenRotationLock, Function | SmallTest | Level3)
432 {
433 dms_->SetScreenRotationLocked(false);
434
435 bool isLocked = false;
436 dms_->IsScreenRotationLocked(isLocked);
437 ASSERT_EQ(false, isLocked);
438
439 ASSERT_NE(nullptr, dms_->GetCutoutInfo(10));
440 }
441
442 /**
443 * @tc.name: AddSurfaceNodeToDisplay | RemoveSurfaceNodeFromDisplay
444 * @tc.desc: add/remove surfaceNode to/from display
445 * @tc.type: FUNC
446 */
447 HWTEST_F(DisplayManagerServiceTest, AddAndRemoveSurfaceNode, Function | SmallTest | Level3)
448 {
449 sptr<DisplayManagerService> dms = new DisplayManagerService();
450 std::shared_ptr<RSSurfaceNode> surfaceNode = nullptr;
451 DMError result = dms_->RemoveSurfaceNodeFromDisplay(DEFAULT_DISPLAY, surfaceNode);
452 EXPECT_EQ(result, DMError::DM_ERROR_NULLPTR);
453
454 ASSERT_EQ(DMError::DM_ERROR_NULLPTR, dms->AddSurfaceNodeToDisplay(DEFAULT_DISPLAY, surfaceNode, true));
455 surfaceNode = std::make_shared<RSSurfaceNode>(RSSurfaceNodeConfig{}, true);
456 ASSERT_EQ(DMError::DM_ERROR_NULLPTR, dms->AddSurfaceNodeToDisplay(DEFAULT_DISPLAY, surfaceNode, true));
457 std::shared_ptr<RSDisplayNode> displayNode = std::make_shared<MockRSDisplayNode>(RSDisplayNodeConfig{});
458 sptr<SupportedScreenModes> info = new SupportedScreenModes;
459 sptr<AbstractScreen> absScreen =
460 new AbstractScreen(nullptr, "", INVALID_SCREEN_ID, INVALID_SCREEN_ID);
461 dms->abstractDisplayController_->abstractDisplayMap_[DEFAULT_DISPLAY] =
462 new AbstractDisplay(DEFAULT_DISPLAY, info, absScreen);
463 dms->abstractDisplayController_->abstractDisplayMap_[DEFAULT_DISPLAY]->screenId_ = DEFAULT_SCREEN;
464
465 dms->abstractScreenController_->dmsScreenMap_[DEFAULT_SCREEN] =
466 new AbstractScreen(dms->abstractScreenController_, "", INVALID_SCREEN_ID, INVALID_SCREEN_ID);
467 ASSERT_EQ(DMError::DM_ERROR_NULLPTR, dms->AddSurfaceNodeToDisplay(DEFAULT_DISPLAY, surfaceNode, true));
468 dms->abstractScreenController_->dmsScreenMap_[DEFAULT_SCREEN]->rsDisplayNode_ = displayNode;
469
470 EXPECT_CALL(*reinterpret_cast<MockRSDisplayNode*>(displayNode.get()), AddChild(_, _));
471 ASSERT_EQ(DMError::DM_OK, dms->AddSurfaceNodeToDisplay(DEFAULT_DISPLAY, surfaceNode, false));
472 EXPECT_CALL(*reinterpret_cast<MockRSDisplayNode*>(displayNode.get()), RemoveChild(_));
473 ASSERT_EQ(DMError::DM_OK, dms->RemoveSurfaceNodeFromDisplay(DEFAULT_DISPLAY, surfaceNode));
474
475 testing::Mock::AllowLeak(displayNode.get());
476 }
477
478 /**
479 * @tc.name: SetGravitySensorSubscriptionEnabled
480 * @tc.desc: DMS set gravity sensor subscription enabled
481 * @tc.type: FUNC
482 */
483 HWTEST_F(DisplayManagerServiceTest, SetGravitySensorSubscriptionEnabled, Function | SmallTest | Level3)
484 {
485 dms_->SetGravitySensorSubscriptionEnabled();
486 DMError result = dms_->DestroyVirtualScreen(10086);
487 EXPECT_EQ(result, DMError::DM_ERROR_INVALID_CALLING);
488 }
489
490 /**
491 * @tc.name: OnStop
492 * @tc.desc: DMS on stop
493 * @tc.type: FUNC
494 */
495 HWTEST_F(DisplayManagerServiceTest, OnStop, Function | SmallTest | Level3)
496 {
497 dms_->OnStop();
498 ASSERT_TRUE(true);
499 }
500 }
501 } // namespace Rosen
502 } // namespace OHOS
503