diff --git a/build/gn/BUILD.gn b/build/gn/BUILD.gn index d782a58a074f36225c92cca9e2539253b81b7c4c..46a17c9c2c782787ae7dc443174554f315113126 100644 --- a/build/gn/BUILD.gn +++ b/build/gn/BUILD.gn @@ -43,8 +43,6 @@ group("ft_test") { "//display_server/rosen/modules/render_service_client/test/ft_build:render_service_client_gravity_demo", "//display_server/drivers/hal/test:gpu_backend_test", - "//window_manager/test/ft_build:wms_window_subwindow_test", - "//window_manager/test/ft_build:wms_window_move_test", - "//window_manager/test/ft_build:wms_window_scale_test", + "//window_manager/test/ft_build:wm_test", ] } diff --git a/window_manager/test/ft_build/BUILD.gn b/window_manager/test/ft_build/BUILD.gn index 563a5f9475605a2947e494edde7f88d749214668..d9f29c5d23ce373908712821ea1ae22a02dd3e8e 100644 --- a/window_manager/test/ft_build/BUILD.gn +++ b/window_manager/test/ft_build/BUILD.gn @@ -14,43 +14,20 @@ import("//build/gn/fangtian.gni") import("//config.gni") -ft_executable("wms_window_subwindow_test") { - sources = [ "window_subwindow_test.cpp" ] - - libs = [ "gtest" ] - - deps = [ - "$window_manager_path/wm/ft_build:libwm", - "$window_manager_path/utils/ft_build:libwmutil", - "$window_manager_path/dm/ft_build:libdm", - "$display_server_root/rosen/modules/render_service_client/ft_build:librender_service_client", - "//build/gn/configs/system_libs:image", +ft_executable("wm_test") { + sources = [ + "main.cpp", + "window_move_test.cpp", + "window_scale_test.cpp", + "window_subwindow_test.cpp", ] -} - -ft_executable("wms_window_move_test") { - sources = [ "window_move_test.cpp" ] libs = [ "gtest" ] deps = [ - "$window_manager_path/wm/ft_build:libwm", - "$window_manager_path/utils/ft_build:libwmutil", "$window_manager_path/dm/ft_build:libdm", - "$display_server_root/rosen/modules/render_service_client/ft_build:librender_service_client", - "//build/gn/configs/system_libs:image", - ] -} - -ft_executable("wms_window_scale_test") { - sources = [ "window_scale_test.cpp" ] - - libs = [ "gtest" ] - - deps = [ - "$window_manager_path/wm/ft_build:libwm", "$window_manager_path/utils/ft_build:libwmutil", - "$window_manager_path/dm/ft_build:libdm", + "$window_manager_path/wm/ft_build:libwm", "$display_server_root/rosen/modules/render_service_client/ft_build:librender_service_client", "//build/gn/configs/system_libs:image", ] diff --git a/window_manager/test/ft_build/main.cpp b/window_manager/test/ft_build/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9e490355ffcd277f21866dd9ba14ce9a814067fd --- /dev/null +++ b/window_manager/test/ft_build/main.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023 Huawei Technologies 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. + */ + +#include + +int main(int argc, char *argv[]) { + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} \ No newline at end of file diff --git a/window_manager/test/ft_build/window_move_test.cpp b/window_manager/test/ft_build/window_move_test.cpp index 7c9c49750ec56ca6ceecc83589b86c5a542456ca..807b7eb96ae5847326aeff1819a28d9f6cf39a14 100644 --- a/window_manager/test/ft_build/window_move_test.cpp +++ b/window_manager/test/ft_build/window_move_test.cpp @@ -18,22 +18,15 @@ #include "window_option.h" #include "wm_common.h" -namespace OHOS { -namespace Rosen { +using namespace OHOS; +using namespace OHOS::Rosen; + class WindowMoveTest : public testing::Test { public: - virtual void SetUp() override; - virtual void TearDown() override; + virtual void SetUp() override {} + virtual void TearDown() override {} }; -void WindowMoveTest::SetUp() -{ -} - -void WindowMoveTest::TearDown() -{ -} - static sptr CreateWindow(WindowMode mode) { sptr mainOption(new WindowOption()); @@ -45,6 +38,15 @@ static sptr CreateWindow(WindowMode mode) return Window::Create("window", mainOption); } + +class WindowMoveTestListener : public IWindowChangeListener { +public: + void OnSizeChange(Rect rect, WindowSizeChangeReason reason) override { + ASSERT_EQ(100, rect.posX_); + ASSERT_EQ(100, rect.posY_); + } +}; + /** * @tc.name: Move01 * @tc.desc: Floating Window @@ -55,9 +57,11 @@ TEST_F(WindowMoveTest, Move01) sptr window = CreateWindow(WindowMode::WINDOW_MODE_FLOATING); ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WMError::WM_OK, window->MoveTo(100, 100)); - ASSERT_EQ(100, window->GetRequestRect().posX_); - ASSERT_EQ(100, window->GetRequestRect().posY_); + sptr listener = new WindowMoveTestListener(); + ASSERT_EQ(true, window->RegisterWindowChangeListener(listener)); + + window->MoveTo(100, 100); + sleep(1); ASSERT_EQ(WMError::WM_OK, window->Hide()); sleep(1); @@ -82,82 +86,3 @@ TEST_F(WindowMoveTest, Move02) window->Destroy(); } - -/** - * @tc.name: Move03 - * @tc.desc: Undefined Window - * @tc.type: FUNC - */ -TEST_F(WindowMoveTest, Move03) -{ - sptr window = CreateWindow(WindowMode::WINDOW_MODE_UNDEFINED); - ASSERT_EQ(WMError::WM_OK, window->Show()); - - ASSERT_NE(WMError::WM_OK, window->MoveTo(100, 100)); - - ASSERT_EQ(WMError::WM_OK, window->Hide()); - sleep(1); - - window->Destroy(); -} - -/** - * @tc.name: Move04 - * @tc.desc: Pip Window - * @tc.type: FUNC - */ -TEST_F(WindowMoveTest, Move04) -{ - sptr window = CreateWindow(WindowMode::WINDOW_MODE_PIP); - ASSERT_EQ(WMError::WM_OK, window->Show()); - - ASSERT_NE(WMError::WM_OK, window->MoveTo(100, 100)); - - ASSERT_EQ(WMError::WM_OK, window->Hide()); - sleep(1); - - window->Destroy(); -} - -/** - * @tc.name: Move05 - * @tc.desc: Split Primary Window - * @tc.type: FUNC - */ -TEST_F(WindowMoveTest, Move05) -{ - sptr window = CreateWindow(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); - ASSERT_EQ(WMError::WM_OK, window->Show()); - - ASSERT_NE(WMError::WM_OK, window->MoveTo(100, 100)); - - ASSERT_EQ(WMError::WM_OK, window->Hide()); - sleep(1); - - window->Destroy(); -} - -/** - * @tc.name: Move06 - * @tc.desc: Split Secondary Window - * @tc.type: FUNC - */ -TEST_F(WindowMoveTest, Move06) -{ - sptr window = CreateWindow(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); - ASSERT_EQ(WMError::WM_OK, window->Show()); - - ASSERT_NE(WMError::WM_OK, window->MoveTo(100, 100)); - - ASSERT_EQ(WMError::WM_OK, window->Hide()); - sleep(1); - - window->Destroy(); -} -} // namespace Rosen -} // namespace OHOS - -int main(int argc, char *argv[]) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/window_manager/test/ft_build/window_scale_test.cpp b/window_manager/test/ft_build/window_scale_test.cpp index 53e830b6f51656ccd03714c3a570e8f9da40fb06..7fade7cdd896ee82813d4e07c932b924050fd6f7 100644 --- a/window_manager/test/ft_build/window_scale_test.cpp +++ b/window_manager/test/ft_build/window_scale_test.cpp @@ -18,22 +18,15 @@ #include "window_option.h" #include "wm_common.h" -namespace OHOS { -namespace Rosen { +using namespace OHOS; +using namespace OHOS::Rosen; + class WindowScaleTest : public testing::Test { public: - virtual void SetUp() override; - virtual void TearDown() override; + virtual void SetUp() override {} + virtual void TearDown() override {} }; -void WindowScaleTest::SetUp() -{ -} - -void WindowScaleTest::TearDown() -{ -} - static sptr CreateWindow(WindowMode mode) { sptr mainOption(new WindowOption()); @@ -45,6 +38,15 @@ static sptr CreateWindow(WindowMode mode) return Window::Create("window", mainOption); } +class WindowScaleTestListener : public IWindowChangeListener { +public: + void OnSizeChange(Rect rect, WindowSizeChangeReason reason) override { + // real Rect depends on hardware platform, thus can not use ASSERT_EQ + ASSERT_LE(rect.width_, 400); + ASSERT_LE(rect.height_, 400); + } +}; + /** * @tc.name: Resize01 * @tc.desc: Floating Window @@ -55,13 +57,11 @@ TEST_F(WindowScaleTest, Resize01) sptr window = CreateWindow(WindowMode::WINDOW_MODE_FLOATING); ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WMError::WM_OK, window->Resize(300, 300)); - ASSERT_EQ(300, window->GetRequestRect().width_); - ASSERT_EQ(300, window->GetRequestRect().height_); + sptr listener = new WindowScaleTestListener(); + ASSERT_EQ(true, window->RegisterWindowChangeListener(listener)); - ASSERT_EQ(WMError::WM_OK, window->Resize(30, 30)); - ASSERT_EQ(30, window->GetRequestRect().width_); - ASSERT_EQ(30, window->GetRequestRect().height_); + ASSERT_EQ(WMError::WM_OK, window->Resize(300, 300)); + sleep(1); ASSERT_EQ(WMError::WM_OK, window->Hide()); sleep(1); @@ -86,111 +86,3 @@ TEST_F(WindowScaleTest, Resize02) window->Destroy(); } - -/** - * @tc.name: Resize03 - * @tc.desc: Undefined Window - * @tc.type: FUNC - */ -TEST_F(WindowScaleTest, Resize03) -{ - sptr window = CreateWindow(WindowMode::WINDOW_MODE_UNDEFINED); - ASSERT_EQ(WMError::WM_OK, window->Show()); - - ASSERT_NE(WMError::WM_OK, window->Resize(300, 300)); - - ASSERT_EQ(WMError::WM_OK, window->Hide()); - sleep(1); - - window->Destroy(); -} - -/** - * @tc.name: Resize04 - * @tc.desc: Pip Window - * @tc.type: FUNC - */ -TEST_F(WindowScaleTest, Resize04) -{ - sptr window = CreateWindow(WindowMode::WINDOW_MODE_PIP); - ASSERT_EQ(WMError::WM_OK, window->Show()); - - ASSERT_NE(WMError::WM_OK, window->Resize(300, 300)); - - ASSERT_EQ(WMError::WM_OK, window->Hide()); - sleep(1); - - window->Destroy(); -} - -/** - * @tc.name: Resize05 - * @tc.desc: Split Primary Window - * @tc.type: FUNC - */ -TEST_F(WindowScaleTest, Resize05) -{ - sptr window = CreateWindow(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); - ASSERT_EQ(WMError::WM_OK, window->Show()); - - ASSERT_NE(WMError::WM_OK, window->Resize(300, 300)); - - ASSERT_EQ(WMError::WM_OK, window->Hide()); - sleep(1); - - window->Destroy(); -} - -/** - * @tc.name: Resize06 - * @tc.desc: Split Secondary Window - * @tc.type: FUNC - */ -TEST_F(WindowScaleTest, Resize06) -{ - sptr window = CreateWindow(WindowMode::WINDOW_MODE_SPLIT_SECONDARY); - ASSERT_EQ(WMError::WM_OK, window->Show()); - - ASSERT_NE(WMError::WM_OK, window->Resize(300, 300)); - - ASSERT_EQ(WMError::WM_OK, window->Hide()); - sleep(1); - - window->Destroy(); -} - -/** - * @tc.name: Transform - * @tc.desc: Transform - * @tc.type: FUNC - */ -TEST_F(WindowScaleTest, Transform) -{ - sptr window = CreateWindow(WindowMode::WINDOW_MODE_FLOATING); - ASSERT_EQ(WMError::WM_OK, window->Show()); - - Transform trans; - trans.scaleX_ = 0.5f; - trans.scaleY_ = 0.5f; - window->SetTransform(trans); - ASSERT_EQ(0.5, window->GetTransform().scaleX_); - ASSERT_EQ(0.5, window->GetTransform().scaleY_); - - trans.scaleX_ = 2.0f; - trans.scaleY_ = 2.0f; - window->SetTransform(trans); - ASSERT_EQ(2.0, window->GetTransform().scaleX_); - ASSERT_EQ(2.0, window->GetTransform().scaleY_); - - ASSERT_EQ(WMError::WM_OK, window->Hide()); - sleep(1); - - window->Destroy(); -} -} // namespace Rosen -} // namespace OHOS - -int main(int argc, char *argv[]) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/window_manager/test/ft_build/window_subwindow_test.cpp b/window_manager/test/ft_build/window_subwindow_test.cpp index fbf82c204e9977d3628adbc22f3281f35dd62766..1f54b12219d6f0cfc915c728be04da132fb04b51 100644 --- a/window_manager/test/ft_build/window_subwindow_test.cpp +++ b/window_manager/test/ft_build/window_subwindow_test.cpp @@ -18,8 +18,9 @@ #include "window_option.h" #include "wm_common.h" -namespace OHOS { -namespace Rosen { +using namespace OHOS; +using namespace OHOS::Rosen; + class WindowSubWindowTest : public testing::Test { public: virtual void SetUp() override; @@ -37,21 +38,19 @@ void WindowSubWindowTest::TearDown() static sptr CreateMainWindow() { sptr mainOption(new WindowOption()); - mainOption->SetDisplayId(0); - mainOption->SetWindowTag(WindowTag::MAIN_WINDOW); + mainOption->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + mainOption->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); return Window::Create("main_window", mainOption); } static sptr CreateSubWindow(sptr mainWindow, WindowType type, - struct Rect rect, uint32_t flags, std::string name = "") + struct Rect rect, std::string name = "") { sptr subOp = new WindowOption(); subOp->SetWindowType(type); subOp->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); subOp->SetWindowRect(rect); - subOp->SetWindowFlags(flags); subOp->SetParentId(mainWindow->GetWindowId()); - subOp->SetWindowTag(WindowTag::SUB_WINDOW); static int cnt = 0; std::string subWinName = (name == "") ? "SubWindow" + std::to_string(cnt++) : name; @@ -68,8 +67,7 @@ TEST_F(WindowSubWindowTest, SubWindow01) sptr window = CreateMainWindow(); struct Rect rect = {0, 0, 100, 200}; - uint32_t flags = 0; - sptr subWindow = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); + sptr subWindow = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect); ASSERT_NE(nullptr, subWindow); ASSERT_EQ(WMError::WM_OK, window->Show()); @@ -85,124 +83,18 @@ TEST_F(WindowSubWindowTest, SubWindow01) /** * @tc.name: SubWindow02 - * @tc.desc: FullScreen Main Window + Floating SubWindow & Parent Limit work - * @tc.type: FUNC - */ -TEST_F(WindowSubWindowTest, SubWindow02) -{ - sptr window = CreateMainWindow(); - - struct Rect rect = {0, 0, 100, 200}; - uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); - sptr subWindow = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); - ASSERT_NE(nullptr, subWindow); - - ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WMError::WM_OK, subWindow->Show()); - - ASSERT_EQ(WMError::WM_OK, subWindow->Hide()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); - sleep(1); - - subWindow->Destroy(); - window->Destroy(); -} - -/** - * @tc.name: SubWindow03 - * @tc.desc: FullScreen Main Window + Floating MediaWindow - * @tc.type: FUNC - */ -TEST_F(WindowSubWindowTest, SubWindow03) -{ - sptr window = CreateMainWindow(); - - struct Rect rect = {0, 2000, 100, 200}; - uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); - sptr subWindow = CreateSubWindow(window, WindowType::WINDOW_TYPE_MEDIA, rect, flags); - ASSERT_NE(nullptr, subWindow); - - ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WMError::WM_OK, subWindow->Show()); - - ASSERT_EQ(WMError::WM_OK, subWindow->Hide()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); - sleep(1); - - subWindow->Destroy(); - window->Destroy(); -} - -/** - * @tc.name: SubWindow04 - * @tc.desc: FullScreen Main Window + Floating MediaWindow - * @tc.type: FUNC - */ -TEST_F(WindowSubWindowTest, SubWindow04) -{ - sptr window = CreateMainWindow(); - - struct Rect rect = {0, 2000, 3000, 2000}; - uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); - sptr subWindow = CreateSubWindow(window, WindowType::WINDOW_TYPE_MEDIA, rect, flags); - ASSERT_NE(nullptr, subWindow); - - ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WMError::WM_OK, subWindow->Show()); - - ASSERT_EQ(WMError::WM_OK, subWindow->Hide()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); - sleep(1); - - subWindow->Destroy(); - window->Destroy(); -} - -/** - * @tc.name: SubWindow05 - * @tc.desc: FullScreen Main Window + Floating MediaWindow + Floating SubWindow - * @tc.type: FUNC - */ -TEST_F(WindowSubWindowTest, SubWindow05) -{ - sptr window = CreateMainWindow(); - - struct Rect rect = {0, 0, 100, 200}; - uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); - sptr subWindow = CreateSubWindow(window, WindowType::WINDOW_TYPE_MEDIA, rect, flags); - ASSERT_NE(nullptr, subWindow); - - sptr subWindow2 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); - ASSERT_NE(nullptr, subWindow2); - - ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WMError::WM_OK, subWindow->Show()); - ASSERT_EQ(WMError::WM_OK, subWindow2->Show()); - - ASSERT_EQ(WMError::WM_OK, subWindow->Hide()); - ASSERT_EQ(WMError::WM_OK, subWindow2->Hide()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); - sleep(1); - - subWindow->Destroy(); - subWindow2->Destroy(); - window->Destroy(); -} - -/** - * @tc.name: SubWindow06 * @tc.desc: FullScreen Main Window + 2 SubWindows * @tc.type: FUNC */ -TEST_F(WindowSubWindowTest, SubWindow06) +TEST_F(WindowSubWindowTest, SubWindow02) { sptr window = CreateMainWindow(); struct Rect rect = {0, 0, 100, 200}; - sptr subWindow0 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); + sptr subWindow0 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect); ASSERT_NE(nullptr, subWindow0); - sptr subWindow1 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); + sptr subWindow1 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect); ASSERT_NE(nullptr, subWindow1); ASSERT_EQ(WMError::WM_OK, window->Show()); @@ -220,125 +112,28 @@ TEST_F(WindowSubWindowTest, SubWindow06) } /** - * @tc.name: SubWindow07 - * @tc.desc: FullScreen Main Window + Floating SubWindow & MainWindow First Hide - * @tc.type: FUNC - */ -TEST_F(WindowSubWindowTest, SubWindow07) -{ - sptr window = CreateMainWindow(); - - struct Rect rect = {0, 0, 100, 200}; - uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); - sptr subWindow = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); - ASSERT_NE(nullptr, subWindow); - - ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WMError::WM_OK, subWindow->Show()); - - ASSERT_EQ(WMError::WM_OK, window->Hide()); - ASSERT_EQ(WMError::WM_OK, subWindow->Hide()); - sleep(1); - - subWindow->Destroy(); - window->Destroy(); -} - -/** - * @tc.name: SubWindow08 - * @tc.desc: FullScreen Main Window + Floating SubWindow & only show SubWindow - * @tc.type: FUNC - */ -TEST_F(WindowSubWindowTest, SubWindow08) -{ - sptr window = CreateMainWindow(); - - struct Rect rect = {0, 0, 100, 200}; - uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); - sptr subWindow = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); - ASSERT_NE(nullptr, subWindow); - - ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, subWindow->Show()); - sleep(1); - - subWindow->Destroy(); - window->Destroy(); -} - -/** - * @tc.name: SubWindow09 - * @tc.desc: FullScreen Main Window + Floating SubWindow & first destroy SubWindow, then destroy MainWindow - * @tc.type: FUNC - */ -TEST_F(WindowSubWindowTest, SubWindow09) -{ - sptr window = CreateMainWindow(); - - struct Rect rect = {0, 0, 100, 200}; - uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); - sptr subWindow = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); - ASSERT_NE(nullptr, subWindow); - - ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WMError::WM_OK, subWindow->Show()); - - ASSERT_EQ(WMError::WM_OK, subWindow->Hide()); - ASSERT_EQ(WMError::WM_OK, window->Hide()); - sleep(1); - - ASSERT_EQ(WMError::WM_OK, subWindow->Destroy()); - - subWindow->Destroy(); - window->Destroy(); -} - -/** - * @tc.name: SubWindow10 - * @tc.desc: FullScreen Main Window + Floating SubWindow & first destroy MainWindow, then destroy SubWindow - * @tc.type: FUNC - */ -TEST_F(WindowSubWindowTest, SubWindow10) -{ - sptr window = CreateMainWindow(); - - struct Rect rect = {0, 0, 100, 200}; - uint32_t flags = static_cast(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); - sptr subWindow = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, flags); - ASSERT_NE(nullptr, subWindow); - - ASSERT_EQ(WMError::WM_OK, window->Show()); - ASSERT_EQ(WMError::WM_OK, subWindow->Show()); - sleep(1); - - ASSERT_EQ(WMError::WM_OK, window->Destroy()); - ASSERT_EQ(WMError::WM_OK, subWindow->Destroy()); - - window->Destroy(); -} - -/** - * @tc.name: SubWindow11 + * @tc.name: SubWindow03 * @tc.desc: FullScreen Main Window + 5 subWindows * @tc.type: FUNC */ -TEST_F(WindowSubWindowTest, SubWindow11) +TEST_F(WindowSubWindowTest, SubWindow03) { sptr window = CreateMainWindow(); struct Rect rect = {0, 0, 100, 200}; - sptr subWindow0 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); + sptr subWindow0 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect); ASSERT_NE(nullptr, subWindow0); - sptr subWindow1 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); + sptr subWindow1 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect); ASSERT_NE(nullptr, subWindow1); - sptr subWindow2 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); + sptr subWindow2 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect); ASSERT_NE(nullptr, subWindow2); - sptr subWindow3 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); + sptr subWindow3 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect); ASSERT_NE(nullptr, subWindow3); - sptr subWindow4 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0); + sptr subWindow4 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect); ASSERT_NE(nullptr, subWindow4); ASSERT_EQ(WMError::WM_OK, window->Show()); @@ -365,17 +160,17 @@ TEST_F(WindowSubWindowTest, SubWindow11) } /** - * @tc.name: SubWindow12 + * @tc.name: SubWindow04 * @tc.desc: FullScreen Main Window + 2 SubWindows with the same name * @tc.type: FUNC */ -TEST_F(WindowSubWindowTest, SubWindow12) +TEST_F(WindowSubWindowTest, SubWindow04) { sptr window = CreateMainWindow(); struct Rect rect = {0, 0, 100, 200}; - sptr subWindow0 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0, "sub0"); - sptr subWindow1 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0, "sub0"); + sptr subWindow0 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, "sub0"); + sptr subWindow1 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, "sub0"); ASSERT_NE(nullptr, subWindow0); ASSERT_EQ(nullptr, subWindow1); @@ -391,23 +186,23 @@ TEST_F(WindowSubWindowTest, SubWindow12) } /** - * @tc.name: SubWindow13 + * @tc.name: SubWindow05 * @tc.desc: FullScreen Main Window + 2 subwindows with the same name but one create after another destroyed * @tc.type: FUNC */ -TEST_F(WindowSubWindowTest, SubWindow13) +TEST_F(WindowSubWindowTest, SubWindow05) { sptr window = CreateMainWindow(); ASSERT_EQ(WMError::WM_OK, window->Show()); struct Rect rect = {0, 0, 100, 200}; - sptr subWindow0 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0, "sub1"); + sptr subWindow0 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, "sub1"); ASSERT_NE(nullptr, subWindow0); ASSERT_EQ(WMError::WM_OK, subWindow0->Show()); ASSERT_EQ(WMError::WM_OK, subWindow0->Destroy()); - sptr subWindow1 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, 0, "sub1"); + sptr subWindow1 = CreateSubWindow(window, WindowType::WINDOW_TYPE_APP_SUB_WINDOW, rect, "sub1"); ASSERT_NE(nullptr, subWindow1); ASSERT_EQ(WMError::WM_OK, subWindow1->Show()); ASSERT_EQ(WMError::WM_OK, subWindow1->Destroy()); @@ -416,10 +211,3 @@ TEST_F(WindowSubWindowTest, SubWindow13) sleep(1); window->Destroy(); } -} // namespace Rosen -} // namespace OHOS - -int main(int argc, char *argv[]) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -}