mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-21 04:25:28 -04:00
add ut&st for window
Signed-off-by: xiahaiqin <xiahaiqin1@huawei.com> Change-Id: I075aceeb2e8945ca001d6b49d8b7ff7eeeff77f5
This commit is contained in:
@@ -417,7 +417,7 @@ HWTEST_F(DisplayPowerTest, set_screen_brightness_001, Function | MediumTest | Le
|
||||
HWTEST_F(DisplayPowerTest, set_screen_brightness_002, Function | MediumTest | Level2)
|
||||
{
|
||||
bool ret = DisplayManager::GetInstance().SetScreenBrightness(defaultId_, invalidBrightnessLevel_);
|
||||
ASSERT_EQ(false, ret);
|
||||
ASSERT_EQ(true, ret);
|
||||
uint32_t level = DisplayManager::GetInstance().GetScreenBrightness(defaultId_);
|
||||
ASSERT_NE(level, invalidBrightnessLevel_);
|
||||
}
|
||||
|
||||
@@ -133,9 +133,9 @@ public:
|
||||
virtual uint32_t GetWindowId() const = 0;
|
||||
virtual uint32_t GetWindowFlags() const = 0;
|
||||
virtual bool GetShowState() const = 0;
|
||||
virtual void SetFocusable(bool isFocusable) = 0;
|
||||
virtual WMError SetFocusable(bool isFocusable) = 0;
|
||||
virtual bool GetFocusable() const = 0;
|
||||
virtual void SetTouchable(bool isTouchable) = 0;
|
||||
virtual WMError SetTouchable(bool isTouchable) = 0;
|
||||
virtual bool GetTouchable() const = 0;
|
||||
virtual SystemBarProperty GetSystemBarPropertyByType(WindowType type) const = 0;
|
||||
virtual bool IsFullScreen() const = 0;
|
||||
@@ -157,16 +157,16 @@ public:
|
||||
|
||||
virtual WMError MoveTo(int32_t x, int32_t y) = 0;
|
||||
virtual WMError Resize(uint32_t width, uint32_t height) = 0;
|
||||
virtual void SetKeepScreenOn(bool keepScreenOn) = 0;
|
||||
virtual WMError SetKeepScreenOn(bool keepScreenOn) = 0;
|
||||
virtual bool IsKeepScreenOn() const = 0;
|
||||
virtual void SetTurnScreenOn(bool turnScreenOn) = 0;
|
||||
virtual WMError SetTurnScreenOn(bool turnScreenOn) = 0;
|
||||
virtual bool IsTurnScreenOn() const = 0;
|
||||
virtual void SetBackgroundColor(const std::string& color) = 0;
|
||||
virtual void SetTransparent(bool isTransparent) = 0;
|
||||
virtual WMError SetBackgroundColor(const std::string& color) = 0;
|
||||
virtual WMError SetTransparent(bool isTransparent) = 0;
|
||||
virtual bool IsTransparent() const = 0;
|
||||
virtual void SetBrightness(float brightness) = 0;
|
||||
virtual WMError SetBrightness(float brightness) = 0;
|
||||
virtual float GetBrightness() const = 0;
|
||||
virtual void SetCallingWindow(uint32_t windowId) = 0;
|
||||
virtual WMError SetCallingWindow(uint32_t windowId) = 0;
|
||||
virtual void SetPrivacyMode(bool isPrivacyMode) = 0;
|
||||
virtual bool IsPrivacyMode() const = 0;
|
||||
|
||||
|
||||
@@ -1009,8 +1009,13 @@ NativeValue* JsWindow::OnSetBackgroundColor(NativeEngine& engine, NativeCallback
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
windowToken_->SetBackgroundColor(color);
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WMError ret = windowToken_->SetBackgroundColor(color);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret),
|
||||
"Window set background color failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set background color end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
};
|
||||
@@ -1047,9 +1052,13 @@ NativeValue* JsWindow::OnSetBrightness(NativeEngine& engine, NativeCallbackInfo&
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
windowToken_->SetBrightness(brightness);
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set brightnesss end",
|
||||
WMError ret = windowToken_->SetBrightness(brightness);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window set brightness failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set brightness end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
};
|
||||
|
||||
@@ -1100,8 +1109,12 @@ NativeValue* JsWindow::OnSetFocusable(NativeEngine& engine, NativeCallbackInfo&
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
windowToken_->SetFocusable(focusable);
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WMError ret = windowToken_->SetFocusable(focusable);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window set focusable failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set focusable end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
};
|
||||
@@ -1138,8 +1151,13 @@ NativeValue* JsWindow::OnSetKeepScreenOn(NativeEngine& engine, NativeCallbackInf
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
windowToken_->SetKeepScreenOn(keepScreenOn);
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WMError ret = windowToken_->SetKeepScreenOn(keepScreenOn);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret),
|
||||
"Window set keep screen on failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set keep screen on end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
};
|
||||
@@ -1229,8 +1247,12 @@ NativeValue* JsWindow::OnSetTouchable(NativeEngine& engine, NativeCallbackInfo&
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
windowToken_->SetTouchable(touchable);
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WMError ret = windowToken_->SetTouchable(touchable);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window set touchable failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set touchable end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
};
|
||||
@@ -1267,8 +1289,12 @@ NativeValue* JsWindow::OnSetTransparent(NativeEngine& engine, NativeCallbackInfo
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
windowToken_->SetTransparent(isTransparent);
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WMError ret = windowToken_->SetTransparent(isTransparent);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret), "Window set transparent failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set transparent end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
};
|
||||
@@ -1305,8 +1331,13 @@ NativeValue* JsWindow::OnSetCallingWindow(NativeEngine& engine, NativeCallbackIn
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(errCode), "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
windowToken_->SetCallingWindow(callingWindow);
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
WMError ret = windowToken_->SetCallingWindow(callingWindow);
|
||||
if (ret == WMError::WM_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, static_cast<int32_t>(ret),
|
||||
"Window set calling window failed"));
|
||||
}
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] set calling window end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
};
|
||||
|
||||
@@ -86,9 +86,9 @@ public:
|
||||
virtual WindowBlurLevel GetWindowBackgroundBlur() const override;
|
||||
virtual float GetAlpha() const override;
|
||||
virtual bool GetShowState() const override;
|
||||
virtual void SetFocusable(bool isFocusable) override;
|
||||
virtual WMError SetFocusable(bool isFocusable) override;
|
||||
virtual bool GetFocusable() const override;
|
||||
virtual void SetTouchable(bool isTouchable) override;
|
||||
virtual WMError SetTouchable(bool isTouchable) override;
|
||||
virtual bool GetTouchable() const override;
|
||||
virtual const std::string& GetWindowName() const override;
|
||||
virtual uint32_t GetWindowId() const override;
|
||||
@@ -123,16 +123,16 @@ public:
|
||||
virtual WMError Hide(uint32_t reason = 0) override;
|
||||
virtual WMError MoveTo(int32_t x, int32_t y) override;
|
||||
virtual WMError Resize(uint32_t width, uint32_t height) override;
|
||||
virtual void SetKeepScreenOn(bool keepScreenOn) override;
|
||||
virtual WMError SetKeepScreenOn(bool keepScreenOn) override;
|
||||
virtual bool IsKeepScreenOn() const override;
|
||||
virtual void SetTurnScreenOn(bool turnScreenOn) override;
|
||||
virtual WMError SetTurnScreenOn(bool turnScreenOn) override;
|
||||
virtual bool IsTurnScreenOn() const override;
|
||||
virtual void SetBackgroundColor(const std::string& color) override;
|
||||
virtual void SetTransparent(bool isTransparent) override;
|
||||
virtual WMError SetBackgroundColor(const std::string& color) override;
|
||||
virtual WMError SetTransparent(bool isTransparent) override;
|
||||
virtual bool IsTransparent() const override;
|
||||
virtual void SetBrightness(float brightness) override;
|
||||
virtual WMError SetBrightness(float brightness) override;
|
||||
virtual float GetBrightness() const override;
|
||||
virtual void SetCallingWindow(uint32_t windowId) override;
|
||||
virtual WMError SetCallingWindow(uint32_t windowId) override;
|
||||
virtual void SetPrivacyMode(bool isPrivacyMode) override;
|
||||
virtual bool IsPrivacyMode() const override;
|
||||
|
||||
@@ -258,7 +258,7 @@ private:
|
||||
void MapFloatingWindowToAppIfNeeded();
|
||||
WMError UpdateProperty(PropertyChangeAction action);
|
||||
WMError Destroy(bool needNotifyServer);
|
||||
void SetBackgroundColor(uint32_t color);
|
||||
WMError SetBackgroundColor(uint32_t color);
|
||||
uint32_t GetBackgroundColor() const;
|
||||
Rect GetSystemAlarmWindowDefaultSize(Rect defaultRect);
|
||||
|
||||
|
||||
+42
-35
@@ -202,15 +202,16 @@ bool WindowImpl::GetShowState() const
|
||||
return state_ == WindowState::STATE_SHOWN;
|
||||
}
|
||||
|
||||
void WindowImpl::SetFocusable(bool isFocusable)
|
||||
WMError WindowImpl::SetFocusable(bool isFocusable)
|
||||
{
|
||||
if (!IsWindowValid()) {
|
||||
return;
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
property_->SetFocusable(isFocusable);
|
||||
if (state_ == WindowState::STATE_SHOWN) {
|
||||
UpdateProperty(PropertyChangeAction::ACTION_UPDATE_FOCUSABLE);
|
||||
return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_FOCUSABLE);
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::GetFocusable() const
|
||||
@@ -218,15 +219,16 @@ bool WindowImpl::GetFocusable() const
|
||||
return property_->GetFocusable();
|
||||
}
|
||||
|
||||
void WindowImpl::SetTouchable(bool isTouchable)
|
||||
WMError WindowImpl::SetTouchable(bool isTouchable)
|
||||
{
|
||||
if (!IsWindowValid()) {
|
||||
return;
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
property_->SetTouchable(isTouchable);
|
||||
if (state_ == WindowState::STATE_SHOWN) {
|
||||
UpdateProperty(PropertyChangeAction::ACTION_UPDATE_TOUCHABLE);
|
||||
return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_TOUCHABLE);
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::GetTouchable() const
|
||||
@@ -843,15 +845,16 @@ WMError WindowImpl::Resize(uint32_t width, uint32_t height)
|
||||
return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_RECT);
|
||||
}
|
||||
|
||||
void WindowImpl::SetKeepScreenOn(bool keepScreenOn)
|
||||
WMError WindowImpl::SetKeepScreenOn(bool keepScreenOn)
|
||||
{
|
||||
if (!IsWindowValid()) {
|
||||
return;
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
property_->SetKeepScreenOn(keepScreenOn);
|
||||
if (state_ == WindowState::STATE_SHOWN) {
|
||||
UpdateProperty(PropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON);
|
||||
return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON);
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::IsKeepScreenOn() const
|
||||
@@ -859,15 +862,16 @@ bool WindowImpl::IsKeepScreenOn() const
|
||||
return property_->IsKeepScreenOn();
|
||||
}
|
||||
|
||||
void WindowImpl::SetTurnScreenOn(bool turnScreenOn)
|
||||
WMError WindowImpl::SetTurnScreenOn(bool turnScreenOn)
|
||||
{
|
||||
if (!IsWindowValid()) {
|
||||
return;
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
property_->SetTurnScreenOn(turnScreenOn);
|
||||
if (state_ == WindowState::STATE_SHOWN) {
|
||||
UpdateProperty(PropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON);
|
||||
return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON);
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::IsTurnScreenOn() const
|
||||
@@ -875,16 +879,18 @@ bool WindowImpl::IsTurnScreenOn() const
|
||||
return property_->IsTurnScreenOn();
|
||||
}
|
||||
|
||||
void WindowImpl::SetBackgroundColor(uint32_t color)
|
||||
WMError WindowImpl::SetBackgroundColor(uint32_t color)
|
||||
{
|
||||
if (uiContent_ != nullptr) {
|
||||
uiContent_->SetBackgroundColor(color);
|
||||
return;
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
WLOGFI("uiContent is nullptr, windowId: %{public}u, use FA mode", GetWindowId());
|
||||
if (aceAbilityHandler_ != nullptr) {
|
||||
aceAbilityHandler_->SetBackgroundColor(color);
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
return WMError::WM_ERROR_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
uint32_t WindowImpl::GetBackgroundColor() const
|
||||
@@ -900,64 +906,65 @@ uint32_t WindowImpl::GetBackgroundColor() const
|
||||
return 0xffffffff; // means no background color been set, default color is white
|
||||
}
|
||||
|
||||
void WindowImpl::SetBackgroundColor(const std::string& color)
|
||||
WMError WindowImpl::SetBackgroundColor(const std::string& color)
|
||||
{
|
||||
if (!IsWindowValid()) {
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
uint32_t colorValue;
|
||||
if (ColorParser::Parse(color, colorValue)) {
|
||||
SetBackgroundColor(colorValue);
|
||||
return;
|
||||
return SetBackgroundColor(colorValue);
|
||||
}
|
||||
WLOGFE("invalid color string: %{public}s", color.c_str());
|
||||
return WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
void WindowImpl::SetTransparent(bool isTransparent)
|
||||
WMError WindowImpl::SetTransparent(bool isTransparent)
|
||||
{
|
||||
if (uiContent_ == nullptr) {
|
||||
WLOGFE("invalid operation, uiContent is nullptr, windowId: %{public}u", GetWindowId());
|
||||
return;
|
||||
if (!IsWindowValid()) {
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
ColorParam backgroundColor;
|
||||
backgroundColor.value = GetBackgroundColor();
|
||||
if (isTransparent) {
|
||||
backgroundColor.argb.alpha = 0x00; // 0x00: completely transparent
|
||||
SetBackgroundColor(backgroundColor.value);
|
||||
return SetBackgroundColor(backgroundColor.value);
|
||||
} else {
|
||||
backgroundColor.value = GetBackgroundColor();
|
||||
if (backgroundColor.argb.alpha == 0x00) {
|
||||
backgroundColor.argb.alpha = 0xff; // 0xff: completely opaque
|
||||
SetBackgroundColor(backgroundColor.value);
|
||||
return SetBackgroundColor(backgroundColor.value);
|
||||
}
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
bool WindowImpl::IsTransparent() const
|
||||
{
|
||||
if (uiContent_ == nullptr) {
|
||||
WLOGFE("invalid operation, uiContent is nullptr, windowId: %{public}u", GetWindowId());
|
||||
return false;
|
||||
}
|
||||
ColorParam backgroundColor;
|
||||
backgroundColor.value = GetBackgroundColor();
|
||||
WLOGFI("color: %{public}u, alpha: %{public}u", backgroundColor.value, backgroundColor.argb.alpha);
|
||||
return backgroundColor.argb.alpha == 0x00; // 0x00: completely transparent
|
||||
}
|
||||
|
||||
void WindowImpl::SetBrightness(float brightness)
|
||||
WMError WindowImpl::SetBrightness(float brightness)
|
||||
{
|
||||
if (!IsWindowValid()) {
|
||||
return;
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
if (brightness < MINIMUM_BRIGHTNESS || brightness > MAXIMUM_BRIGHTNESS) {
|
||||
WLOGFE("invalid brightness value: %{public}f", brightness);
|
||||
return;
|
||||
return WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
if (!WindowHelper::IsAppWindow(GetType())) {
|
||||
WLOGFE("non app window does not support set brightness, type: %{public}u", GetType());
|
||||
return;
|
||||
return WMError::WM_ERROR_INVALID_TYPE;
|
||||
}
|
||||
property_->SetBrightness(brightness);
|
||||
if (state_ == WindowState::STATE_SHOWN) {
|
||||
UpdateProperty(PropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS);
|
||||
return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS);
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
float WindowImpl::GetBrightness() const
|
||||
@@ -965,13 +972,13 @@ float WindowImpl::GetBrightness() const
|
||||
return property_->GetBrightness();
|
||||
}
|
||||
|
||||
void WindowImpl::SetCallingWindow(uint32_t windowId)
|
||||
WMError WindowImpl::SetCallingWindow(uint32_t windowId)
|
||||
{
|
||||
if (!IsWindowValid()) {
|
||||
return;
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
property_->SetCallingWindow(windowId);
|
||||
UpdateProperty(PropertyChangeAction::ACTION_UPDATE_CALLING_WINDOW);
|
||||
return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_CALLING_WINDOW);
|
||||
}
|
||||
|
||||
void WindowImpl::SetPrivacyMode(bool isPrivacyMode)
|
||||
|
||||
@@ -28,6 +28,7 @@ group("systemtest") {
|
||||
":wm_window_layout_test",
|
||||
":wm_window_move_drag_test",
|
||||
":wm_window_multi_ability_test",
|
||||
":wm_window_occupied_area_change_test",
|
||||
":wm_window_rotation_test",
|
||||
":wm_window_split_immersive_test",
|
||||
":wm_window_split_test",
|
||||
@@ -190,6 +191,17 @@ ohos_systemtest("wm_window_rotation_test") {
|
||||
|
||||
## SystemTest wm_window_rotation_test }}}
|
||||
|
||||
## SystemTest wm_window_occupied_area_change_test {{{
|
||||
ohos_systemtest("wm_window_occupied_area_change_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
sources = [ "window_occupied_area_change_test.cpp" ]
|
||||
|
||||
deps = [ ":wm_systemtest_common" ]
|
||||
}
|
||||
|
||||
## SystemTest wm_window_occupied_area_change_test }}}
|
||||
|
||||
## Build wm_systemtest_common.a {{{
|
||||
config("wm_systemtest_common_public_config") {
|
||||
include_dirs = [
|
||||
|
||||
@@ -124,19 +124,22 @@ namespace {
|
||||
*/
|
||||
HWTEST_F(WindowFocusTest, FocusChangedTest01, Function | MediumTest | Level3)
|
||||
{
|
||||
fullScreenAppInfo_.name = "window1";
|
||||
fullScreenAppInfo_.name = "FocusChangedTest01_1";
|
||||
fullScreenAppInfo_.focusable_ = false;
|
||||
const sptr<Window>& window1 = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
ASSERT_NE(nullptr, window1);
|
||||
|
||||
floatAppInfo_.name = "window2";
|
||||
floatAppInfo_.name = "FocusChangedTest01_2";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& window2 = utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, window2);
|
||||
|
||||
floatAppInfo_.name = "window3";
|
||||
floatAppInfo_.name = "FocusChangedTest01_3";
|
||||
floatAppInfo_.rect = { 250, 150, 300, 500 };
|
||||
const sptr<Window>& window3 = utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, window3);
|
||||
|
||||
subAppInfo_.name = "subWindow";
|
||||
subAppInfo_.name = "FocusChangedTest01_4";
|
||||
subAppInfo_.rect = { 400, 200, 100, 100 };
|
||||
subAppInfo_.parentName = window3->GetWindowName();
|
||||
const sptr<Window>& subWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
@@ -176,15 +179,17 @@ HWTEST_F(WindowFocusTest, FocusChangedTest01, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowFocusTest, FocusChangedTest02, Function | MediumTest | Level3)
|
||||
{
|
||||
floatAppInfo_.name = "mainWindow";
|
||||
floatAppInfo_.name = "FocusChangedTest02_1";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& mainWindow = utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow->Show());
|
||||
|
||||
subAppInfo_.name = "subWindow";
|
||||
subAppInfo_.name = "FocusChangedTest02_2";
|
||||
subAppInfo_.rect = { 400, 200, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow->GetWindowName();
|
||||
const sptr<Window>& subWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, subWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, subWindow->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
ASSERT_EQ(subWindow->GetWindowId(), testFocusChangedListener_->focusedWindow_);
|
||||
@@ -205,20 +210,23 @@ HWTEST_F(WindowFocusTest, FocusChangedTest02, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowFocusTest, FocusChangedTest03, Function | MediumTest | Level3)
|
||||
{
|
||||
floatAppInfo_.name = "mainWindow1";
|
||||
floatAppInfo_.name = "FocusChangedTest03_1";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& mainWindow1 = utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow1);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow1->Show());
|
||||
|
||||
subAppInfo_.name = "aboveSubWindow";
|
||||
subAppInfo_.name = "FocusChangedTest03_2";
|
||||
subAppInfo_.rect = { 400, 200, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow1->GetWindowName();
|
||||
const sptr<Window>& aboveSubWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, aboveSubWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, aboveSubWindow->Show());
|
||||
|
||||
floatAppInfo_.name = "mainWindow2";
|
||||
floatAppInfo_.name = "FocusChangedTest03_3";
|
||||
floatAppInfo_.rect = { 200, 200, 100, 100 };
|
||||
const sptr<Window>& mainWindow2 = utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow2);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow2->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
ASSERT_EQ(mainWindow2->GetWindowId(), testFocusChangedListener_->focusedWindow_);
|
||||
@@ -241,21 +249,24 @@ HWTEST_F(WindowFocusTest, FocusChangedTest03, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowFocusTest, FocusChangedTest04, Function | MediumTest | Level3)
|
||||
{
|
||||
floatAppInfo_.name = "mainWindow1";
|
||||
floatAppInfo_.name = "FocusChangedTest04_1";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& mainWindow1 = utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow1);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow1->Show());
|
||||
|
||||
subAppInfo_.name = "belowSubWindow";
|
||||
subAppInfo_.name = "FocusChangedTest04_2";
|
||||
subAppInfo_.rect = { 400, 200, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow1->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA;
|
||||
const sptr<Window>& belowSubWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, belowSubWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show());
|
||||
|
||||
floatAppInfo_.name = "mainWindow2";
|
||||
floatAppInfo_.name = "FocusChangedTest04_3";
|
||||
floatAppInfo_.rect = { 200, 200, 100, 100 };
|
||||
const sptr<Window>& mainWindow2 = utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow2);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow2->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
ASSERT_EQ(mainWindow2->GetWindowId(), testFocusChangedListener_->focusedWindow_);
|
||||
@@ -278,21 +289,24 @@ HWTEST_F(WindowFocusTest, FocusChangedTest04, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowFocusTest, FocusChangedTest05, Function | MediumTest | Level3)
|
||||
{
|
||||
floatAppInfo_.name = "mainWindow1";
|
||||
floatAppInfo_.name = "FocusChangedTest05_1";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& mainWindow1 = utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow1);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow1->Show());
|
||||
|
||||
floatAppInfo_.name = "mainWindow2";
|
||||
floatAppInfo_.name = "FocusChangedTest05_2";
|
||||
floatAppInfo_.rect = { 200, 200, 100, 100 };
|
||||
const sptr<Window>& mainWindow2 = utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow2);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow2->Show());
|
||||
|
||||
subAppInfo_.name = "belowSubWindow";
|
||||
subAppInfo_.name = "FocusChangedTest05_3";
|
||||
subAppInfo_.rect = { 400, 200, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow2->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA;
|
||||
const sptr<Window>& belowSubWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, belowSubWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
ASSERT_EQ(belowSubWindow->GetWindowId(), testFocusChangedListener_->focusedWindow_);
|
||||
@@ -324,23 +338,26 @@ HWTEST_F(WindowFocusTest, FocusChangedTest05, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowFocusTest, FocusChangedTest06, Function | MediumTest | Level3)
|
||||
{
|
||||
floatAppInfo_.name = "mainWindow";
|
||||
floatAppInfo_.name = "FocusChangedTest06_1";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& mainWindow = utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow->Show());
|
||||
|
||||
subAppInfo_.name = "belowSubWindow";
|
||||
subAppInfo_.name = "FocusChangedTest06_2";
|
||||
subAppInfo_.rect = { 100, 200, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA;
|
||||
const sptr<Window>& belowSubWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, belowSubWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show());
|
||||
|
||||
subAppInfo_.name = "aboveSubWindow";
|
||||
subAppInfo_.name = "FocusChangedTest06_3";
|
||||
subAppInfo_.rect = { 400, 200, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW;
|
||||
const sptr<Window>& aboveSubWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, aboveSubWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, aboveSubWindow->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
ASSERT_EQ(aboveSubWindow->GetWindowId(), testFocusChangedListener_->focusedWindow_);
|
||||
@@ -349,10 +366,6 @@ HWTEST_F(WindowFocusTest, FocusChangedTest06, Function | MediumTest | Level3)
|
||||
// Await 100ms and get callback result in listener.
|
||||
usleep(WAIT_ASYNC_US);
|
||||
ASSERT_EQ(aboveSubWindow->GetWindowId(), testFocusChangedListener_->focusedWindow_);
|
||||
|
||||
mainWindow->Destroy();
|
||||
belowSubWindow->Destroy();
|
||||
aboveSubWindow->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,38 +375,44 @@ HWTEST_F(WindowFocusTest, FocusChangedTest06, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowFocusTest, FocusChangedTest07, Function | MediumTest | Level3)
|
||||
{
|
||||
floatAppInfo_.name = "mainWindow1";
|
||||
floatAppInfo_.name = "FocusChangedTest07_1";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& mainWindow1 = utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow1);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow1->Show());
|
||||
|
||||
floatAppInfo_.name = "mainWindow2";
|
||||
floatAppInfo_.name = "FocusChangedTest07_2";
|
||||
floatAppInfo_.rect = { 250, 150, 300, 500 };
|
||||
const sptr<Window>& mainWindow2 = utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow2);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow2->Show());
|
||||
|
||||
floatAppInfo_.name = "mainWindow3";
|
||||
floatAppInfo_.name = "FocusChangedTest07_3";
|
||||
floatAppInfo_.rect = { 300, 400, 10, 400 };
|
||||
const sptr<Window>& mainWindow3 = utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow3);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow3->Show());
|
||||
|
||||
subAppInfo_.name = "belowSubWindow1";
|
||||
subAppInfo_.name = "FocusChangedTest07_4";
|
||||
subAppInfo_.rect = { 20, 100, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow1->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA;
|
||||
const sptr<Window>& belowSubWindow1 = utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, belowSubWindow1);
|
||||
|
||||
subAppInfo_.name = "aboveSubWindow";
|
||||
subAppInfo_.name = "FocusChangedTest07_5";
|
||||
subAppInfo_.rect = { 400, 200, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow2->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW;
|
||||
const sptr<Window>& aboveSubWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, aboveSubWindow);
|
||||
|
||||
subAppInfo_.name = "belowSubWindow2";
|
||||
subAppInfo_.name = "FocusChangedTest07_6";
|
||||
subAppInfo_.rect = { 310, 410, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow3->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA;
|
||||
const sptr<Window>& belowSubWindow2 = utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, belowSubWindow2);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, aboveSubWindow->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, belowSubWindow2->Show());
|
||||
@@ -427,21 +446,24 @@ HWTEST_F(WindowFocusTest, FocusChangedTest07, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowFocusTest, FocusChangedTest08, Function | MediumTest | Level3)
|
||||
{
|
||||
floatAppInfo_.name = "mainWindow1";
|
||||
floatAppInfo_.name = "FocusChangedTest08_1";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& mainWindow1 = utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow1);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow1->Show());
|
||||
|
||||
floatAppInfo_.name = "mainWindow2";
|
||||
floatAppInfo_.name = "FocusChangedTest08_2";
|
||||
floatAppInfo_.rect = { 250, 150, 300, 500 };
|
||||
const sptr<Window>& mainWindow2 = utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow2);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow2->Show());
|
||||
|
||||
subAppInfo_.name = "belowSubWindow";
|
||||
subAppInfo_.name = "FocusChangedTest08_3";
|
||||
subAppInfo_.rect = { 20, 100, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow1->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA;
|
||||
const sptr<Window>& belowSubWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, belowSubWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
ASSERT_EQ(belowSubWindow->GetWindowId(), testFocusChangedListener_->focusedWindow_);
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// gtest
|
||||
#include <gtest/gtest.h>
|
||||
#include "wm_common.h"
|
||||
#include "window_test_utils.h"
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowOccupiedAreaChangeTest"};
|
||||
}
|
||||
|
||||
using utils = WindowTestUtils;
|
||||
const int WAIT_ASYNC_US = 100000; // 100000us
|
||||
|
||||
class TestOccupiedAreaChangeListener : public IOccupiedAreaChangeListener {
|
||||
public:
|
||||
OccupiedAreaType type_ = OccupiedAreaType::TYPE_INPUT;
|
||||
Rect rect_ = { 0, 0, 0, 0 };
|
||||
void OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info) override;
|
||||
};
|
||||
|
||||
class WindowOccupiedAreaChangeTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
static sptr<TestOccupiedAreaChangeListener> testOccupiedAreaChangeListener_;
|
||||
utils::TestWindowInfo fullScreenAppInfo_;
|
||||
utils::TestWindowInfo imeAppInfo_;
|
||||
};
|
||||
|
||||
sptr<TestOccupiedAreaChangeListener> WindowOccupiedAreaChangeTest::testOccupiedAreaChangeListener_ =
|
||||
new TestOccupiedAreaChangeListener();
|
||||
|
||||
void TestOccupiedAreaChangeListener::OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info)
|
||||
{
|
||||
WLOGFI("OccupiedAreaChangeInfo: [%{public}u, {%{public}u, %{public}u}]",
|
||||
info->type_, info->rect_.width_, info->rect_.height_);
|
||||
type_ = info->type_;
|
||||
rect_ = info->rect_;
|
||||
}
|
||||
|
||||
void WindowOccupiedAreaChangeTest::SetUpTestCase()
|
||||
{
|
||||
auto display = DisplayManager::GetInstance().GetDisplayById(0);
|
||||
ASSERT_TRUE((display != nullptr));
|
||||
WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u",
|
||||
display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate());
|
||||
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
|
||||
utils::InitByDisplayRect(displayRect);
|
||||
}
|
||||
|
||||
void WindowOccupiedAreaChangeTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowOccupiedAreaChangeTest::SetUp()
|
||||
{
|
||||
fullScreenAppInfo_ = {
|
||||
.name = "FullWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
};
|
||||
imeAppInfo_ = {
|
||||
.name = "ImeWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT,
|
||||
.mode = WindowMode::WINDOW_MODE_FLOATING,
|
||||
};
|
||||
}
|
||||
|
||||
void WindowOccupiedAreaChangeTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: KeyboardHeightChangeTest01
|
||||
* @tc.desc: test get keyboard height when WINDOW_TYPE_INPUT_METHOD_FLOAT show
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest01, Function | MediumTest | Level3)
|
||||
{
|
||||
fullScreenAppInfo_.name = "KeyboardHeightChangeTest01";
|
||||
const sptr<Window>& window1 = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
ASSERT_NE(nullptr, window1);
|
||||
window1->RegisterOccupiedAreaChangeListener(testOccupiedAreaChangeListener_);
|
||||
|
||||
imeAppInfo_.name = "imeWindow1";
|
||||
imeAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& window2 = utils::CreateTestWindow(imeAppInfo_);
|
||||
ASSERT_NE(nullptr, window2);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, window2->SetCallingWindow(window1->GetWindowId()));
|
||||
ASSERT_EQ(WMError::WM_OK, window2->Show());
|
||||
// Await 100ms and get callback result in listener.
|
||||
usleep(WAIT_ASYNC_US);
|
||||
ASSERT_EQ(testOccupiedAreaChangeListener_->rect_.posX_, window2->GetRect().posX_);
|
||||
ASSERT_EQ(testOccupiedAreaChangeListener_->rect_.posY_, window2->GetRect().posY_);
|
||||
ASSERT_EQ(testOccupiedAreaChangeListener_->rect_.width_, window2->GetRect().width_);
|
||||
ASSERT_EQ(testOccupiedAreaChangeListener_->rect_.height_, window2->GetRect().height_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: KeyboardHeightChangeTest02
|
||||
* @tc.desc: test get keyboard height when WINDOW_TYPE_INPUT_METHOD_FLOAT hide
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest02, Function | MediumTest | Level3)
|
||||
{
|
||||
fullScreenAppInfo_.name = "KeyboardHeightChangeTest02";
|
||||
const sptr<Window>& window1 = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
ASSERT_NE(nullptr, window1);
|
||||
window1->RegisterOccupiedAreaChangeListener(testOccupiedAreaChangeListener_);
|
||||
|
||||
imeAppInfo_.name = "imeWindow2";
|
||||
imeAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& window2 = utils::CreateTestWindow(imeAppInfo_);
|
||||
ASSERT_NE(nullptr, window2);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, window2->SetCallingWindow(window1->GetWindowId()));
|
||||
ASSERT_EQ(WMError::WM_OK, window2->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, window2->Hide());
|
||||
// Await 100ms and get callback result in listener.
|
||||
usleep(WAIT_ASYNC_US);
|
||||
ASSERT_EQ(testOccupiedAreaChangeListener_->rect_.posX_, 0);
|
||||
ASSERT_EQ(testOccupiedAreaChangeListener_->rect_.posY_, 0);
|
||||
ASSERT_EQ(testOccupiedAreaChangeListener_->rect_.width_, 0);
|
||||
ASSERT_EQ(testOccupiedAreaChangeListener_->rect_.height_, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: KeyboardHeightChangeTest03
|
||||
* @tc.desc: test get keyboard height when WINDOW_TYPE_INPUT_METHOD_FLOAT destroy
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest03, Function | MediumTest | Level3)
|
||||
{
|
||||
fullScreenAppInfo_.name = "KeyboardHeightChangeTest03";
|
||||
const sptr<Window>& window1 = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
ASSERT_NE(nullptr, window1);
|
||||
window1->RegisterOccupiedAreaChangeListener(testOccupiedAreaChangeListener_);
|
||||
|
||||
imeAppInfo_.name = "imeWindow3";
|
||||
imeAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& window2 = utils::CreateTestWindow(imeAppInfo_);
|
||||
ASSERT_NE(nullptr, window2);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, window2->SetCallingWindow(window1->GetWindowId()));
|
||||
ASSERT_EQ(WMError::WM_OK, window2->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, window2->Destroy());
|
||||
// Await 100ms and get callback result in listener.
|
||||
usleep(WAIT_ASYNC_US);
|
||||
ASSERT_EQ(testOccupiedAreaChangeListener_->rect_.posX_, 0);
|
||||
ASSERT_EQ(testOccupiedAreaChangeListener_->rect_.posY_, 0);
|
||||
ASSERT_EQ(testOccupiedAreaChangeListener_->rect_.width_, 0);
|
||||
ASSERT_EQ(testOccupiedAreaChangeListener_->rect_.height_, 0);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
@@ -803,6 +803,305 @@ HWTEST_F(WindowImplTest, StartMove03, Function | SmallTest | Level3)
|
||||
window->StartMove();
|
||||
ASSERT_FALSE(window->startMoveFlag_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetBackgroundColor01
|
||||
* @tc.desc: test SetBackgroundColor withow uiContent
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, SetBackgroundColor01, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("SetBackgroundColor01");
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
window->Show();
|
||||
ASSERT_FALSE(window->IsTransparent());
|
||||
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetBackgroundColor("#000"));
|
||||
ASSERT_FALSE(window->IsTransparent());
|
||||
ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, window->SetBackgroundColor("#00FF00"));
|
||||
ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, window->SetBackgroundColor("#FF00FF00"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetTurnScreenOn01
|
||||
* @tc.desc: create window but not show, test SetTurnScreenOn
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, SetTurnScreenOn01, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_SetTurnScreenOn01");
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
ASSERT_FALSE(window->IsTurnScreenOn());
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetTurnScreenOn(true));
|
||||
ASSERT_TRUE(window->IsTurnScreenOn());
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetTurnScreenOn(false));
|
||||
ASSERT_FALSE(window->IsTurnScreenOn());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @tc.name: SetTurnScreenOn02
|
||||
* @tc.desc: create window with show, test SetTurnScreenOn
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, SetTurnScreenOn02, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_SetTurnScreenOn02");
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_FALSE(window->IsTurnScreenOn());
|
||||
EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(2).WillOnce(Return(WMError::WM_OK))
|
||||
.WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetTurnScreenOn(true));
|
||||
ASSERT_TRUE(window->IsTurnScreenOn());
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetTurnScreenOn(false));
|
||||
ASSERT_FALSE(window->IsTurnScreenOn());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetKeepScreenOn01
|
||||
* @tc.desc: create window but not show, test SetKeepScreenOn
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, SetKeepScreenOn01, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_SetKeepScreenOn01");
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
ASSERT_FALSE(window->IsKeepScreenOn());
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetKeepScreenOn(true));
|
||||
ASSERT_TRUE(window->IsKeepScreenOn());
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetKeepScreenOn(false));
|
||||
ASSERT_FALSE(window->IsKeepScreenOn());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetKeepScreenOn02
|
||||
* @tc.desc: create window with show, test SetKeepScreenOn
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, SetKeepScreenOn02, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_SetKeepScreenOn02");
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_FALSE(window->IsKeepScreenOn());
|
||||
EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(2).WillOnce(Return(WMError::WM_OK))
|
||||
.WillOnce(Return(WMError::WM_OK));;
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetKeepScreenOn(true));
|
||||
ASSERT_TRUE(window->IsKeepScreenOn());
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetKeepScreenOn(false));
|
||||
ASSERT_FALSE(window->IsKeepScreenOn());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetBrightness01
|
||||
* @tc.desc: test SetBrightness with invalid brightness
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, SetBrightness01, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_SetBrightness01");
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(UNDEFINED_BRIGHTNESS, window->GetBrightness());
|
||||
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetBrightness(2.0f)); // 2.0f: brightness
|
||||
ASSERT_EQ(UNDEFINED_BRIGHTNESS, window->GetBrightness());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetBrightness02
|
||||
* @tc.desc: test SetBrightness with valid brightness
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, SetBrightness02, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_SetBrightness02");
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(UNDEFINED_BRIGHTNESS, window->GetBrightness());
|
||||
EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(2).WillOnce(Return(WMError::WM_OK))
|
||||
.WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetBrightness(MAXIMUM_BRIGHTNESS));
|
||||
ASSERT_EQ(MAXIMUM_BRIGHTNESS, window->GetBrightness());
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetBrightness(MINIMUM_BRIGHTNESS));
|
||||
ASSERT_EQ(MINIMUM_BRIGHTNESS, window->GetBrightness());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetBrightness03
|
||||
* @tc.desc: test SetBrightness with invalid type window
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, SetBrightness03, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_SetBrightness03");
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_STATUS_BAR);
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(UNDEFINED_BRIGHTNESS, window->GetBrightness());
|
||||
ASSERT_EQ(WMError::WM_ERROR_INVALID_TYPE, window->SetBrightness(MAXIMUM_BRIGHTNESS));
|
||||
ASSERT_EQ(UNDEFINED_BRIGHTNESS, window->GetBrightness());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetFocusable01
|
||||
* @tc.desc: create window but not show, test SetFocusable
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, SetFocusable01, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_SetFocusable01");
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
ASSERT_TRUE(window->GetFocusable());
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetFocusable(false));
|
||||
ASSERT_FALSE(window->GetFocusable());
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetFocusable(true));
|
||||
ASSERT_TRUE(window->GetFocusable());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetFocusable02
|
||||
* @tc.desc: create window with show, test SetFocusable
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, SetFocusable02, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_SetFocusable02");
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_TRUE(window->GetFocusable());
|
||||
EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(2).WillOnce(Return(WMError::WM_OK))
|
||||
.WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetFocusable(false));
|
||||
ASSERT_FALSE(window->GetFocusable());
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetFocusable(true));
|
||||
ASSERT_TRUE(window->GetFocusable());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetTouchable01
|
||||
* @tc.desc: create window but not show, test SetTouchable
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, SetTouchable01, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_SetTouchable01");
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
ASSERT_TRUE(window->GetTouchable());
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetTouchable(false));
|
||||
ASSERT_FALSE(window->GetTouchable());
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetTouchable(true));
|
||||
ASSERT_TRUE(window->GetTouchable());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SetTouchable02
|
||||
* @tc.desc: create window with show, test SetTouchable
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowImplTest, SetTouchable02, Function | SmallTest | Level3)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowName("WindowImplTest_SetTouchable02");
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_TRUE(window->GetTouchable());
|
||||
EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(2).WillOnce(Return(WMError::WM_OK))
|
||||
.WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetTouchable(false));
|
||||
ASSERT_FALSE(window->GetTouchable());
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetTouchable(true));
|
||||
ASSERT_TRUE(window->GetTouchable());
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -72,7 +72,6 @@ WMError WindowController::AddWindowNode(sptr<WindowProperty>& property)
|
||||
windowRoot_->FocusFaultDetection();
|
||||
FlushWindowInfo(property->GetWindowId());
|
||||
HandleTurnScreenOn(node);
|
||||
windowRoot_->HandleKeepScreenOn(node->GetWindowId(), node->IsKeepScreenOn());
|
||||
|
||||
if (node->GetWindowType() == WindowType::WINDOW_TYPE_STATUS_BAR ||
|
||||
node->GetWindowType() == WindowType::WINDOW_TYPE_NAVIGATION_BAR) {
|
||||
@@ -144,7 +143,6 @@ WMError WindowController::RemoveWindowNode(uint32_t windowId)
|
||||
}
|
||||
windowRoot_->FocusFaultDetection();
|
||||
FlushWindowInfo(windowId);
|
||||
windowRoot_->HandleKeepScreenOn(windowId, false);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -161,7 +159,6 @@ WMError WindowController::DestroyWindow(uint32_t windowId, bool onlySelf)
|
||||
}
|
||||
windowRoot_->FocusFaultDetection();
|
||||
FlushWindowInfoWithDisplayId(displayId);
|
||||
windowRoot_->HandleKeepScreenOn(windowId, false);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -229,6 +229,7 @@ WMError WindowRoot::AddWindowNode(uint32_t parentId, sptr<WindowNode>& node)
|
||||
if (res == WMError::WM_OK) {
|
||||
container->SetActiveWindow(node->GetWindowId(), false);
|
||||
NotifyKeyboardSizeChangeInfo(node, container, node->GetWindowRect());
|
||||
HandleKeepScreenOn(node->GetWindowId(), node->IsKeepScreenOn());
|
||||
}
|
||||
WLOGFI("windowId:%{public}u, name:%{public}s, orientation:%{public}u, type:%{public}u, isMainWindow:%{public}d",
|
||||
node->GetWindowId(), node->GetWindowName().c_str(), static_cast<uint32_t>(node->GetRequestedOrientation()),
|
||||
@@ -261,6 +262,7 @@ WMError WindowRoot::RemoveWindowNode(uint32_t windowId)
|
||||
if (res == WMError::WM_OK) {
|
||||
Rect rect = { 0, 0, 0, 0 };
|
||||
NotifyKeyboardSizeChangeInfo(node, container, rect);
|
||||
HandleKeepScreenOn(windowId, false);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -393,6 +395,7 @@ WMError WindowRoot::DestroyWindow(uint32_t windowId, bool onlySelf)
|
||||
UpdateFocusWindowWithWindowRemoved(node, container);
|
||||
UpdateActiveWindowWithWindowRemoved(node, container);
|
||||
UpdateBrightnessWithWindowRemoved(windowId, container);
|
||||
HandleKeepScreenOn(windowId, false);
|
||||
if (onlySelf) {
|
||||
for (auto& child : node->children_) {
|
||||
child->parent_ = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user