mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
Add camera floating window type and test
Signed-off-by: qianlf <qianliangfang@huawei.com> Change-Id: I272890078a0aad4abdb585202753df586c94097a
This commit is contained in:
@@ -59,6 +59,7 @@ enum class WindowType : uint32_t {
|
||||
WINDOW_TYPE_BOOT_ANIMATION,
|
||||
WINDOW_TYPE_FREEZE_DISPLAY,
|
||||
WINDOW_TYPE_VOICE_INTERACTION,
|
||||
WINDOW_TYPE_FLOAT_CAMERA,
|
||||
ABOVE_APP_SYSTEM_WINDOW_END,
|
||||
SYSTEM_WINDOW_END = ABOVE_APP_SYSTEM_WINDOW_END,
|
||||
};
|
||||
|
||||
@@ -166,7 +166,7 @@ static void CreateSystemWindowTask(void* contextPtr, std::string windowName, Win
|
||||
WLOGFE("[NAPI]Context is nullptr");
|
||||
return;
|
||||
}
|
||||
if (winType == WindowType::WINDOW_TYPE_FLOAT) {
|
||||
if (winType == WindowType::WINDOW_TYPE_FLOAT || winType == WindowType::WINDOW_TYPE_FLOAT_CAMERA) {
|
||||
auto abilityContext = Context::ConvertTo<AbilityRuntime::AbilityContext>(context->lock());
|
||||
if (abilityContext != nullptr) {
|
||||
if (!CheckCallingPermission("ohos.permission.SYSTEM_FLOAT_WINDOW")) {
|
||||
@@ -538,7 +538,7 @@ NativeValue* JsWindowManager::OnSetWindowLayoutMode(NativeEngine& engine, Native
|
||||
if (winLayoutMode != WindowLayoutMode::CASCADE && winLayoutMode != WindowLayoutMode::TILE) {
|
||||
errCode = WMError::WM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
|
||||
WLOGFI("[NAPI]LayoutMode = %{public}u, err = %{public}d", winLayoutMode, errCode);
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[=](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
|
||||
@@ -62,6 +62,8 @@ NativeValue* WindowTypeInit(NativeEngine* engine)
|
||||
static_cast<int32_t>(ApiWindowType::TYPE_NAVIGATION_BAR)));
|
||||
object->SetProperty("TYPE_FLOAT", CreateJsValue(*engine,
|
||||
static_cast<int32_t>(ApiWindowType::TYPE_FLOAT)));
|
||||
object->SetProperty("TYPE_FLOAT_CAMERA", CreateJsValue(*engine,
|
||||
static_cast<int32_t>(ApiWindowType::TYPE_FLOAT_CAMERA)));
|
||||
object->SetProperty("TYPE_WALLPAPER", CreateJsValue(*engine,
|
||||
static_cast<int32_t>(ApiWindowType::TYPE_WALLPAPER)));
|
||||
object->SetProperty("TYPE_DESKTOP", CreateJsValue(*engine,
|
||||
|
||||
@@ -44,7 +44,8 @@ enum class ApiWindowType : uint32_t {
|
||||
TYPE_LAUNCHER_DOCK,
|
||||
TYPE_VOICE_INTERACTION,
|
||||
TYPE_POINTER,
|
||||
TYPE_END = TYPE_POINTER,
|
||||
TYPE_FLOAT_CAMERA,
|
||||
TYPE_END = TYPE_FLOAT_CAMERA,
|
||||
};
|
||||
|
||||
enum class LifeCycleEventType : uint32_t {
|
||||
@@ -64,6 +65,7 @@ const std::map<WindowType, ApiWindowType> NATIVE_JS_TO_WINDOW_TYPE_MAP {
|
||||
{ WindowType::WINDOW_TYPE_VOLUME_OVERLAY, ApiWindowType::TYPE_VOLUME_OVERLAY },
|
||||
{ WindowType::WINDOW_TYPE_NAVIGATION_BAR, ApiWindowType::TYPE_NAVIGATION_BAR },
|
||||
{ WindowType::WINDOW_TYPE_FLOAT, ApiWindowType::TYPE_FLOAT },
|
||||
{ WindowType::WINDOW_TYPE_FLOAT_CAMERA, ApiWindowType::TYPE_FLOAT_CAMERA },
|
||||
{ WindowType::WINDOW_TYPE_WALLPAPER, ApiWindowType::TYPE_WALLPAPER },
|
||||
{ WindowType::WINDOW_TYPE_DESKTOP, ApiWindowType::TYPE_DESKTOP },
|
||||
{ WindowType::WINDOW_TYPE_LAUNCHER_RECENT, ApiWindowType::TYPE_LAUNCHER_RECENT },
|
||||
@@ -82,6 +84,7 @@ const std::map<ApiWindowType, WindowType> JS_TO_NATIVE_WINDOW_TYPE_MAP {
|
||||
{ ApiWindowType::TYPE_VOLUME_OVERLAY, WindowType::WINDOW_TYPE_VOLUME_OVERLAY },
|
||||
{ ApiWindowType::TYPE_NAVIGATION_BAR, WindowType::WINDOW_TYPE_NAVIGATION_BAR },
|
||||
{ ApiWindowType::TYPE_FLOAT, WindowType::WINDOW_TYPE_FLOAT },
|
||||
{ ApiWindowType::TYPE_FLOAT_CAMERA, WindowType::WINDOW_TYPE_FLOAT_CAMERA },
|
||||
{ ApiWindowType::TYPE_WALLPAPER, WindowType::WINDOW_TYPE_WALLPAPER },
|
||||
{ ApiWindowType::TYPE_DESKTOP, WindowType::WINDOW_TYPE_DESKTOP },
|
||||
{ ApiWindowType::TYPE_LAUNCHER_RECENT, WindowType::WINDOW_TYPE_LAUNCHER_RECENT },
|
||||
|
||||
@@ -39,6 +39,11 @@ public:
|
||||
return (IsMainWindow(type) || IsSubWindow(type));
|
||||
}
|
||||
|
||||
static inline bool IsAppFloatingWindow(WindowType type)
|
||||
{
|
||||
return (type == WindowType::WINDOW_TYPE_FLOAT) || (type == WindowType::WINDOW_TYPE_FLOAT_CAMERA);
|
||||
}
|
||||
|
||||
static inline bool IsBelowSystemWindow(WindowType type)
|
||||
{
|
||||
return (type >= WindowType::BELOW_APP_SYSTEM_WINDOW_BASE && type < WindowType::BELOW_APP_SYSTEM_WINDOW_END);
|
||||
|
||||
@@ -313,6 +313,7 @@ private:
|
||||
void UpdatePointerEventForStretchableWindow(std::shared_ptr<MMI::PointerEvent>& pointerEvent);
|
||||
void UpdateDragType();
|
||||
void InitListenerHandler();
|
||||
bool CheckCameraFloatingWindowMultiCreated(WindowType type);
|
||||
|
||||
// colorspace, gamut
|
||||
using ColorSpaceConvertMap = struct {
|
||||
|
||||
+26
-3
@@ -625,7 +625,7 @@ WMError WindowImpl::SetFullScreen(bool status)
|
||||
|
||||
void WindowImpl::MapFloatingWindowToAppIfNeeded()
|
||||
{
|
||||
if (GetType() != WindowType::WINDOW_TYPE_FLOAT || context_.get() == nullptr) {
|
||||
if (!WindowHelper::IsAppFloatingWindow(GetType()) || context_.get() == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -634,7 +634,8 @@ void WindowImpl::MapFloatingWindowToAppIfNeeded()
|
||||
if (win->GetType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW &&
|
||||
context_.get() == win->GetContext().get()) {
|
||||
appFloatingWindowMap_[win->GetWindowId()].push_back(this);
|
||||
WLOGFI("Map FloatingWindow %{public}u to AppMainWindow %{public}u", GetWindowId(), win->GetWindowId());
|
||||
WLOGFI("Map FloatingWindow %{public}u to AppMainWindow %{public}u, type is %{public}u",
|
||||
GetWindowId(), win->GetWindowId(), GetType());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -663,6 +664,12 @@ WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr<
|
||||
property_->SetParentId(parentId);
|
||||
}
|
||||
}
|
||||
|
||||
if (CheckCameraFloatingWindowMultiCreated(property_->GetWindowType())) {
|
||||
WLOGFE("Camera Floating Window already exists.");
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
|
||||
context_ = context;
|
||||
sptr<WindowImpl> window(this);
|
||||
sptr<IWindow> windowAgent(new WindowAgent(window));
|
||||
@@ -723,7 +730,8 @@ void WindowImpl::DestroyFloatingWindow()
|
||||
|
||||
// Destroy app floating window if exist
|
||||
if (appFloatingWindowMap_.count(GetWindowId()) > 0) {
|
||||
for (auto& floatingWindow : appFloatingWindowMap_.at(GetWindowId())) {
|
||||
auto floatingWindows = appFloatingWindowMap_.at(GetWindowId());
|
||||
for (auto& floatingWindow : floatingWindows) {
|
||||
if (floatingWindow == nullptr) {
|
||||
continue;
|
||||
}
|
||||
@@ -2243,6 +2251,7 @@ void WindowImpl::SetDefaultOption()
|
||||
}
|
||||
case WindowType::WINDOW_TYPE_TOAST:
|
||||
case WindowType::WINDOW_TYPE_FLOAT:
|
||||
case WindowType::WINDOW_TYPE_FLOAT_CAMERA:
|
||||
case WindowType::WINDOW_TYPE_VOICE_INTERACTION:
|
||||
case WindowType::WINDOW_TYPE_LAUNCHER_DOCK:
|
||||
case WindowType::WINDOW_TYPE_SEARCHING_BAR: {
|
||||
@@ -2320,5 +2329,19 @@ void WindowImpl::GetRequestedTouchHotAreas(std::vector<Rect>& rects) const
|
||||
{
|
||||
property_->GetTouchHotAreas(rects);
|
||||
}
|
||||
|
||||
bool WindowImpl::CheckCameraFloatingWindowMultiCreated(WindowType type)
|
||||
{
|
||||
if (type != WindowType::WINDOW_TYPE_FLOAT_CAMERA) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto& winPair : windowMap_) {
|
||||
if (winPair.second.second->GetType() == WindowType::WINDOW_TYPE_FLOAT_CAMERA) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -20,6 +20,7 @@ group("systemtest") {
|
||||
testonly = true
|
||||
|
||||
deps = [
|
||||
":wm_window_app_floating_window_test",
|
||||
":wm_window_drag_test",
|
||||
":wm_window_effect_test",
|
||||
":wm_window_focus_test",
|
||||
@@ -243,6 +244,17 @@ ohos_systemtest("wm_window_mode_support_info_test") {
|
||||
|
||||
## SystemTest wm_window_mode_support_info_test }}}
|
||||
|
||||
## SystemTest wm_window_app_floating_window_test {{{
|
||||
ohos_systemtest("wm_window_app_floating_window_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
sources = [ "window_app_floating_window_test.cpp" ]
|
||||
|
||||
deps = [ ":wm_systemtest_common" ]
|
||||
}
|
||||
|
||||
## SystemTest wm_window_app_floating_window_test }}}
|
||||
|
||||
## Build wm_systemtest_common.a {{{
|
||||
config("wm_systemtest_common_public_config") {
|
||||
include_dirs = [
|
||||
@@ -307,6 +319,7 @@ ohos_static_library("wm_systemtest_common") {
|
||||
"ability_base:base",
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:ability_context_native",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
* Copyright (c) 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 "ability_context_impl.h"
|
||||
#include "window.h"
|
||||
#include "window_option.h"
|
||||
#include "window_scene.h"
|
||||
#include "window_test_utils.h"
|
||||
#include "wm_common.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class WindowAppFloatingWindowTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
static inline float virtualPixelRatio_ = 1.0;
|
||||
static inline std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext_ = nullptr;
|
||||
};
|
||||
|
||||
void WindowAppFloatingWindowTest::SetUpTestCase()
|
||||
{
|
||||
auto display = DisplayManager::GetInstance().GetDisplayById(0);
|
||||
ASSERT_TRUE((display != nullptr));
|
||||
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
|
||||
WindowTestUtils::InitByDisplayRect(displayRect);
|
||||
virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0);
|
||||
}
|
||||
|
||||
void WindowAppFloatingWindowTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowAppFloatingWindowTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowAppFloatingWindowTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
static sptr<WindowScene> CreateWindowScene()
|
||||
{
|
||||
sptr<IWindowLifeCycle> listener = nullptr;
|
||||
WindowAppFloatingWindowTest::abilityContext_ = std::make_shared<AbilityRuntime::AbilityContextImpl>();
|
||||
|
||||
sptr<WindowScene> scene = new WindowScene();
|
||||
scene->Init(0, WindowAppFloatingWindowTest::abilityContext_, listener);
|
||||
return scene;
|
||||
}
|
||||
|
||||
static sptr<Window> CreateAppFloatingWindow(WindowType type, Rect rect, std::string name = "")
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetWindowType(type);
|
||||
option->SetWindowRect(rect);
|
||||
|
||||
static int cnt = 0;
|
||||
std::string winName = (name == "") ? "FloatingWindowTest" + std::to_string(cnt++) : name;
|
||||
|
||||
return Window::Create(winName, option, WindowAppFloatingWindowTest::abilityContext_);
|
||||
}
|
||||
|
||||
static inline Rect GetRectWithVpr(int32_t x, int32_t y, uint32_t w, uint32_t h)
|
||||
{
|
||||
auto vpr = WindowAppFloatingWindowTest::virtualPixelRatio_;
|
||||
return {x, y, static_cast<uint32_t>(w * vpr), static_cast<uint32_t>(h * vpr)};
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppFloatingWindow01
|
||||
* @tc.desc: AppFloatingWindow life cycle
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow01, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<WindowScene> scene = CreateWindowScene();
|
||||
ASSERT_NE(nullptr, scene);
|
||||
|
||||
Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600);
|
||||
sptr<Window> fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT, fltWindRect);
|
||||
ASSERT_NE(nullptr, fltWin);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Show());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Hide());
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Destroy());
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppFloatingWindow02
|
||||
* @tc.desc: AppFloatingWindow life cycle, main window hide first
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow02, Function | MediumTest | Level3)
|
||||
{
|
||||
sptr<WindowScene> scene = CreateWindowScene();
|
||||
ASSERT_NE(nullptr, scene);
|
||||
|
||||
Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600);
|
||||
sptr<Window> fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT, fltWindRect);
|
||||
ASSERT_NE(nullptr, fltWin);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Show());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
|
||||
ASSERT_EQ(false, scene->GetMainWindow()->GetShowState());
|
||||
ASSERT_EQ(true, fltWin->GetShowState());
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Hide());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Destroy());
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppFloatingWindow03
|
||||
* @tc.desc: AppFloatingWindow life cycle, app floating window hide first
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow03, Function | MediumTest | Level3)
|
||||
{
|
||||
sptr<WindowScene> scene = CreateWindowScene();
|
||||
ASSERT_NE(nullptr, scene);
|
||||
|
||||
Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600);
|
||||
sptr<Window> fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT, fltWindRect);
|
||||
ASSERT_NE(nullptr, fltWin);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Show());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Hide());
|
||||
ASSERT_EQ(false, fltWin->GetShowState());
|
||||
ASSERT_EQ(true, scene->GetMainWindow()->GetShowState());
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Destroy());
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppFloatingWindow04
|
||||
* @tc.desc: AppFloatingWindow life cycle, main window destroy first
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow04, Function | MediumTest | Level3)
|
||||
{
|
||||
sptr<WindowScene> scene = CreateWindowScene();
|
||||
ASSERT_NE(nullptr, scene);
|
||||
|
||||
Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600);
|
||||
sptr<Window> fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT, fltWindRect);
|
||||
ASSERT_NE(nullptr, fltWin);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Show());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
|
||||
ASSERT_EQ(nullptr, scene->GetMainWindow());
|
||||
ASSERT_EQ(false, fltWin->GetShowState());
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Destroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppFloatingWindow05
|
||||
* @tc.desc: Camera AppFloatingWindow life cycle
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow05, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<WindowScene> scene = CreateWindowScene();
|
||||
ASSERT_NE(nullptr, scene);
|
||||
|
||||
Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600);
|
||||
sptr<Window> fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect);
|
||||
ASSERT_NE(nullptr, fltWin);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Show());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Hide());
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Destroy());
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppFloatingWindow06
|
||||
* @tc.desc: Camera AppFloatingWindow life cycle, main window hide first
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow06, Function | MediumTest | Level3)
|
||||
{
|
||||
sptr<WindowScene> scene = CreateWindowScene();
|
||||
ASSERT_NE(nullptr, scene);
|
||||
|
||||
Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600);
|
||||
sptr<Window> fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect);
|
||||
ASSERT_NE(nullptr, fltWin);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Show());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
|
||||
ASSERT_EQ(false, scene->GetMainWindow()->GetShowState());
|
||||
ASSERT_EQ(true, fltWin->GetShowState());
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Hide());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Destroy());
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppFloatingWindow07
|
||||
* @tc.desc: Camera AppFloatingWindow life cycle, app floating window hide first
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow07, Function | MediumTest | Level3)
|
||||
{
|
||||
sptr<WindowScene> scene = CreateWindowScene();
|
||||
ASSERT_NE(nullptr, scene);
|
||||
|
||||
Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600);
|
||||
sptr<Window> fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect);
|
||||
ASSERT_NE(nullptr, fltWin);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Show());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Hide());
|
||||
ASSERT_EQ(false, fltWin->GetShowState());
|
||||
ASSERT_EQ(true, scene->GetMainWindow()->GetShowState());
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoBackground());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Destroy());
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppFloatingWindow08
|
||||
* @tc.desc: Camera AppFloatingWindow life cycle, main window destroy first
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow08, Function | MediumTest | Level3)
|
||||
{
|
||||
sptr<WindowScene> scene = CreateWindowScene();
|
||||
ASSERT_NE(nullptr, scene);
|
||||
|
||||
Rect fltWindRect = GetRectWithVpr(0, 0, 400, 600);
|
||||
sptr<Window> fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect);
|
||||
ASSERT_NE(nullptr, fltWin);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Show());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
|
||||
ASSERT_EQ(nullptr, scene->GetMainWindow());
|
||||
ASSERT_EQ(false, fltWin->GetShowState());
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Destroy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppFloatingWindow09
|
||||
* @tc.desc: Camera AppFloatingWindow rect check
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowAppFloatingWindowTest, AppFloatingWindow09, Function | MediumTest | Level3)
|
||||
{
|
||||
sptr<WindowScene> scene = CreateWindowScene();
|
||||
ASSERT_NE(nullptr, scene);
|
||||
|
||||
Rect fltWindRect = GetRectWithVpr(10, 20, 10, 10);
|
||||
sptr<Window> fltWin = CreateAppFloatingWindow(WindowType::WINDOW_TYPE_FLOAT_CAMERA, fltWindRect);
|
||||
ASSERT_NE(nullptr, fltWin);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Show());
|
||||
|
||||
Rect exceptRect = WindowTestUtils::GetFloatingLimitedRect(fltWindRect, virtualPixelRatio_);
|
||||
ASSERT_TRUE(WindowTestUtils::RectEqualTo(fltWin, exceptRect));
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fltWin->Destroy());
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoDestroy());
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
@@ -52,6 +52,7 @@ private:
|
||||
{ WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW, 106 },
|
||||
{ WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, 107 },
|
||||
{ WindowType::WINDOW_TYPE_FLOAT, 108 },
|
||||
{ WindowType::WINDOW_TYPE_FLOAT_CAMERA, 108 },
|
||||
{ WindowType::WINDOW_TYPE_TOAST, 109 },
|
||||
{ WindowType::WINDOW_TYPE_STATUS_BAR, 110 },
|
||||
{ WindowType::WINDOW_TYPE_PANEL, 111 },
|
||||
|
||||
@@ -678,7 +678,8 @@ void WindowLayoutPolicy::UpdateFloatingWindowSizeBySystemLimits(const sptr<Windo
|
||||
GetSystemLimitsConfig(displayRect, GetVirtualPixelRatio(node->GetDisplayId()));
|
||||
|
||||
// limit minimum size of floating (not system type) window
|
||||
if (!WindowHelper::IsSystemWindow(node->GetWindowType())) {
|
||||
if (!WindowHelper::IsSystemWindow(node->GetWindowType()) ||
|
||||
node->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT_CAMERA) {
|
||||
winRect.width_ = std::max(systemLimits.minWidth_, winRect.width_);
|
||||
winRect.height_ = std::max(systemLimits.minHeight_, winRect.height_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user