1e0dac50fSopenharmony_ci/* 2e0dac50fSopenharmony_ci * Copyright (c) 2021-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 "window_option.h" 18e0dac50fSopenharmony_ci#include <gtest/gtest.h> 19e0dac50fSopenharmony_ci#include "window_manager.h" 20e0dac50fSopenharmony_ci#include "window_test_utils.h" 21e0dac50fSopenharmony_ci#include "wm_common.h" 22e0dac50fSopenharmony_ci#include "window_session_impl.h" 23e0dac50fSopenharmony_ci#include "window_scene_session_impl.h" 24e0dac50fSopenharmony_ci#include "mock_session.h" 25e0dac50fSopenharmony_ci#include "js_window.h" 26e0dac50fSopenharmony_ci#include "js_window_utils.h" 27e0dac50fSopenharmony_ciusing namespace testing; 28e0dac50fSopenharmony_ciusing namespace testing::ext; 29e0dac50fSopenharmony_ci 30e0dac50fSopenharmony_cinamespace OHOS { 31e0dac50fSopenharmony_cinamespace Rosen { 32e0dac50fSopenharmony_cinamespace { 33e0dac50fSopenharmony_ci constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowImmersiveTest1"}; 34e0dac50fSopenharmony_ci 35e0dac50fSopenharmony_ci const Rect SYS_BAR_REGION_NULL = { 0, 0, 0, 0 }; 36e0dac50fSopenharmony_ci const SystemBarProperty SYS_BAR_PROP_DEFAULT; 37e0dac50fSopenharmony_ci const SystemBarProperty SYS_BAR_PROP_1(true, 0xE5111111, 0xE5222222); 38e0dac50fSopenharmony_ci const SystemBarProperty SYS_BAR_PROP_2(false, 0xE5222222, 0xE5333333); 39e0dac50fSopenharmony_ci const SystemBarProperty SYS_BAR_PROP_3(false, 0xE5333333, 0xE5444444); 40e0dac50fSopenharmony_ci const SystemBarProperty SYS_BAR_PROP_4(true, 0xE5444444, 0x66555555); 41e0dac50fSopenharmony_ci const SystemBarRegionTints TEST_PROPS_DEFAULT = { 42e0dac50fSopenharmony_ci { WindowType::WINDOW_TYPE_STATUS_BAR, SYS_BAR_PROP_DEFAULT, SYS_BAR_REGION_NULL }, 43e0dac50fSopenharmony_ci { WindowType::WINDOW_TYPE_NAVIGATION_BAR, SYS_BAR_PROP_DEFAULT, SYS_BAR_REGION_NULL }, 44e0dac50fSopenharmony_ci }; 45e0dac50fSopenharmony_ci const SystemBarRegionTints TEST_PROPS_1 = { 46e0dac50fSopenharmony_ci { WindowType::WINDOW_TYPE_STATUS_BAR, SYS_BAR_PROP_1, SYS_BAR_REGION_NULL }, 47e0dac50fSopenharmony_ci { WindowType::WINDOW_TYPE_NAVIGATION_BAR, SYS_BAR_PROP_2, SYS_BAR_REGION_NULL }, 48e0dac50fSopenharmony_ci }; 49e0dac50fSopenharmony_ci const SystemBarRegionTints TEST_PROPS_2 = { 50e0dac50fSopenharmony_ci { WindowType::WINDOW_TYPE_STATUS_BAR, SYS_BAR_PROP_1, SYS_BAR_REGION_NULL }, 51e0dac50fSopenharmony_ci { WindowType::WINDOW_TYPE_NAVIGATION_BAR, SYS_BAR_PROP_3, SYS_BAR_REGION_NULL }, 52e0dac50fSopenharmony_ci }; 53e0dac50fSopenharmony_ci 54e0dac50fSopenharmony_ci const Rect EMPTY_RECT = {0, 0, 0, 0}; 55e0dac50fSopenharmony_ci const float RATIO = 0.3; 56e0dac50fSopenharmony_ci} 57e0dac50fSopenharmony_ci 58e0dac50fSopenharmony_ciusing Utils = WindowTestUtils; 59e0dac50fSopenharmony_ciconst int WAIT_ASYNC_US = 100000; // 100000us 60e0dac50fSopenharmony_ci 61e0dac50fSopenharmony_ciclass TestSystemBarChangedListener : public ISystemBarChangedListener { 62e0dac50fSopenharmony_cipublic: 63e0dac50fSopenharmony_ci SystemBarRegionTints tints_ = TEST_PROPS_DEFAULT; 64e0dac50fSopenharmony_ci void OnSystemBarPropertyChange(DisplayId displayId, const SystemBarRegionTints& tints) override; 65e0dac50fSopenharmony_ci}; 66e0dac50fSopenharmony_ci 67e0dac50fSopenharmony_ciclass TestAvoidAreaChangedListener : public IAvoidAreaChangedListener { 68e0dac50fSopenharmony_cipublic: 69e0dac50fSopenharmony_ci AvoidArea avoidArea_; 70e0dac50fSopenharmony_ci void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) override; 71e0dac50fSopenharmony_ci}; 72e0dac50fSopenharmony_ci 73e0dac50fSopenharmony_ciclass WindowImmersiveTest1 : public testing::Test { 74e0dac50fSopenharmony_cipublic: 75e0dac50fSopenharmony_ci static void SetUpTestCase(); 76e0dac50fSopenharmony_ci void SetUp() override; 77e0dac50fSopenharmony_ci void TearDown() override; 78e0dac50fSopenharmony_ci void SetWindowSystemProps(const sptr<Window>& window, const SystemBarRegionTints& props); 79e0dac50fSopenharmony_ci bool SystemBarPropsEqualsTo(const SystemBarRegionTints& expect); 80e0dac50fSopenharmony_ci void DumpFailedInfo(const SystemBarRegionTints& expect); 81e0dac50fSopenharmony_ci void DumpFailedInfo(bool expectStatus, bool expectNav); 82e0dac50fSopenharmony_ci bool SystemBarEnableState(bool expectStatus, bool expectNav); 83e0dac50fSopenharmony_ci DisplayId displayId_ = 0; 84e0dac50fSopenharmony_ci std::vector<sptr<Window>> activeWindows_; 85e0dac50fSopenharmony_ci static vector<Rect> fullScreenExpecteds_; 86e0dac50fSopenharmony_ci static sptr<TestSystemBarChangedListener> testSystemBarChangedListener_; 87e0dac50fSopenharmony_ci static sptr<TestAvoidAreaChangedListener> testAvoidAreaChangedListener_; 88e0dac50fSopenharmony_ci Utils::TestWindowInfo fullScreenAppinfo_; 89e0dac50fSopenharmony_ci Utils::TestWindowInfo avoidBarInfo_; 90e0dac50fSopenharmony_ci uint32_t leftAvoidW_; 91e0dac50fSopenharmony_ci uint32_t leftAvoidH_; 92e0dac50fSopenharmony_ci uint32_t topAvoidW_; 93e0dac50fSopenharmony_ci uint32_t topAvoidH_; 94e0dac50fSopenharmony_ci sptr<Window> backgroundWindow_; 95e0dac50fSopenharmony_ci}; 96e0dac50fSopenharmony_ci 97e0dac50fSopenharmony_civector<Rect> WindowImmersiveTest1::fullScreenExpecteds_; 98e0dac50fSopenharmony_cisptr<TestSystemBarChangedListener> WindowImmersiveTest1::testSystemBarChangedListener_ = 99e0dac50fSopenharmony_ci new TestSystemBarChangedListener(); 100e0dac50fSopenharmony_cisptr<TestAvoidAreaChangedListener> WindowImmersiveTest1::testAvoidAreaChangedListener_ = 101e0dac50fSopenharmony_ci new TestAvoidAreaChangedListener(); 102e0dac50fSopenharmony_ci 103e0dac50fSopenharmony_civoid WindowImmersiveTest1::SetWindowSystemProps(const sptr<Window>& window, const SystemBarRegionTints& tints) 104e0dac50fSopenharmony_ci{ 105e0dac50fSopenharmony_ci for (auto tint : tints) { 106e0dac50fSopenharmony_ci window->SetSystemBarProperty(tint.type_, tint.prop_); 107e0dac50fSopenharmony_ci } 108e0dac50fSopenharmony_ci} 109e0dac50fSopenharmony_ci 110e0dac50fSopenharmony_civoid WindowImmersiveTest1::DumpFailedInfo(const SystemBarRegionTints& expect) 111e0dac50fSopenharmony_ci{ 112e0dac50fSopenharmony_ci auto act = testSystemBarChangedListener_->tints_; 113e0dac50fSopenharmony_ci WLOGI("WindowImmersiveTest1 Expected:"); 114e0dac50fSopenharmony_ci for (auto tint : expect) { 115e0dac50fSopenharmony_ci WLOGI("WindowType: %{public}4d, Enable: %{public}4d, Color: %{public}x | %{public}x", 116e0dac50fSopenharmony_ci static_cast<uint32_t>(tint.type_), tint.prop_.enable_, 117e0dac50fSopenharmony_ci tint.prop_.backgroundColor_, tint.prop_.contentColor_); 118e0dac50fSopenharmony_ci } 119e0dac50fSopenharmony_ci WLOGI("WindowImmersiveTest1 Act: "); 120e0dac50fSopenharmony_ci for (auto tint : act) { 121e0dac50fSopenharmony_ci WLOGI("WindowType: %{public}4d, Enable: %{public}4d, Color: %{public}x | %{public}x", 122e0dac50fSopenharmony_ci static_cast<uint32_t>(tint.type_), tint.prop_.enable_, 123e0dac50fSopenharmony_ci tint.prop_.backgroundColor_, tint.prop_.contentColor_); 124e0dac50fSopenharmony_ci } 125e0dac50fSopenharmony_ci} 126e0dac50fSopenharmony_ci 127e0dac50fSopenharmony_civoid WindowImmersiveTest1::DumpFailedInfo(bool expectStatus, bool expectNav) 128e0dac50fSopenharmony_ci{ 129e0dac50fSopenharmony_ci auto act = testSystemBarChangedListener_->tints_; 130e0dac50fSopenharmony_ci WLOGI("WindowImmersiveTest1 Expected:"); 131e0dac50fSopenharmony_ci WLOGI("expectStatus: %{public}4d, expectNav: %{public}4d", expectStatus, expectNav); 132e0dac50fSopenharmony_ci WLOGI("WindowImmersiveTest1 Act: "); 133e0dac50fSopenharmony_ci for (auto tint : act) { 134e0dac50fSopenharmony_ci WLOGI("WindowType: %{public}4d, Enable: %{public}4d, Color: %{public}x | %{public}x", 135e0dac50fSopenharmony_ci static_cast<uint32_t>(tint.type_), tint.prop_.enable_, 136e0dac50fSopenharmony_ci tint.prop_.backgroundColor_, tint.prop_.contentColor_); 137e0dac50fSopenharmony_ci } 138e0dac50fSopenharmony_ci} 139e0dac50fSopenharmony_ci 140e0dac50fSopenharmony_cibool WindowImmersiveTest1::SystemBarPropsEqualsTo(const SystemBarRegionTints& expect) 141e0dac50fSopenharmony_ci{ 142e0dac50fSopenharmony_ci usleep(WAIT_ASYNC_US); 143e0dac50fSopenharmony_ci auto act = testSystemBarChangedListener_->tints_; 144e0dac50fSopenharmony_ci if (act.size() != expect.size()) { 145e0dac50fSopenharmony_ci DumpFailedInfo(expect); 146e0dac50fSopenharmony_ci return false; 147e0dac50fSopenharmony_ci } 148e0dac50fSopenharmony_ci for (auto item : expect) { 149e0dac50fSopenharmony_ci bool check = false; 150e0dac50fSopenharmony_ci for (auto tint : act) { 151e0dac50fSopenharmony_ci if (item.prop_ == tint.prop_ && item.type_ == tint.type_) { 152e0dac50fSopenharmony_ci check = true; 153e0dac50fSopenharmony_ci break; 154e0dac50fSopenharmony_ci } 155e0dac50fSopenharmony_ci } 156e0dac50fSopenharmony_ci if (!check) { 157e0dac50fSopenharmony_ci DumpFailedInfo(expect); 158e0dac50fSopenharmony_ci return false; 159e0dac50fSopenharmony_ci } 160e0dac50fSopenharmony_ci check = false; 161e0dac50fSopenharmony_ci } 162e0dac50fSopenharmony_ci return true; 163e0dac50fSopenharmony_ci} 164e0dac50fSopenharmony_ci 165e0dac50fSopenharmony_cibool WindowImmersiveTest1::SystemBarEnableState(bool expectStatus, bool expectNav) 166e0dac50fSopenharmony_ci{ 167e0dac50fSopenharmony_ci usleep(WAIT_ASYNC_US); 168e0dac50fSopenharmony_ci auto act = testSystemBarChangedListener_->tints_; 169e0dac50fSopenharmony_ci bool check = false; 170e0dac50fSopenharmony_ci for (auto tint : act) { 171e0dac50fSopenharmony_ci if ((tint.type_ == WindowType::WINDOW_TYPE_STATUS_BAR && tint.prop_.enable_ == expectStatus) 172e0dac50fSopenharmony_ci || (tint.type_ == WindowType::WINDOW_TYPE_NAVIGATION_BAR && tint.prop_.enable_ == expectNav)) { 173e0dac50fSopenharmony_ci check = true; 174e0dac50fSopenharmony_ci } else { 175e0dac50fSopenharmony_ci check = false; 176e0dac50fSopenharmony_ci } 177e0dac50fSopenharmony_ci } 178e0dac50fSopenharmony_ci if (!check) { 179e0dac50fSopenharmony_ci DumpFailedInfo(expectStatus, expectNav); 180e0dac50fSopenharmony_ci } 181e0dac50fSopenharmony_ci return check; 182e0dac50fSopenharmony_ci} 183e0dac50fSopenharmony_ci 184e0dac50fSopenharmony_civoid TestSystemBarChangedListener::OnSystemBarPropertyChange(DisplayId displayId, const SystemBarRegionTints& tints) 185e0dac50fSopenharmony_ci{ 186e0dac50fSopenharmony_ci WLOGI("TestSystemBarChangedListener Display ID: %{public}" PRIu64"", displayId); 187e0dac50fSopenharmony_ci WLOGI("TestSystemBarChangedListener tints size: %{public}zu", tints.size()); 188e0dac50fSopenharmony_ci for (auto tint : tints) { 189e0dac50fSopenharmony_ci auto type = tint.type_; 190e0dac50fSopenharmony_ci for (uint32_t i = 0; i < tints_.size(); i++) { 191e0dac50fSopenharmony_ci if (tints_[i].type_ == type) { 192e0dac50fSopenharmony_ci tints_[i] = tint; 193e0dac50fSopenharmony_ci } 194e0dac50fSopenharmony_ci } 195e0dac50fSopenharmony_ci } 196e0dac50fSopenharmony_ci} 197e0dac50fSopenharmony_ci 198e0dac50fSopenharmony_civoid TestAvoidAreaChangedListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) 199e0dac50fSopenharmony_ci{ 200e0dac50fSopenharmony_ci avoidArea_ = avoidArea; 201e0dac50fSopenharmony_ci} 202e0dac50fSopenharmony_ci 203e0dac50fSopenharmony_civoid WindowImmersiveTest1::SetUpTestCase() 204e0dac50fSopenharmony_ci{ 205e0dac50fSopenharmony_ci auto display = DisplayManager::GetInstance().GetDisplayById(0); 206e0dac50fSopenharmony_ci ASSERT_TRUE((display != nullptr)); 207e0dac50fSopenharmony_ci WLOGI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", 208e0dac50fSopenharmony_ci display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate()); 209e0dac50fSopenharmony_ci Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; 210e0dac50fSopenharmony_ci Utils::InitByDisplayRect(displayRect); 211e0dac50fSopenharmony_ci} 212e0dac50fSopenharmony_ci 213e0dac50fSopenharmony_civoid WindowImmersiveTest1::SetUp() 214e0dac50fSopenharmony_ci{ 215e0dac50fSopenharmony_ci fullScreenAppinfo_ = { 216e0dac50fSopenharmony_ci .name = "main", 217e0dac50fSopenharmony_ci .rect = Utils::customAppRect_, 218e0dac50fSopenharmony_ci .type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, 219e0dac50fSopenharmony_ci .mode = WindowMode::WINDOW_MODE_FULLSCREEN, // immersive setting 220e0dac50fSopenharmony_ci .needAvoid = false, // immersive setting 221e0dac50fSopenharmony_ci .parentLimit = false, 222e0dac50fSopenharmony_ci .parentId = INVALID_WINDOW_ID, 223e0dac50fSopenharmony_ci }; 224e0dac50fSopenharmony_ci 225e0dac50fSopenharmony_ci avoidBarInfo_ = { 226e0dac50fSopenharmony_ci .name = "LeftAvoidTest", 227e0dac50fSopenharmony_ci .rect = EMPTY_RECT, 228e0dac50fSopenharmony_ci .type = WindowType::WINDOW_TYPE_STATUS_BAR, 229e0dac50fSopenharmony_ci .mode = WindowMode::WINDOW_MODE_FLOATING, 230e0dac50fSopenharmony_ci }; 231e0dac50fSopenharmony_ci // makesure left avoid win w < h 232e0dac50fSopenharmony_ci leftAvoidW_ = std::min(Utils::displayRect_.width_, static_cast<uint32_t>(Utils::displayRect_.height_ * RATIO)); 233e0dac50fSopenharmony_ci leftAvoidH_ = Utils::displayRect_.height_; 234e0dac50fSopenharmony_ci // makesure top avoid win h < w 235e0dac50fSopenharmony_ci topAvoidW_ = Utils::displayRect_.width_; 236e0dac50fSopenharmony_ci topAvoidH_ = std::min(Utils::displayRect_.height_, static_cast<uint32_t>(Utils::displayRect_.width_ * RATIO)); 237e0dac50fSopenharmony_ci 238e0dac50fSopenharmony_ci WindowManager::GetInstance().RegisterSystemBarChangedListener(testSystemBarChangedListener_); 239e0dac50fSopenharmony_ci activeWindows_.clear(); 240e0dac50fSopenharmony_ci sleep(1); 241e0dac50fSopenharmony_ci} 242e0dac50fSopenharmony_ci 243e0dac50fSopenharmony_civoid WindowImmersiveTest1::TearDown() 244e0dac50fSopenharmony_ci{ 245e0dac50fSopenharmony_ci while (!activeWindows_.empty()) { 246e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, activeWindows_.back()->Destroy()); 247e0dac50fSopenharmony_ci activeWindows_.pop_back(); 248e0dac50fSopenharmony_ci } 249e0dac50fSopenharmony_ci WindowManager::GetInstance().UnregisterSystemBarChangedListener(testSystemBarChangedListener_); 250e0dac50fSopenharmony_ci sleep(1); 251e0dac50fSopenharmony_ci} 252e0dac50fSopenharmony_ci 253e0dac50fSopenharmony_cinamespace { 254e0dac50fSopenharmony_ci 255e0dac50fSopenharmony_cistatic void UpdateSystemBarProperties(std::map<WindowType, SystemBarProperty>& systemBarProperties, 256e0dac50fSopenharmony_ci const std::map<WindowType, SystemBarPropertyFlag>& systemBarPropertyFlags, sptr<WindowSceneSessionImpl> windowToken) 257e0dac50fSopenharmony_ci{ 258e0dac50fSopenharmony_ci for (auto it : systemBarPropertyFlags) { 259e0dac50fSopenharmony_ci WindowType type = it.first; 260e0dac50fSopenharmony_ci SystemBarPropertyFlag flag = it.second; 261e0dac50fSopenharmony_ci auto property = windowToken->GetSystemBarPropertyByType(type); 262e0dac50fSopenharmony_ci if (flag.enableFlag == false) { 263e0dac50fSopenharmony_ci systemBarProperties[type].enable_ = property.enable_; 264e0dac50fSopenharmony_ci } 265e0dac50fSopenharmony_ci if (flag.backgroundColorFlag == false) { 266e0dac50fSopenharmony_ci systemBarProperties[type].backgroundColor_ = property.backgroundColor_; 267e0dac50fSopenharmony_ci } 268e0dac50fSopenharmony_ci if (flag.contentColorFlag == false) { 269e0dac50fSopenharmony_ci systemBarProperties[type].contentColor_ = property.contentColor_; 270e0dac50fSopenharmony_ci } 271e0dac50fSopenharmony_ci if (flag.enableAnimationFlag == false) { 272e0dac50fSopenharmony_ci systemBarProperties[type].enableAnimation_ = property.enableAnimation_; 273e0dac50fSopenharmony_ci } 274e0dac50fSopenharmony_ci if (flag.enableFlag == true) { 275e0dac50fSopenharmony_ci systemBarProperties[type].settingFlag_ = 276e0dac50fSopenharmony_ci static_cast<SystemBarSettingFlag>(static_cast<uint32_t>(property.settingFlag_) | 277e0dac50fSopenharmony_ci static_cast<uint32_t>(SystemBarSettingFlag::ENABLE_SETTING)); 278e0dac50fSopenharmony_ci } 279e0dac50fSopenharmony_ci if (flag.backgroundColorFlag == true || flag.contentColorFlag == true) { 280e0dac50fSopenharmony_ci systemBarProperties[type].settingFlag_ = 281e0dac50fSopenharmony_ci static_cast<SystemBarSettingFlag>(static_cast<uint32_t>(property.settingFlag_) | 282e0dac50fSopenharmony_ci static_cast<uint32_t>(SystemBarSettingFlag::COLOR_SETTING)); 283e0dac50fSopenharmony_ci } 284e0dac50fSopenharmony_ci } 285e0dac50fSopenharmony_ci return; 286e0dac50fSopenharmony_ci} 287e0dac50fSopenharmony_ci 288e0dac50fSopenharmony_cistatic WMError SetSystemBarPropertiesByFlags(std::map<WindowType, SystemBarPropertyFlag>& systemBarPropertyFlags, 289e0dac50fSopenharmony_ci std::map<WindowType, SystemBarProperty>& systemBarProperties, sptr<WindowSceneSessionImpl> windowToken) 290e0dac50fSopenharmony_ci{ 291e0dac50fSopenharmony_ci WMError ret = WMError::WM_OK; 292e0dac50fSopenharmony_ci WMError err = WMError::WM_OK; 293e0dac50fSopenharmony_ci 294e0dac50fSopenharmony_ci for (auto it : systemBarPropertyFlags) { 295e0dac50fSopenharmony_ci WindowType type = it.first; 296e0dac50fSopenharmony_ci SystemBarPropertyFlag flag = it.second; 297e0dac50fSopenharmony_ci if (flag.enableFlag || flag.backgroundColorFlag || flag.contentColorFlag || flag.enableAnimationFlag) { 298e0dac50fSopenharmony_ci err = windowToken->SetSystemBarProperty(type, systemBarProperties.at(type)); 299e0dac50fSopenharmony_ci if (err != WMError::WM_OK) { 300e0dac50fSopenharmony_ci TLOGE(WmsLogTag::WMS_IMMS, "SetSystemBarProperty failed, ret = %{public}d", err); 301e0dac50fSopenharmony_ci ret = err; 302e0dac50fSopenharmony_ci } 303e0dac50fSopenharmony_ci } 304e0dac50fSopenharmony_ci } 305e0dac50fSopenharmony_ci return ret; 306e0dac50fSopenharmony_ci} 307e0dac50fSopenharmony_ci 308e0dac50fSopenharmony_civoid GetSystemBarStatus(std::map<WindowType, SystemBarProperty>& systemBarProperties, 309e0dac50fSopenharmony_ci std::map<WindowType, SystemBarPropertyFlag>& systemBarPropertyFlags, WindowType type) 310e0dac50fSopenharmony_ci{ 311e0dac50fSopenharmony_ci systemBarProperties[WindowType::WINDOW_TYPE_STATUS_BAR].enable_ = false; 312e0dac50fSopenharmony_ci systemBarProperties[WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR].enable_ = false; 313e0dac50fSopenharmony_ci systemBarProperties[WindowType::WINDOW_TYPE_NAVIGATION_BAR].enable_ = false; 314e0dac50fSopenharmony_ci systemBarPropertyFlags[WindowType::WINDOW_TYPE_STATUS_BAR] = {true, true, true, true}; 315e0dac50fSopenharmony_ci systemBarPropertyFlags[WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR] = {true, true, true, true}; 316e0dac50fSopenharmony_ci systemBarPropertyFlags[WindowType::WINDOW_TYPE_NAVIGATION_BAR] = {true, true, true, true}; 317e0dac50fSopenharmony_ci 318e0dac50fSopenharmony_ci if (type == WindowType::WINDOW_TYPE_STATUS_BAR) { 319e0dac50fSopenharmony_ci systemBarProperties[WindowType::WINDOW_TYPE_STATUS_BAR].enable_ = true; 320e0dac50fSopenharmony_ci systemBarProperties[WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR].enable_ = true; 321e0dac50fSopenharmony_ci } else if (type == WindowType::WINDOW_TYPE_NAVIGATION_BAR) { 322e0dac50fSopenharmony_ci systemBarProperties[WindowType::WINDOW_TYPE_NAVIGATION_BAR].enable_ = true; 323e0dac50fSopenharmony_ci } 324e0dac50fSopenharmony_ci} 325e0dac50fSopenharmony_ci 326e0dac50fSopenharmony_civoid GetSystemBarStatus(std::map<WindowType, SystemBarProperty>& systemBarProperties, SystemBarProperty pro, 327e0dac50fSopenharmony_ci std::map<WindowType, SystemBarPropertyFlag>& systemBarPropertyFlags, WindowType type) 328e0dac50fSopenharmony_ci{ 329e0dac50fSopenharmony_ci systemBarPropertyFlags[WindowType::WINDOW_TYPE_STATUS_BAR] = {true, true, true, true}; 330e0dac50fSopenharmony_ci systemBarPropertyFlags[WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR] = {true, true, true, true}; 331e0dac50fSopenharmony_ci systemBarPropertyFlags[WindowType::WINDOW_TYPE_NAVIGATION_BAR] = {true, true, true, true}; 332e0dac50fSopenharmony_ci 333e0dac50fSopenharmony_ci if (type == WindowType::WINDOW_TYPE_STATUS_BAR) { 334e0dac50fSopenharmony_ci systemBarProperties[type] = pro; 335e0dac50fSopenharmony_ci systemBarProperties[WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR] = pro; 336e0dac50fSopenharmony_ci } else if (type == WindowType::WINDOW_TYPE_NAVIGATION_BAR) { 337e0dac50fSopenharmony_ci systemBarProperties[type] = pro; 338e0dac50fSopenharmony_ci } 339e0dac50fSopenharmony_ci} 340e0dac50fSopenharmony_ci 341e0dac50fSopenharmony_civoid GetSpecificBarStatus( 342e0dac50fSopenharmony_ci std::map<WindowType, SystemBarProperty>& systemBarProperties, 343e0dac50fSopenharmony_ci std::map<WindowType, SystemBarPropertyFlag>& systemBarPropertyFlags, 344e0dac50fSopenharmony_ci WindowType type) 345e0dac50fSopenharmony_ci{ 346e0dac50fSopenharmony_ci systemBarProperties[WindowType::WINDOW_TYPE_STATUS_BAR].enable_ = false; 347e0dac50fSopenharmony_ci systemBarProperties[WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR].enable_ = false; 348e0dac50fSopenharmony_ci systemBarProperties[WindowType::WINDOW_TYPE_NAVIGATION_BAR].enable_ = false; 349e0dac50fSopenharmony_ci systemBarPropertyFlags[WindowType::WINDOW_TYPE_STATUS_BAR] = {true, true, true, true}; 350e0dac50fSopenharmony_ci systemBarPropertyFlags[WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR] = {true, true, true, true}; 351e0dac50fSopenharmony_ci systemBarPropertyFlags[WindowType::WINDOW_TYPE_NAVIGATION_BAR] = {true, true, true, true}; 352e0dac50fSopenharmony_ci if (type == WindowType::WINDOW_TYPE_STATUS_BAR) { 353e0dac50fSopenharmony_ci systemBarProperties[WindowType::WINDOW_TYPE_STATUS_BAR].enable_ = true; 354e0dac50fSopenharmony_ci } else if (type == WindowType::WINDOW_TYPE_NAVIGATION_BAR) { 355e0dac50fSopenharmony_ci systemBarProperties[WindowType::WINDOW_TYPE_NAVIGATION_BAR].enable_ = true; 356e0dac50fSopenharmony_ci } else if (type == WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR) { 357e0dac50fSopenharmony_ci systemBarProperties[WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR].enable_ = true; 358e0dac50fSopenharmony_ci } 359e0dac50fSopenharmony_ci} 360e0dac50fSopenharmony_ci 361e0dac50fSopenharmony_ci/** 362e0dac50fSopenharmony_ci * @tc.name: SetFullScreen 363e0dac50fSopenharmony_ci * @tc.desc: SetFullScreen 364e0dac50fSopenharmony_ci * @tc.type: FUNC 365e0dac50fSopenharmony_ci */ 366e0dac50fSopenharmony_ciHWTEST_F(WindowImmersiveTest1, setFullScreen, Function | MediumTest | Level3) 367e0dac50fSopenharmony_ci{ 368e0dac50fSopenharmony_ci const vector<WindowMode>windowMode{WindowMode::WINDOW_MODE_FULLSCREEN, WindowMode::WINDOW_MODE_SPLIT_PRIMARY, 369e0dac50fSopenharmony_ci WindowMode::WINDOW_MODE_SPLIT_SECONDARY, WindowMode::WINDOW_MODE_FLOATING}; 370e0dac50fSopenharmony_ci 371e0dac50fSopenharmony_ci for (auto mode : windowMode) { 372e0dac50fSopenharmony_ci sptr<WindowOption> option = new (std::nothrow) WindowOption(); 373e0dac50fSopenharmony_ci ASSERT_NE(nullptr, option); 374e0dac50fSopenharmony_ci option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); 375e0dac50fSopenharmony_ci option->SetWindowMode(mode); 376e0dac50fSopenharmony_ci 377e0dac50fSopenharmony_ci sptr<WindowSceneSessionImpl> window = new WindowSceneSessionImpl(option); 378e0dac50fSopenharmony_ci EXPECT_FALSE(window == nullptr); 379e0dac50fSopenharmony_ci 380e0dac50fSopenharmony_ci SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; 381e0dac50fSopenharmony_ci sptr<SessionMocker> session = new(std::nothrow) SessionMocker(sessionInfo); 382e0dac50fSopenharmony_ci ASSERT_NE(nullptr, session); 383e0dac50fSopenharmony_ci window->property_->SetPersistentId(1); 384e0dac50fSopenharmony_ci window->hostSession_ = session; 385e0dac50fSopenharmony_ci window->state_ = WindowState::STATE_SHOWN; 386e0dac50fSopenharmony_ci activeWindows_.push_back(window); 387e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, window->SetFullScreen(true)); 388e0dac50fSopenharmony_ci 389e0dac50fSopenharmony_ci if (mode != WindowMode::WINDOW_MODE_FULLSCREEN) { 390e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN)); 391e0dac50fSopenharmony_ci } 392e0dac50fSopenharmony_ci EXPECT_EQ(true, window->IsFullScreen()); 393e0dac50fSopenharmony_ci 394e0dac50fSopenharmony_ci window->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); 395e0dac50fSopenharmony_ci 396e0dac50fSopenharmony_ci if (mode == WindowMode::WINDOW_MODE_FULLSCREEN) { 397e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, window->SetFullScreen(false)); 398e0dac50fSopenharmony_ci EXPECT_EQ(false, window->IsFullScreen()); 399e0dac50fSopenharmony_ci } else { 400e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, window->SetFullScreen(false)); 401e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN)); 402e0dac50fSopenharmony_ci EXPECT_EQ(false, window->IsFullScreen()); 403e0dac50fSopenharmony_ci } 404e0dac50fSopenharmony_ci 405e0dac50fSopenharmony_ci window->SetWindowType(WindowType::WINDOW_TYPE_DESKTOP); 406e0dac50fSopenharmony_ci window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); 407e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, window->SetFullScreen(false)); 408e0dac50fSopenharmony_ci EXPECT_EQ(false, window->IsFullScreen()); 409e0dac50fSopenharmony_ci } 410e0dac50fSopenharmony_ci} 411e0dac50fSopenharmony_ci 412e0dac50fSopenharmony_ci/** 413e0dac50fSopenharmony_ci * @tc.name: SetLayoutFullScreen 414e0dac50fSopenharmony_ci * @tc.desc: SetLayoutFullScreen 415e0dac50fSopenharmony_ci * @tc.type: FUNC 416e0dac50fSopenharmony_ci */ 417e0dac50fSopenharmony_ciHWTEST_F(WindowImmersiveTest1, setLayoutFullScreen, Function | MediumTest | Level3) 418e0dac50fSopenharmony_ci{ 419e0dac50fSopenharmony_ci const vector<WindowMode>windowMode{WindowMode::WINDOW_MODE_FULLSCREEN, WindowMode::WINDOW_MODE_SPLIT_PRIMARY, 420e0dac50fSopenharmony_ci WindowMode::WINDOW_MODE_SPLIT_SECONDARY, WindowMode::WINDOW_MODE_FLOATING}; 421e0dac50fSopenharmony_ci 422e0dac50fSopenharmony_ci for (auto mode : windowMode) { 423e0dac50fSopenharmony_ci sptr<WindowOption> option = new (std::nothrow) WindowOption(); 424e0dac50fSopenharmony_ci ASSERT_NE(nullptr, option); 425e0dac50fSopenharmony_ci option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); 426e0dac50fSopenharmony_ci option->SetWindowMode(mode); 427e0dac50fSopenharmony_ci 428e0dac50fSopenharmony_ci sptr<WindowSceneSessionImpl> window = new WindowSceneSessionImpl(option); 429e0dac50fSopenharmony_ci EXPECT_FALSE(window == nullptr); 430e0dac50fSopenharmony_ci 431e0dac50fSopenharmony_ci SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; 432e0dac50fSopenharmony_ci sptr<SessionMocker> session = new(std::nothrow) SessionMocker(sessionInfo); 433e0dac50fSopenharmony_ci ASSERT_NE(nullptr, session); 434e0dac50fSopenharmony_ci window->property_->SetPersistentId(1); 435e0dac50fSopenharmony_ci window->hostSession_ = session; 436e0dac50fSopenharmony_ci window->state_ = WindowState::STATE_SHOWN; 437e0dac50fSopenharmony_ci activeWindows_.push_back(window); 438e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(true)); 439e0dac50fSopenharmony_ci 440e0dac50fSopenharmony_ci if (mode != WindowMode::WINDOW_MODE_FULLSCREEN) { 441e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN)); 442e0dac50fSopenharmony_ci } 443e0dac50fSopenharmony_ci EXPECT_EQ(true, window->IsLayoutFullScreen()); 444e0dac50fSopenharmony_ci 445e0dac50fSopenharmony_ci window->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); 446e0dac50fSopenharmony_ci if (mode == WindowMode::WINDOW_MODE_FULLSCREEN) { 447e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(false)); 448e0dac50fSopenharmony_ci EXPECT_EQ(false, window->IsLayoutFullScreen()); 449e0dac50fSopenharmony_ci } else { 450e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(false)); 451e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN)); 452e0dac50fSopenharmony_ci EXPECT_EQ(false, window->IsLayoutFullScreen()); 453e0dac50fSopenharmony_ci } 454e0dac50fSopenharmony_ci 455e0dac50fSopenharmony_ci window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); 456e0dac50fSopenharmony_ci window->SetWindowType(WindowType::WINDOW_TYPE_DESKTOP); 457e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(false)); 458e0dac50fSopenharmony_ci EXPECT_EQ(false, window->IsLayoutFullScreen()); 459e0dac50fSopenharmony_ci } 460e0dac50fSopenharmony_ci} 461e0dac50fSopenharmony_ci 462e0dac50fSopenharmony_ci/** 463e0dac50fSopenharmony_ci * @tc.name: SetImmersiveModeEnabledState 464e0dac50fSopenharmony_ci * @tc.desc: SetImmersiveModeEnabledState 465e0dac50fSopenharmony_ci * @tc.type: FUNC 466e0dac50fSopenharmony_ci */ 467e0dac50fSopenharmony_ciHWTEST_F(WindowImmersiveTest1, setImmersiveModeEnabledState, Function | MediumTest | Level3) 468e0dac50fSopenharmony_ci{ 469e0dac50fSopenharmony_ci sptr<WindowOption> option = new (std::nothrow) WindowOption(); 470e0dac50fSopenharmony_ci ASSERT_NE(nullptr, option); 471e0dac50fSopenharmony_ci sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option); 472e0dac50fSopenharmony_ci ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->SetImmersiveModeEnabledState(false)); 473e0dac50fSopenharmony_ci 474e0dac50fSopenharmony_ci window->property_->SetPersistentId(1); 475e0dac50fSopenharmony_ci SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; 476e0dac50fSopenharmony_ci sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo); 477e0dac50fSopenharmony_ci ASSERT_NE(nullptr, session); 478e0dac50fSopenharmony_ci window->hostSession_ = session; 479e0dac50fSopenharmony_ci window->property_->SetWindowName("SetImmersiveModeEnabledState"); 480e0dac50fSopenharmony_ci window->property_->SetWindowType(WindowType::WINDOW_TYPE_PIP); 481e0dac50fSopenharmony_ci window->state_ = WindowState::STATE_CREATED; 482e0dac50fSopenharmony_ci ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetImmersiveModeEnabledState(false)); 483e0dac50fSopenharmony_ci 484e0dac50fSopenharmony_ci window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); 485e0dac50fSopenharmony_ci ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(true)); 486e0dac50fSopenharmony_ci ASSERT_EQ(true, window->GetImmersiveModeEnabledState()); 487e0dac50fSopenharmony_ci ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(false)); 488e0dac50fSopenharmony_ci ASSERT_EQ(false, window->GetImmersiveModeEnabledState()); 489e0dac50fSopenharmony_ci 490e0dac50fSopenharmony_ci window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); 491e0dac50fSopenharmony_ci ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(true)); 492e0dac50fSopenharmony_ci ASSERT_EQ(true, window->IsLayoutFullScreen()); 493e0dac50fSopenharmony_ci ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(false)); 494e0dac50fSopenharmony_ci ASSERT_EQ(false, window->IsLayoutFullScreen()); 495e0dac50fSopenharmony_ci ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(true)); 496e0dac50fSopenharmony_ci ASSERT_EQ(true, window->IsLayoutFullScreen()); 497e0dac50fSopenharmony_ci ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(false)); 498e0dac50fSopenharmony_ci ASSERT_EQ(false, window->IsLayoutFullScreen()); 499e0dac50fSopenharmony_ci 500e0dac50fSopenharmony_ci window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); 501e0dac50fSopenharmony_ci ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(true)); 502e0dac50fSopenharmony_ci ASSERT_EQ(true, window->IsLayoutFullScreen()); 503e0dac50fSopenharmony_ci ASSERT_EQ(true, window->GetImmersiveModeEnabledState()); 504e0dac50fSopenharmony_ci 505e0dac50fSopenharmony_ci window->property_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); 506e0dac50fSopenharmony_ci ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(true)); 507e0dac50fSopenharmony_ci ASSERT_EQ(true, window->IsLayoutFullScreen()); 508e0dac50fSopenharmony_ci ASSERT_EQ(true, window->GetImmersiveModeEnabledState()); 509e0dac50fSopenharmony_ci 510e0dac50fSopenharmony_ci window->property_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); 511e0dac50fSopenharmony_ci ASSERT_EQ(WMError::WM_OK, window->SetImmersiveModeEnabledState(true)); 512e0dac50fSopenharmony_ci ASSERT_EQ(true, window->IsLayoutFullScreen()); 513e0dac50fSopenharmony_ci ASSERT_EQ(true, window->GetImmersiveModeEnabledState()); 514e0dac50fSopenharmony_ci ASSERT_EQ(true, window->IsLayoutFullScreen()); 515e0dac50fSopenharmony_ci 516e0dac50fSopenharmony_ci window->property_->SetWindowType(WindowType::WINDOW_TYPE_DESKTOP); 517e0dac50fSopenharmony_ci window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); 518e0dac50fSopenharmony_ci ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetImmersiveModeEnabledState(true)); 519e0dac50fSopenharmony_ci ASSERT_EQ(true, window->GetImmersiveModeEnabledState()); 520e0dac50fSopenharmony_ci ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetImmersiveModeEnabledState(false)); 521e0dac50fSopenharmony_ci ASSERT_EQ(true, window->GetImmersiveModeEnabledState()); 522e0dac50fSopenharmony_ci} 523e0dac50fSopenharmony_ci 524e0dac50fSopenharmony_ci/** 525e0dac50fSopenharmony_ci * @tc.name: SetWindowSystemBarEnable_1 526e0dac50fSopenharmony_ci * @tc.desc: SetWindowSystemBarEnable_1 WINDOW_TYPE_APP_MAIN_WINDOW 527e0dac50fSopenharmony_ci * @tc.type: FUNC 528e0dac50fSopenharmony_ci */ 529e0dac50fSopenharmony_ciHWTEST_F(WindowImmersiveTest1, setWindowSystemBarEnable_1, Function | MediumTest | Level3) 530e0dac50fSopenharmony_ci{ 531e0dac50fSopenharmony_ci const vector<WindowMode>windowMode{WindowMode::WINDOW_MODE_FULLSCREEN, WindowMode::WINDOW_MODE_SPLIT_PRIMARY, 532e0dac50fSopenharmony_ci WindowMode::WINDOW_MODE_SPLIT_SECONDARY, WindowMode::WINDOW_MODE_FLOATING}; 533e0dac50fSopenharmony_ci const vector<WindowType>windowType{WindowType::WINDOW_TYPE_STATUS_BAR, WindowType::WINDOW_TYPE_NAVIGATION_BAR}; 534e0dac50fSopenharmony_ci for (auto type : windowType) { 535e0dac50fSopenharmony_ci for (auto mode : windowMode) { 536e0dac50fSopenharmony_ci sptr<WindowOption> option = new (std::nothrow) WindowOption(); 537e0dac50fSopenharmony_ci ASSERT_NE(nullptr, option); 538e0dac50fSopenharmony_ci option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); 539e0dac50fSopenharmony_ci option->SetWindowMode(mode); 540e0dac50fSopenharmony_ci sptr<WindowSceneSessionImpl> window = new WindowSceneSessionImpl(option); 541e0dac50fSopenharmony_ci EXPECT_FALSE(window == nullptr); 542e0dac50fSopenharmony_ci SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; 543e0dac50fSopenharmony_ci sptr<SessionMocker> session = new(std::nothrow) SessionMocker(sessionInfo); 544e0dac50fSopenharmony_ci ASSERT_NE(nullptr, session); 545e0dac50fSopenharmony_ci window->property_->SetPersistentId(1); 546e0dac50fSopenharmony_ci window->hostSession_ = session; 547e0dac50fSopenharmony_ci window->state_ = WindowState::STATE_SHOWN; 548e0dac50fSopenharmony_ci activeWindows_.push_back(window); 549e0dac50fSopenharmony_ci std::map<WindowType, SystemBarProperty> systemBarProperties; 550e0dac50fSopenharmony_ci std::map<WindowType, SystemBarPropertyFlag> systemBarPropertyFlags; 551e0dac50fSopenharmony_ci GetSystemBarStatus(systemBarProperties, systemBarPropertyFlags, type); 552e0dac50fSopenharmony_ci UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags, window); 553e0dac50fSopenharmony_ci WMError ret = SetSystemBarPropertiesByFlags(systemBarPropertyFlags, systemBarProperties, window); 554e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, ret); 555e0dac50fSopenharmony_ci sleep(1); 556e0dac50fSopenharmony_ci if (type == WindowType::WINDOW_TYPE_STATUS_BAR) { 557e0dac50fSopenharmony_ci auto sta = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); 558e0dac50fSopenharmony_ci auto nav = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR); 559e0dac50fSopenharmony_ci EXPECT_EQ(true, sta.enable_); 560e0dac50fSopenharmony_ci EXPECT_EQ(true, nav.enable_); 561e0dac50fSopenharmony_ci } else if (type == WindowType::WINDOW_TYPE_NAVIGATION_BAR) { 562e0dac50fSopenharmony_ci auto nav = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_BAR); 563e0dac50fSopenharmony_ci EXPECT_EQ(true, nav.enable_); 564e0dac50fSopenharmony_ci } 565e0dac50fSopenharmony_ci } 566e0dac50fSopenharmony_ci } 567e0dac50fSopenharmony_ci} 568e0dac50fSopenharmony_ci 569e0dac50fSopenharmony_ci/** 570e0dac50fSopenharmony_ci * @tc.name: SetWindowSystemBarEnable_2 571e0dac50fSopenharmony_ci * @tc.desc: SetWindowSystemBarEnable_2 572e0dac50fSopenharmony_ci * @tc.type: FUNC 573e0dac50fSopenharmony_ci */ 574e0dac50fSopenharmony_ciHWTEST_F(WindowImmersiveTest1, setWindowSystemBarEnable_2, Function | MediumTest | Level3) 575e0dac50fSopenharmony_ci{ 576e0dac50fSopenharmony_ci const vector<WindowMode>windowMode{WindowMode::WINDOW_MODE_FULLSCREEN, WindowMode::WINDOW_MODE_SPLIT_PRIMARY, 577e0dac50fSopenharmony_ci WindowMode::WINDOW_MODE_SPLIT_SECONDARY, WindowMode::WINDOW_MODE_FLOATING}; 578e0dac50fSopenharmony_ci const vector<WindowType>windowType{WindowType::WINDOW_TYPE_STATUS_BAR, WindowType::WINDOW_TYPE_NAVIGATION_BAR}; 579e0dac50fSopenharmony_ci for (auto type : windowType) { 580e0dac50fSopenharmony_ci for (auto mode : windowMode) { 581e0dac50fSopenharmony_ci sptr<WindowOption> option = new (std::nothrow) WindowOption(); 582e0dac50fSopenharmony_ci ASSERT_NE(nullptr, option); 583e0dac50fSopenharmony_ci option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); 584e0dac50fSopenharmony_ci option->SetWindowMode(mode); 585e0dac50fSopenharmony_ci sptr<WindowSceneSessionImpl> window = new WindowSceneSessionImpl(option); 586e0dac50fSopenharmony_ci EXPECT_FALSE(window == nullptr); 587e0dac50fSopenharmony_ci SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; 588e0dac50fSopenharmony_ci sptr<SessionMocker> session = new(std::nothrow) SessionMocker(sessionInfo); 589e0dac50fSopenharmony_ci ASSERT_NE(nullptr, session); 590e0dac50fSopenharmony_ci window->property_->SetPersistentId(1); 591e0dac50fSopenharmony_ci window->hostSession_ = session; 592e0dac50fSopenharmony_ci window->state_ = WindowState::STATE_SHOWN; 593e0dac50fSopenharmony_ci activeWindows_.push_back(window); 594e0dac50fSopenharmony_ci std::map<WindowType, SystemBarProperty> systemBarProperties; 595e0dac50fSopenharmony_ci std::map<WindowType, SystemBarPropertyFlag> systemBarPropertyFlags; 596e0dac50fSopenharmony_ci GetSystemBarStatus(systemBarProperties, systemBarPropertyFlags, type); 597e0dac50fSopenharmony_ci UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags, window); 598e0dac50fSopenharmony_ci WMError ret = SetSystemBarPropertiesByFlags(systemBarPropertyFlags, systemBarProperties, window); 599e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, ret); 600e0dac50fSopenharmony_ci 601e0dac50fSopenharmony_ci GetSystemBarStatus(systemBarProperties, systemBarPropertyFlags, WindowType::APP_WINDOW_BASE); 602e0dac50fSopenharmony_ci UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags, window); 603e0dac50fSopenharmony_ci ret = SetSystemBarPropertiesByFlags(systemBarPropertyFlags, systemBarProperties, window); 604e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, ret); 605e0dac50fSopenharmony_ci sleep(1); 606e0dac50fSopenharmony_ci auto sta = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); 607e0dac50fSopenharmony_ci auto nav = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR); 608e0dac50fSopenharmony_ci EXPECT_EQ(false, sta.enable_); 609e0dac50fSopenharmony_ci EXPECT_EQ(false, nav.enable_); 610e0dac50fSopenharmony_ci window->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); 611e0dac50fSopenharmony_ci GetSystemBarStatus(systemBarProperties, systemBarPropertyFlags, type); 612e0dac50fSopenharmony_ci UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags, window); 613e0dac50fSopenharmony_ci ret = SetSystemBarPropertiesByFlags(systemBarPropertyFlags, systemBarProperties, window); 614e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, ret); 615e0dac50fSopenharmony_ci sleep(1); 616e0dac50fSopenharmony_ci sta = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR); 617e0dac50fSopenharmony_ci nav = window->GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR); 618e0dac50fSopenharmony_ci EXPECT_EQ(false, sta.enable_); 619e0dac50fSopenharmony_ci EXPECT_EQ(false, nav.enable_); 620e0dac50fSopenharmony_ci } 621e0dac50fSopenharmony_ci } 622e0dac50fSopenharmony_ci} 623e0dac50fSopenharmony_ci 624e0dac50fSopenharmony_ci/** 625e0dac50fSopenharmony_ci * @tc.name: SetSpecificBarProperty 626e0dac50fSopenharmony_ci * @tc.desc: SetSpecificBarProperty 627e0dac50fSopenharmony_ci * @tc.type: FUNC 628e0dac50fSopenharmony_ci */ 629e0dac50fSopenharmony_ciHWTEST_F(WindowImmersiveTest1, setSpecificBarProperty, Function | MediumTest | Level3) 630e0dac50fSopenharmony_ci{ 631e0dac50fSopenharmony_ci const vector<WindowMode>windowMode{WindowMode::WINDOW_MODE_FULLSCREEN, WindowMode::WINDOW_MODE_SPLIT_PRIMARY, 632e0dac50fSopenharmony_ci WindowMode::WINDOW_MODE_SPLIT_SECONDARY, WindowMode::WINDOW_MODE_FLOATING}; 633e0dac50fSopenharmony_ci const vector<WindowType>windowType{WindowType::WINDOW_TYPE_STATUS_BAR, WindowType::WINDOW_TYPE_NAVIGATION_BAR, 634e0dac50fSopenharmony_ci WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR}; 635e0dac50fSopenharmony_ci for (auto mode : windowMode) { 636e0dac50fSopenharmony_ci for (auto type : windowType) { 637e0dac50fSopenharmony_ci sptr<WindowOption> option = new (std::nothrow) WindowOption(); 638e0dac50fSopenharmony_ci ASSERT_NE(nullptr, option); 639e0dac50fSopenharmony_ci option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); 640e0dac50fSopenharmony_ci option->SetWindowMode(mode); 641e0dac50fSopenharmony_ci 642e0dac50fSopenharmony_ci sptr<WindowSceneSessionImpl> window = new WindowSceneSessionImpl(option); 643e0dac50fSopenharmony_ci EXPECT_FALSE(window == nullptr); 644e0dac50fSopenharmony_ci 645e0dac50fSopenharmony_ci SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; 646e0dac50fSopenharmony_ci sptr<SessionMocker> session = new(std::nothrow) SessionMocker(sessionInfo); 647e0dac50fSopenharmony_ci ASSERT_NE(nullptr, session); 648e0dac50fSopenharmony_ci window->property_->SetPersistentId(1); 649e0dac50fSopenharmony_ci window->hostSession_ = session; 650e0dac50fSopenharmony_ci window->state_ = WindowState::STATE_SHOWN; 651e0dac50fSopenharmony_ci activeWindows_.push_back(window); 652e0dac50fSopenharmony_ci 653e0dac50fSopenharmony_ci std::map<WindowType, SystemBarProperty> systemBarProperties; 654e0dac50fSopenharmony_ci std::map<WindowType, SystemBarPropertyFlag> systemBarPropertyFlags; 655e0dac50fSopenharmony_ci GetSpecificBarStatus(systemBarProperties, systemBarPropertyFlags, type); 656e0dac50fSopenharmony_ci WMError ret = window->SetSpecificBarProperty(type, systemBarProperties[type]); 657e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, ret); 658e0dac50fSopenharmony_ci auto status = window->GetSystemBarPropertyByType(type); 659e0dac50fSopenharmony_ci EXPECT_EQ(true, status.enable_); 660e0dac50fSopenharmony_ci 661e0dac50fSopenharmony_ci GetSpecificBarStatus(systemBarProperties, systemBarPropertyFlags, WindowType::APP_WINDOW_BASE); 662e0dac50fSopenharmony_ci ret = window->SetSpecificBarProperty(type, systemBarProperties[type]); 663e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, ret); 664e0dac50fSopenharmony_ci status = window->GetSystemBarPropertyByType(type); 665e0dac50fSopenharmony_ci EXPECT_EQ(false, status.enable_); 666e0dac50fSopenharmony_ci 667e0dac50fSopenharmony_ci window->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); 668e0dac50fSopenharmony_ci 669e0dac50fSopenharmony_ci GetSpecificBarStatus(systemBarProperties, systemBarPropertyFlags, WindowType::APP_WINDOW_BASE); 670e0dac50fSopenharmony_ci ret = window->SetSpecificBarProperty(type, systemBarProperties[type]); 671e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, ret); 672e0dac50fSopenharmony_ci status = window->GetSystemBarPropertyByType(type); 673e0dac50fSopenharmony_ci EXPECT_EQ(false, status.enable_); 674e0dac50fSopenharmony_ci } 675e0dac50fSopenharmony_ci } 676e0dac50fSopenharmony_ci} 677e0dac50fSopenharmony_ci 678e0dac50fSopenharmony_ci/** 679e0dac50fSopenharmony_ci * @tc.name: SetWindowSystemBarProperties 680e0dac50fSopenharmony_ci * @tc.desc: SetWindowSystemBarProperties 681e0dac50fSopenharmony_ci * @tc.type: FUNC 682e0dac50fSopenharmony_ci */ 683e0dac50fSopenharmony_ciHWTEST_F(WindowImmersiveTest1, setWindowSystemBarProperties, Function | MediumTest | Level3) 684e0dac50fSopenharmony_ci{ 685e0dac50fSopenharmony_ci const vector<WindowMode>windowMode{WindowMode::WINDOW_MODE_FULLSCREEN, WindowMode::WINDOW_MODE_SPLIT_PRIMARY, 686e0dac50fSopenharmony_ci WindowMode::WINDOW_MODE_SPLIT_SECONDARY, WindowMode::WINDOW_MODE_FLOATING}; 687e0dac50fSopenharmony_ci const vector<WindowType>windowType{WindowType::WINDOW_TYPE_STATUS_BAR, WindowType::WINDOW_TYPE_NAVIGATION_BAR}; 688e0dac50fSopenharmony_ci 689e0dac50fSopenharmony_ci for (auto type : windowType) { 690e0dac50fSopenharmony_ci for (auto mode : windowMode) { 691e0dac50fSopenharmony_ci sptr<WindowOption> option = new (std::nothrow) WindowOption(); 692e0dac50fSopenharmony_ci ASSERT_NE(nullptr, option); 693e0dac50fSopenharmony_ci option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); 694e0dac50fSopenharmony_ci option->SetWindowMode(mode); 695e0dac50fSopenharmony_ci 696e0dac50fSopenharmony_ci sptr<WindowSceneSessionImpl> window = new WindowSceneSessionImpl(option); 697e0dac50fSopenharmony_ci EXPECT_FALSE(window == nullptr); 698e0dac50fSopenharmony_ci 699e0dac50fSopenharmony_ci SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; 700e0dac50fSopenharmony_ci sptr<SessionMocker> session = new(std::nothrow) SessionMocker(sessionInfo); 701e0dac50fSopenharmony_ci ASSERT_NE(nullptr, session); 702e0dac50fSopenharmony_ci window->property_->SetPersistentId(1); 703e0dac50fSopenharmony_ci window->hostSession_ = session; 704e0dac50fSopenharmony_ci window->state_ = WindowState::STATE_SHOWN; 705e0dac50fSopenharmony_ci activeWindows_.push_back(window); 706e0dac50fSopenharmony_ci 707e0dac50fSopenharmony_ci std::map<WindowType, SystemBarProperty> systemBarProperties; 708e0dac50fSopenharmony_ci std::map<WindowType, SystemBarPropertyFlag> systemBarPropertyFlags; 709e0dac50fSopenharmony_ci GetSystemBarStatus(systemBarProperties, SYS_BAR_PROP_1, systemBarPropertyFlags, type); 710e0dac50fSopenharmony_ci UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags, window); 711e0dac50fSopenharmony_ci WMError ret = SetSystemBarPropertiesByFlags(systemBarPropertyFlags, systemBarProperties, window); 712e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, ret); 713e0dac50fSopenharmony_ci sleep(1); 714e0dac50fSopenharmony_ci auto sta = window->GetSystemBarPropertyByType(type); 715e0dac50fSopenharmony_ci EXPECT_EQ(SYS_BAR_PROP_1, sta); 716e0dac50fSopenharmony_ci 717e0dac50fSopenharmony_ci GetSystemBarStatus(systemBarProperties, SYS_BAR_PROP_2, systemBarPropertyFlags, type); 718e0dac50fSopenharmony_ci UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags, window); 719e0dac50fSopenharmony_ci ret = SetSystemBarPropertiesByFlags(systemBarPropertyFlags, systemBarProperties, window); 720e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, ret); 721e0dac50fSopenharmony_ci sleep(1); 722e0dac50fSopenharmony_ci sta = window->GetSystemBarPropertyByType(type); 723e0dac50fSopenharmony_ci EXPECT_EQ(SYS_BAR_PROP_2, sta); 724e0dac50fSopenharmony_ci 725e0dac50fSopenharmony_ci window->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); 726e0dac50fSopenharmony_ci 727e0dac50fSopenharmony_ci GetSystemBarStatus(systemBarProperties, SYS_BAR_PROP_1, systemBarPropertyFlags, type); 728e0dac50fSopenharmony_ci UpdateSystemBarProperties(systemBarProperties, systemBarPropertyFlags, window); 729e0dac50fSopenharmony_ci ret = SetSystemBarPropertiesByFlags(systemBarPropertyFlags, systemBarProperties, window); 730e0dac50fSopenharmony_ci EXPECT_EQ(WMError::WM_OK, ret); 731e0dac50fSopenharmony_ci sleep(1); 732e0dac50fSopenharmony_ci sta = window->GetSystemBarPropertyByType(type); 733e0dac50fSopenharmony_ci EXPECT_EQ(SYS_BAR_PROP_2, sta); 734e0dac50fSopenharmony_ci } 735e0dac50fSopenharmony_ci } 736e0dac50fSopenharmony_ci} 737e0dac50fSopenharmony_ci} 738e0dac50fSopenharmony_ci} // namespace Rosen 739e0dac50fSopenharmony_ci} // namespace OHOS