1e0dac50fSopenharmony_ci/*
2e0dac50fSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
3e0dac50fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e0dac50fSopenharmony_ci * you may not use this file except in compliance with the License.
5e0dac50fSopenharmony_ci * You may obtain a copy of the License at
6e0dac50fSopenharmony_ci *
7e0dac50fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e0dac50fSopenharmony_ci *
9e0dac50fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e0dac50fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e0dac50fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e0dac50fSopenharmony_ci * See the License for the specific language governing permissions and
13e0dac50fSopenharmony_ci * limitations under the License.
14e0dac50fSopenharmony_ci */
15e0dac50fSopenharmony_ci
16e0dac50fSopenharmony_ci// gtest
17e0dac50fSopenharmony_ci#include <gtest/gtest.h>
18e0dac50fSopenharmony_ci#include "window_test_utils.h"
19e0dac50fSopenharmony_ci
20e0dac50fSopenharmony_ci#include "display_manager.h"
21e0dac50fSopenharmony_ci#include "display_manager_proxy.h"
22e0dac50fSopenharmony_ci#include "future.h"
23e0dac50fSopenharmony_ci#include "screen_manager.h"
24e0dac50fSopenharmony_ci#include "window_manager.h"
25e0dac50fSopenharmony_ci#include "window_accessibility_controller.h"
26e0dac50fSopenharmony_ci#include "window_impl.h"
27e0dac50fSopenharmony_ci#include "wm_common.h"
28e0dac50fSopenharmony_ci
29e0dac50fSopenharmony_ciusing namespace testing;
30e0dac50fSopenharmony_ciusing namespace testing::ext;
31e0dac50fSopenharmony_ci
32e0dac50fSopenharmony_cinamespace OHOS {
33e0dac50fSopenharmony_cinamespace Rosen {
34e0dac50fSopenharmony_ciusing Utils = WindowTestUtils;
35e0dac50fSopenharmony_ciclass DisplayListener : public DisplayManager::IDisplayListener {
36e0dac50fSopenharmony_cipublic:
37e0dac50fSopenharmony_ci    virtual void OnCreate(DisplayId) override;
38e0dac50fSopenharmony_ci    virtual void OnDestroy(DisplayId) override;
39e0dac50fSopenharmony_ci    virtual void OnChange(DisplayId) override;
40e0dac50fSopenharmony_ci    RunnableFuture<DisplayId> changeFuture_;
41e0dac50fSopenharmony_ci};
42e0dac50fSopenharmony_ci
43e0dac50fSopenharmony_ciclass ScreenListener : public ScreenManager::IScreenListener {
44e0dac50fSopenharmony_cipublic:
45e0dac50fSopenharmony_ci    virtual void OnConnect(ScreenId) override;
46e0dac50fSopenharmony_ci    virtual void OnDisconnect(ScreenId) override;
47e0dac50fSopenharmony_ci    virtual void OnChange(ScreenId) override;
48e0dac50fSopenharmony_ci    RunnableFuture<ScreenId> changeFuture_;
49e0dac50fSopenharmony_ci};
50e0dac50fSopenharmony_ci
51e0dac50fSopenharmony_ciclass WindowRotationTest : public testing::Test {
52e0dac50fSopenharmony_cipublic:
53e0dac50fSopenharmony_ci    static void SetUpTestCase();
54e0dac50fSopenharmony_ci    static void TearDownTestCase();
55e0dac50fSopenharmony_ci    virtual void SetUp() override;
56e0dac50fSopenharmony_ci    virtual void TearDown() override;
57e0dac50fSopenharmony_ci    std::vector<sptr<Window>> activeWindows_;
58e0dac50fSopenharmony_ci    Utils::TestWindowInfo fullInfo_;
59e0dac50fSopenharmony_ci    sptr<DisplayListener> displayListener_;
60e0dac50fSopenharmony_ci    sptr<ScreenListener> screenListener_;
61e0dac50fSopenharmony_ciprivate:
62e0dac50fSopenharmony_ci    static constexpr uint32_t SPLIT_TEST_SLEEP_S = 1;
63e0dac50fSopenharmony_ci    static constexpr long FUTURE_GET_RESULT_TIMEOUT = 1000;
64e0dac50fSopenharmony_ci    static constexpr uint32_t WAIT_SYNC_IN_NS = 200000;
65e0dac50fSopenharmony_ci};
66e0dac50fSopenharmony_ci
67e0dac50fSopenharmony_civoid DisplayListener::OnCreate(DisplayId displayId)
68e0dac50fSopenharmony_ci{
69e0dac50fSopenharmony_ci}
70e0dac50fSopenharmony_ci
71e0dac50fSopenharmony_civoid DisplayListener::OnDestroy(DisplayId displayId)
72e0dac50fSopenharmony_ci{
73e0dac50fSopenharmony_ci}
74e0dac50fSopenharmony_ci
75e0dac50fSopenharmony_civoid DisplayListener::OnChange(DisplayId displayId)
76e0dac50fSopenharmony_ci{
77e0dac50fSopenharmony_ci    changeFuture_.SetValue(displayId);
78e0dac50fSopenharmony_ci}
79e0dac50fSopenharmony_ci
80e0dac50fSopenharmony_civoid ScreenListener::OnConnect(ScreenId screenId)
81e0dac50fSopenharmony_ci{
82e0dac50fSopenharmony_ci}
83e0dac50fSopenharmony_ci
84e0dac50fSopenharmony_civoid ScreenListener::OnDisconnect(ScreenId screenId)
85e0dac50fSopenharmony_ci{
86e0dac50fSopenharmony_ci}
87e0dac50fSopenharmony_ci
88e0dac50fSopenharmony_civoid ScreenListener::OnChange(ScreenId screenId)
89e0dac50fSopenharmony_ci{
90e0dac50fSopenharmony_ci    changeFuture_.SetValue(screenId);
91e0dac50fSopenharmony_ci}
92e0dac50fSopenharmony_ci
93e0dac50fSopenharmony_civoid WindowRotationTest::SetUpTestCase()
94e0dac50fSopenharmony_ci{
95e0dac50fSopenharmony_ci}
96e0dac50fSopenharmony_ci
97e0dac50fSopenharmony_civoid WindowRotationTest::TearDownTestCase()
98e0dac50fSopenharmony_ci{
99e0dac50fSopenharmony_ci}
100e0dac50fSopenharmony_ci
101e0dac50fSopenharmony_civoid WindowRotationTest::SetUp()
102e0dac50fSopenharmony_ci{
103e0dac50fSopenharmony_ci    fullInfo_ = {
104e0dac50fSopenharmony_ci            .name = "",
105e0dac50fSopenharmony_ci            .rect = Utils::customAppRect_,
106e0dac50fSopenharmony_ci            .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
107e0dac50fSopenharmony_ci            .mode = WindowMode::WINDOW_MODE_FULLSCREEN,
108e0dac50fSopenharmony_ci            .needAvoid = true,
109e0dac50fSopenharmony_ci            .parentLimit = false,
110e0dac50fSopenharmony_ci            .showWhenLocked = true,
111e0dac50fSopenharmony_ci            .parentId = INVALID_WINDOW_ID,
112e0dac50fSopenharmony_ci    };
113e0dac50fSopenharmony_ci
114e0dac50fSopenharmony_ci    activeWindows_.clear();
115e0dac50fSopenharmony_ci    displayListener_ = new DisplayListener();
116e0dac50fSopenharmony_ci    DisplayManager::GetInstance().RegisterDisplayListener(displayListener_);
117e0dac50fSopenharmony_ci    screenListener_ = new ScreenListener();
118e0dac50fSopenharmony_ci    ScreenManager::GetInstance().RegisterScreenListener(screenListener_);
119e0dac50fSopenharmony_ci}
120e0dac50fSopenharmony_ci
121e0dac50fSopenharmony_civoid WindowRotationTest::TearDown()
122e0dac50fSopenharmony_ci{
123e0dac50fSopenharmony_ci    while (!activeWindows_.empty()) {
124e0dac50fSopenharmony_ci        ASSERT_EQ(WMError::WM_OK, activeWindows_.back()->Destroy());
125e0dac50fSopenharmony_ci        activeWindows_.pop_back();
126e0dac50fSopenharmony_ci    }
127e0dac50fSopenharmony_ci    DisplayManager::GetInstance().UnregisterDisplayListener(displayListener_);
128e0dac50fSopenharmony_ci    ScreenManager::GetInstance().UnregisterScreenListener(screenListener_);
129e0dac50fSopenharmony_ci    usleep(WAIT_SYNC_IN_NS);
130e0dac50fSopenharmony_ci}
131e0dac50fSopenharmony_ci
132e0dac50fSopenharmony_cinamespace {
133e0dac50fSopenharmony_ci/**
134e0dac50fSopenharmony_ci* @tc.name: WindowRotationTest1
135e0dac50fSopenharmony_ci* @tc.desc: create window and SetRequestedOrientation.
136e0dac50fSopenharmony_ci* @tc.type: FUNC
137e0dac50fSopenharmony_ci*/
138e0dac50fSopenharmony_ciHWTEST_F(WindowRotationTest, WindowRotationTest1, Function | MediumTest | Level3)
139e0dac50fSopenharmony_ci{
140e0dac50fSopenharmony_ci    fullInfo_.name  = "fullscreen.1";
141e0dac50fSopenharmony_ci    fullInfo_.orientation_ = Orientation::UNSPECIFIED;
142e0dac50fSopenharmony_ci    const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
143e0dac50fSopenharmony_ci    if (fullWindow == nullptr) {
144e0dac50fSopenharmony_ci        return;
145e0dac50fSopenharmony_ci    }
146e0dac50fSopenharmony_ci    activeWindows_.push_back(fullWindow);
147e0dac50fSopenharmony_ci    ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
148e0dac50fSopenharmony_ci    ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode());
149e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
150e0dac50fSopenharmony_ci
151e0dac50fSopenharmony_ci    fullWindow->SetRequestedOrientation(Orientation::REVERSE_HORIZONTAL);
152e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
153e0dac50fSopenharmony_ci    ASSERT_EQ(Orientation::REVERSE_HORIZONTAL, fullWindow->GetRequestedOrientation());
154e0dac50fSopenharmony_ci    DisplayId displayId = displayListener_->changeFuture_.GetResult(FUTURE_GET_RESULT_TIMEOUT);
155e0dac50fSopenharmony_ci    displayListener_->changeFuture_.Reset(-1);
156e0dac50fSopenharmony_ci    ScreenId screenId = screenListener_->changeFuture_.GetResult(FUTURE_GET_RESULT_TIMEOUT);
157e0dac50fSopenharmony_ci    screenListener_->changeFuture_.Reset(-1);
158e0dac50fSopenharmony_ci    auto screen = ScreenManager::GetInstance().GetScreenById(screenId);
159e0dac50fSopenharmony_ci    auto display = DisplayManager::GetInstance().GetDisplayById(displayId);
160e0dac50fSopenharmony_ci    ASSERT_EQ(Orientation::REVERSE_HORIZONTAL, screen->GetOrientation());
161e0dac50fSopenharmony_ci    ASSERT_EQ(Orientation::REVERSE_HORIZONTAL, display->GetOrientation());
162e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
163e0dac50fSopenharmony_ci
164e0dac50fSopenharmony_ci    ASSERT_EQ(WMError::WM_OK, fullWindow->Hide());
165e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
166e0dac50fSopenharmony_ci    ASSERT_EQ(Rotation::ROTATION_0, screen->GetRotation());
167e0dac50fSopenharmony_ci}
168e0dac50fSopenharmony_ci
169e0dac50fSopenharmony_ci/**
170e0dac50fSopenharmony_ci* @tc.name: WindowRotationTest2
171e0dac50fSopenharmony_ci* @tc.desc: create window with orientation property.
172e0dac50fSopenharmony_ci* @tc.type: FUNC
173e0dac50fSopenharmony_ci*/
174e0dac50fSopenharmony_ciHWTEST_F(WindowRotationTest, WindowRotationTest2, Function | MediumTest | Level3)
175e0dac50fSopenharmony_ci{
176e0dac50fSopenharmony_ci    fullInfo_.name  = "fullscreen.2";
177e0dac50fSopenharmony_ci    fullInfo_.orientation_ = Orientation::REVERSE_HORIZONTAL;
178e0dac50fSopenharmony_ci    const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
179e0dac50fSopenharmony_ci    if (fullWindow == nullptr) {
180e0dac50fSopenharmony_ci        return;
181e0dac50fSopenharmony_ci    }
182e0dac50fSopenharmony_ci    activeWindows_.push_back(fullWindow);
183e0dac50fSopenharmony_ci
184e0dac50fSopenharmony_ci    ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
185e0dac50fSopenharmony_ci    ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode());
186e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
187e0dac50fSopenharmony_ci
188e0dac50fSopenharmony_ci    ASSERT_EQ(Orientation::REVERSE_HORIZONTAL, fullWindow->GetRequestedOrientation());
189e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
190e0dac50fSopenharmony_ci    DisplayId displayId = displayListener_->changeFuture_.GetResult(FUTURE_GET_RESULT_TIMEOUT);
191e0dac50fSopenharmony_ci    ScreenId screenId = screenListener_->changeFuture_.GetResult(FUTURE_GET_RESULT_TIMEOUT);
192e0dac50fSopenharmony_ci    auto screen = ScreenManager::GetInstance().GetScreenById(screenId);
193e0dac50fSopenharmony_ci    auto display = DisplayManager::GetInstance().GetDisplayById(displayId);
194e0dac50fSopenharmony_ci    ASSERT_EQ(Orientation::REVERSE_HORIZONTAL, screen->GetOrientation());
195e0dac50fSopenharmony_ci    ASSERT_EQ(Orientation::REVERSE_HORIZONTAL, display->GetOrientation());
196e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
197e0dac50fSopenharmony_ci
198e0dac50fSopenharmony_ci    ASSERT_EQ(WMError::WM_OK, fullWindow->Hide());
199e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
200e0dac50fSopenharmony_ci    screen->SetOrientation(Orientation::UNSPECIFIED);
201e0dac50fSopenharmony_ci    displayListener_->changeFuture_.Reset(-1);
202e0dac50fSopenharmony_ci    screenListener_->changeFuture_.Reset(-1);
203e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
204e0dac50fSopenharmony_ci}
205e0dac50fSopenharmony_ci
206e0dac50fSopenharmony_ci/**
207e0dac50fSopenharmony_ci* @tc.name: WindowRotationTest3
208e0dac50fSopenharmony_ci* @tc.desc: create floating window with orientation property
209e0dac50fSopenharmony_ci* @tc.type: FUNC
210e0dac50fSopenharmony_ci*/
211e0dac50fSopenharmony_ciHWTEST_F(WindowRotationTest, WindowRotationTest3, Function | MediumTest | Level3)
212e0dac50fSopenharmony_ci{
213e0dac50fSopenharmony_ci    auto display = DisplayManager::GetInstance().GetDefaultDisplay();
214e0dac50fSopenharmony_ci    ASSERT_NE(display, nullptr);
215e0dac50fSopenharmony_ci    auto curDisplayOrientation = display->GetOrientation();
216e0dac50fSopenharmony_ci
217e0dac50fSopenharmony_ci    fullInfo_.name  = "fullscreen.3";
218e0dac50fSopenharmony_ci    fullInfo_.orientation_ = Orientation::REVERSE_HORIZONTAL;
219e0dac50fSopenharmony_ci    fullInfo_.mode = WindowMode::WINDOW_MODE_FLOATING;
220e0dac50fSopenharmony_ci    const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
221e0dac50fSopenharmony_ci    if (fullWindow == nullptr) {
222e0dac50fSopenharmony_ci        return;
223e0dac50fSopenharmony_ci    }
224e0dac50fSopenharmony_ci    activeWindows_.push_back(fullWindow);
225e0dac50fSopenharmony_ci    ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
226e0dac50fSopenharmony_ci    ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, fullWindow->GetMode());
227e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
228e0dac50fSopenharmony_ci
229e0dac50fSopenharmony_ci    ASSERT_EQ(Orientation::REVERSE_HORIZONTAL, fullWindow->GetRequestedOrientation());
230e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
231e0dac50fSopenharmony_ci    ASSERT_EQ(curDisplayOrientation, display->GetOrientation());
232e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
233e0dac50fSopenharmony_ci
234e0dac50fSopenharmony_ci    curDisplayOrientation = display->GetOrientation();
235e0dac50fSopenharmony_ci    ASSERT_EQ(WMError::WM_OK, fullWindow->Hide());
236e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
237e0dac50fSopenharmony_ci    ASSERT_EQ(curDisplayOrientation, display->GetOrientation());
238e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
239e0dac50fSopenharmony_ci}
240e0dac50fSopenharmony_ci
241e0dac50fSopenharmony_ci
242e0dac50fSopenharmony_ci/**
243e0dac50fSopenharmony_ci* @tc.name: WindowRotationTest4
244e0dac50fSopenharmony_ci* @tc.desc: create window with orientation after setting screen default orientation.
245e0dac50fSopenharmony_ci* @tc.type: FUNC
246e0dac50fSopenharmony_ci*/
247e0dac50fSopenharmony_ciHWTEST_F(WindowRotationTest, WindowRotationTest4, Function | MediumTest | Level3)
248e0dac50fSopenharmony_ci{
249e0dac50fSopenharmony_ci    auto displayDefault = DisplayManager::GetInstance().GetDefaultDisplay();
250e0dac50fSopenharmony_ci    ASSERT_NE(displayDefault, nullptr);
251e0dac50fSopenharmony_ci    ScreenId defaultScreenId = displayDefault->GetScreenId();
252e0dac50fSopenharmony_ci    auto defaultScreen = ScreenManager::GetInstance().GetScreenById(defaultScreenId);
253e0dac50fSopenharmony_ci    defaultScreen->SetOrientation(Orientation::REVERSE_HORIZONTAL);
254e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
255e0dac50fSopenharmony_ci
256e0dac50fSopenharmony_ci    fullInfo_.name  = "fullscreen.4";
257e0dac50fSopenharmony_ci    fullInfo_.orientation_ = Orientation::HORIZONTAL;
258e0dac50fSopenharmony_ci    const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
259e0dac50fSopenharmony_ci    if (fullWindow == nullptr) {
260e0dac50fSopenharmony_ci        return;
261e0dac50fSopenharmony_ci    }
262e0dac50fSopenharmony_ci    activeWindows_.push_back(fullWindow);
263e0dac50fSopenharmony_ci    ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
264e0dac50fSopenharmony_ci    ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode());
265e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
266e0dac50fSopenharmony_ci
267e0dac50fSopenharmony_ci    ASSERT_EQ(Orientation::HORIZONTAL, fullWindow->GetRequestedOrientation());
268e0dac50fSopenharmony_ci    DisplayId displayId = displayListener_->changeFuture_.GetResult(FUTURE_GET_RESULT_TIMEOUT);
269e0dac50fSopenharmony_ci    displayListener_->changeFuture_.Reset(-1);
270e0dac50fSopenharmony_ci    ScreenId screenId = screenListener_->changeFuture_.GetResult(FUTURE_GET_RESULT_TIMEOUT);
271e0dac50fSopenharmony_ci    screenListener_->changeFuture_.Reset(-1);
272e0dac50fSopenharmony_ci    auto screen = ScreenManager::GetInstance().GetScreenById(screenId);
273e0dac50fSopenharmony_ci    auto display = DisplayManager::GetInstance().GetDisplayById(displayId);
274e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
275e0dac50fSopenharmony_ci    ASSERT_EQ(Orientation::HORIZONTAL, screen->GetOrientation());
276e0dac50fSopenharmony_ci    ASSERT_EQ(Orientation::HORIZONTAL, display->GetOrientation());
277e0dac50fSopenharmony_ci
278e0dac50fSopenharmony_ci    ASSERT_EQ(WMError::WM_OK, fullWindow->Hide());
279e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
280e0dac50fSopenharmony_ci    defaultScreen->SetOrientation(Orientation::UNSPECIFIED);
281e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
282e0dac50fSopenharmony_ci}
283e0dac50fSopenharmony_ci
284e0dac50fSopenharmony_ci/**
285e0dac50fSopenharmony_ci* @tc.name: WindowRotationTest5
286e0dac50fSopenharmony_ci* @tc.desc: create window with orientation after setting screen default orientation, and toggle shown state for all app
287e0dac50fSopenharmony_ci*           windows.
288e0dac50fSopenharmony_ci* @tc.type: FUNC
289e0dac50fSopenharmony_ci*/
290e0dac50fSopenharmony_ciHWTEST_F(WindowRotationTest, WindowRotationTest5, Function | MediumTest | Level3)
291e0dac50fSopenharmony_ci{
292e0dac50fSopenharmony_ci    auto displayDefault = DisplayManager::GetInstance().GetDefaultDisplay();
293e0dac50fSopenharmony_ci    ASSERT_NE(displayDefault, nullptr);
294e0dac50fSopenharmony_ci    ScreenId defaultScreenId = displayDefault->GetScreenId();
295e0dac50fSopenharmony_ci    auto defaultScreen = ScreenManager::GetInstance().GetScreenById(defaultScreenId);
296e0dac50fSopenharmony_ci    defaultScreen->SetOrientation(Orientation::REVERSE_HORIZONTAL);
297e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
298e0dac50fSopenharmony_ci
299e0dac50fSopenharmony_ci    fullInfo_.name  = "fullscreen.5";
300e0dac50fSopenharmony_ci    fullInfo_.orientation_ = Orientation::HORIZONTAL;
301e0dac50fSopenharmony_ci    const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
302e0dac50fSopenharmony_ci    if (fullWindow == nullptr) {
303e0dac50fSopenharmony_ci        return;
304e0dac50fSopenharmony_ci    }
305e0dac50fSopenharmony_ci    activeWindows_.push_back(fullWindow);
306e0dac50fSopenharmony_ci    ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
307e0dac50fSopenharmony_ci    ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode());
308e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
309e0dac50fSopenharmony_ci
310e0dac50fSopenharmony_ci    ASSERT_EQ(Orientation::HORIZONTAL, fullWindow->GetRequestedOrientation());
311e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
312e0dac50fSopenharmony_ci    DisplayId displayId = displayListener_->changeFuture_.GetResult(FUTURE_GET_RESULT_TIMEOUT);
313e0dac50fSopenharmony_ci    displayListener_->changeFuture_.Reset(-1);
314e0dac50fSopenharmony_ci    ScreenId screenId = screenListener_->changeFuture_.GetResult(FUTURE_GET_RESULT_TIMEOUT);
315e0dac50fSopenharmony_ci    screenListener_->changeFuture_.Reset(-1);
316e0dac50fSopenharmony_ci    auto screen = ScreenManager::GetInstance().GetScreenById(screenId);
317e0dac50fSopenharmony_ci    auto display = DisplayManager::GetInstance().GetDisplayById(displayId);
318e0dac50fSopenharmony_ci    ASSERT_EQ(Orientation::HORIZONTAL, display->GetOrientation());
319e0dac50fSopenharmony_ci
320e0dac50fSopenharmony_ci    WindowManager::GetInstance().ToggleShownStateForAllAppWindows();
321e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
322e0dac50fSopenharmony_ci    ASSERT_EQ(WMError::WM_OK, fullWindow->Hide());
323e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
324e0dac50fSopenharmony_ci
325e0dac50fSopenharmony_ci    WindowManager::GetInstance().ToggleShownStateForAllAppWindows();
326e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
327e0dac50fSopenharmony_ci
328e0dac50fSopenharmony_ci    ASSERT_EQ(WMError::WM_OK, fullWindow->Hide());
329e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
330e0dac50fSopenharmony_ci    defaultScreen->SetOrientation(Orientation::UNSPECIFIED);
331e0dac50fSopenharmony_ci    sleep(SPLIT_TEST_SLEEP_S);
332e0dac50fSopenharmony_ci}
333e0dac50fSopenharmony_ci}
334e0dac50fSopenharmony_ci} // namespace Rosen
335e0dac50fSopenharmony_ci} // namespace OHOS
336