diff --git a/test/systemtest/wms/BUILD.gn b/test/systemtest/wms/BUILD.gn index cd7ca23880..963d796151 100644 --- a/test/systemtest/wms/BUILD.gn +++ b/test/systemtest/wms/BUILD.gn @@ -61,6 +61,7 @@ ohos_systemtest("wms_window_layout_test") { deps = [ ":wms_systemtest_common", "${window_base_path}/window_scene/common:window_scene_common", + "${window_base_path}/window_scene/session:scene_session", ] external_deps = [ diff --git a/test/systemtest/wms/window_layout_test.cpp b/test/systemtest/wms/window_layout_test.cpp index 0809042519..7d3eecc6d7 100644 --- a/test/systemtest/wms/window_layout_test.cpp +++ b/test/systemtest/wms/window_layout_test.cpp @@ -40,6 +40,7 @@ public: private: static constexpr uint32_t WAIT_SYANC_US = 100000; static void InitAvoidArea(); + std::shared_ptr abilityContext_; }; vector WindowLayoutTest::fullScreenExpecteds_; @@ -113,10 +114,12 @@ void WindowLayoutTest::TearDownTestCase() void WindowLayoutTest::SetUp() { activeWindows_.clear(); + abilityContext_ = std::make_shared(); } void WindowLayoutTest::TearDown() { + abilityContext_ = nullptr; } namespace { @@ -645,6 +648,7 @@ HWTEST_F(WindowLayoutTest, LayoutNegative02, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, moveWindowTo01, Function | MediumTest | Level3) { sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(option, nullptr); option->SetWindowName("moveWindowTo01"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); @@ -652,6 +656,16 @@ HWTEST_F(WindowLayoutTest, moveWindowTo01, Function | MediumTest | Level3) sptr window = new WindowSceneSessionImpl(option); ASSERT_NE(window, nullptr); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(session, nullptr); + + ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false)); + ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); + + window->property_->SetPersistentId(10001); + WMError ret = window->MoveTo(-500, -500); ASSERT_EQ(WMError::WM_OK, ret); @@ -673,6 +687,7 @@ HWTEST_F(WindowLayoutTest, moveWindowTo01, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, moveWindowTo02, Function | MediumTest | Level3) { sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(option, nullptr); option->SetWindowName("moveWindowTo02"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); option->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); @@ -680,6 +695,16 @@ HWTEST_F(WindowLayoutTest, moveWindowTo02, Function | MediumTest | Level3) sptr window = new WindowSceneSessionImpl(option); ASSERT_NE(window, nullptr); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(session, nullptr); + + ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false)); + ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); + + window->property_->SetPersistentId(10002); + WMError ret = window->MoveTo(-500, -500); ASSERT_EQ(WMError::WM_OK, ret); @@ -701,6 +726,7 @@ HWTEST_F(WindowLayoutTest, moveWindowTo02, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, moveWindowTo03, Function | MediumTest | Level3) { sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(option, nullptr); option->SetWindowName("moveWindowTo03"); option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); option->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); @@ -708,6 +734,16 @@ HWTEST_F(WindowLayoutTest, moveWindowTo03, Function | MediumTest | Level3) sptr window = new WindowSceneSessionImpl(option); ASSERT_NE(window, nullptr); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(session, nullptr); + + ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false)); + ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); + + window->property_->SetPersistentId(10003); + WMError ret = window->MoveTo(-500, -500); ASSERT_EQ(WMError::WM_OK, ret); @@ -729,6 +765,7 @@ HWTEST_F(WindowLayoutTest, moveWindowTo03, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, moveWindowTo04, Function | MediumTest | Level3) { sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(option, nullptr); option->SetWindowName("moveWindowTo04"); option->SetWindowType(WindowType::APP_WINDOW_BASE); option->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); @@ -736,6 +773,16 @@ HWTEST_F(WindowLayoutTest, moveWindowTo04, Function | MediumTest | Level3) sptr window = new WindowSceneSessionImpl(option); ASSERT_NE(window, nullptr); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(session, nullptr); + + ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false)); + ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); + + window->property_->SetPersistentId(10004); + WMError ret = window->MoveTo(-500, -500); ASSERT_EQ(WMError::WM_OK, ret); @@ -757,6 +804,7 @@ HWTEST_F(WindowLayoutTest, moveWindowTo04, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, moveWindowTo05, Function | MediumTest | Level3) { sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(option, nullptr); option->SetWindowName("moveWindowTo05"); option->SetWindowType(WindowType::APP_WINDOW_BASE); option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); @@ -764,6 +812,16 @@ HWTEST_F(WindowLayoutTest, moveWindowTo05, Function | MediumTest | Level3) sptr window = new WindowSceneSessionImpl(option); ASSERT_NE(window, nullptr); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(session, nullptr); + + ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false)); + ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); + + window->property_->SetPersistentId(10005); + WMError ret = window->MoveTo(-500, -500); ASSERT_EQ(WMError::WM_OK, ret); @@ -785,6 +843,7 @@ HWTEST_F(WindowLayoutTest, moveWindowTo05, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, moveWindowTo06, Function | MediumTest | Level3) { sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(option, nullptr); option->SetWindowName("moveWindowTo06"); option->SetWindowType(WindowType::APP_WINDOW_BASE); option->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); @@ -792,6 +851,16 @@ HWTEST_F(WindowLayoutTest, moveWindowTo06, Function | MediumTest | Level3) sptr window = new WindowSceneSessionImpl(option); ASSERT_NE(window, nullptr); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(session, nullptr); + + ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false)); + ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); + + window->property_->SetPersistentId(10006); + WMError ret = window->MoveTo(-500, -500); ASSERT_EQ(WMError::WM_OK, ret); @@ -813,6 +882,7 @@ HWTEST_F(WindowLayoutTest, moveWindowTo06, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, moveWindowTo07, Function | MediumTest | Level3) { sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(option, nullptr); option->SetWindowName("moveWindowTo07"); option->SetWindowType(WindowType::APP_WINDOW_BASE); option->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); @@ -820,6 +890,16 @@ HWTEST_F(WindowLayoutTest, moveWindowTo07, Function | MediumTest | Level3) sptr window = new WindowSceneSessionImpl(option); ASSERT_NE(window, nullptr); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(session, nullptr); + + ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false)); + ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); + + window->property_->SetPersistentId(10007); + WMError ret = window->MoveTo(-500, -500); ASSERT_EQ(WMError::WM_OK, ret); @@ -841,6 +921,7 @@ HWTEST_F(WindowLayoutTest, moveWindowTo07, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, resize01, Function | MediumTest | Level3) { sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(option, nullptr); option->SetWindowName("resize01"); option->SetWindowType(WindowType::APP_WINDOW_BASE); option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); @@ -848,6 +929,16 @@ HWTEST_F(WindowLayoutTest, resize01, Function | MediumTest | Level3) sptr window = new WindowSceneSessionImpl(option); ASSERT_NE(window, nullptr); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(session, nullptr); + + ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false)); + ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); + + window->property_->SetPersistentId(10008); + WMError ret = window->Resize(-500, -500); ASSERT_EQ(WMError::WM_OK, ret); @@ -878,6 +969,7 @@ HWTEST_F(WindowLayoutTest, resize01, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, resize02, Function | MediumTest | Level3) { sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(option, nullptr); option->SetWindowName("resize02"); option->SetWindowType(WindowType::APP_WINDOW_BASE); option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); @@ -885,6 +977,16 @@ HWTEST_F(WindowLayoutTest, resize02, Function | MediumTest | Level3) sptr window = new WindowSceneSessionImpl(option); ASSERT_NE(window, nullptr); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(session, nullptr); + + ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false)); + ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); + + window->property_->SetPersistentId(10009); + WMError ret = window->Resize(-500, -500); ASSERT_EQ(WMError::WM_OK, ret); @@ -906,6 +1008,7 @@ HWTEST_F(WindowLayoutTest, resize02, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, resize03, Function | MediumTest | Level3) { sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(option, nullptr); option->SetWindowName("resize03"); option->SetWindowType(WindowType::APP_WINDOW_BASE); option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); @@ -913,6 +1016,16 @@ HWTEST_F(WindowLayoutTest, resize03, Function | MediumTest | Level3) sptr window = new WindowSceneSessionImpl(option); ASSERT_NE(window, nullptr); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(session, nullptr); + + ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false)); + ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); + + window->property_->SetPersistentId(10010); + WMError ret = window->Resize(-500, -500); ASSERT_EQ(WMError::WM_OK, ret); @@ -934,6 +1047,7 @@ HWTEST_F(WindowLayoutTest, resize03, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, resize04, Function | MediumTest | Level3) { sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(option, nullptr); option->SetWindowName("resize04"); option->SetWindowType(WindowType::APP_WINDOW_BASE); option->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); @@ -941,6 +1055,16 @@ HWTEST_F(WindowLayoutTest, resize04, Function | MediumTest | Level3) sptr window = new WindowSceneSessionImpl(option); ASSERT_NE(window, nullptr); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(session, nullptr); + + ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false)); + ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); + + window->property_->SetPersistentId(10011); + WMError ret = window->Resize(-500, -500); ASSERT_EQ(WMError::WM_OK, ret); @@ -962,6 +1086,7 @@ HWTEST_F(WindowLayoutTest, resize04, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, resize05, Function | MediumTest | Level3) { sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(option, nullptr); option->SetWindowName("resize05"); option->SetWindowType(WindowType::APP_WINDOW_BASE); option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); @@ -969,6 +1094,16 @@ HWTEST_F(WindowLayoutTest, resize05, Function | MediumTest | Level3) sptr window = new WindowSceneSessionImpl(option); ASSERT_NE(window, nullptr); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(session, nullptr); + + ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false)); + ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); + + window->property_->SetPersistentId(10012); + WMError ret = window->Resize(-500, -500); ASSERT_EQ(WMError::WM_OK, ret); @@ -1000,6 +1135,7 @@ HWTEST_F(WindowLayoutTest, resize05, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, resize06, Function | MediumTest | Level3) { sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(option, nullptr); option->SetWindowName("resize06"); option->SetWindowType(WindowType::APP_WINDOW_BASE); option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); @@ -1007,6 +1143,16 @@ HWTEST_F(WindowLayoutTest, resize06, Function | MediumTest | Level3) sptr window = new WindowSceneSessionImpl(option); ASSERT_NE(window, nullptr); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(session, nullptr); + + ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false)); + ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); + + window->property_->SetPersistentId(10013); + WindowLimits windowLimits; WMError ret = window->GetWindowLimits(windowLimits); @@ -1025,6 +1171,7 @@ HWTEST_F(WindowLayoutTest, resize06, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, resize07, Function | MediumTest | Level3) { sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(option, nullptr); option->SetWindowName("resize07"); option->SetWindowType(WindowType::APP_WINDOW_BASE); option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); @@ -1032,6 +1179,16 @@ HWTEST_F(WindowLayoutTest, resize07, Function | MediumTest | Level3) sptr window = new WindowSceneSessionImpl(option); ASSERT_NE(window, nullptr); + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(session, nullptr); + + ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false)); + ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); + + window->property_->SetPersistentId(10014); + WindowLimits windowLimits; WMError ret = window->GetWindowLimits(windowLimits); @@ -1050,13 +1207,24 @@ HWTEST_F(WindowLayoutTest, resize07, Function | MediumTest | Level3) HWTEST_F(WindowLayoutTest, resize08, Function | MediumTest | Level3) { sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(option, nullptr); option->SetWindowName("resize08"); option->SetWindowType(WindowType::APP_WINDOW_BASE); option->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); sptr window = new WindowSceneSessionImpl(option); ASSERT_NE(window, nullptr); + + SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" }; + sptr session = new (std::nothrow) SessionMocker(sessionInfo); + ASSERT_NE(session, nullptr); + + ASSERT_EQ(WMError::WM_OK, window->Create(abilityContext_, session)); + ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy(false)); + ASSERT_EQ(WMError::WM_ERROR_REPEAT_OPERATION, window->Create(abilityContext_, session)); + window->property_->SetPersistentId(10015); + WMError ret = window->Resize(-500, -500); ASSERT_EQ(WMError::WM_OK, ret);