diff --git a/dm/test/systemtest/BUILD.gn b/dm/test/systemtest/BUILD.gn index 1e4fc8837dc20c707f1da436c63cbb08e98446ec..84a76f07f011b23b4357ff95f22c90a027e89455 100644 --- a/dm/test/systemtest/BUILD.gn +++ b/dm/test/systemtest/BUILD.gn @@ -119,6 +119,7 @@ config("dm_systemtest_common_public_config") { "//foundation/windowmanager/utils/include", # RSSurface + "//foundation/graphic/standard/interfaces/innerkits/surface", "//foundation/graphic/standard/rosen/modules/render_service_client", ] } diff --git a/dm/test/systemtest/screen_manager_test.cpp b/dm/test/systemtest/screen_manager_test.cpp index f40717c60028620fdc24fbe6c7fa1ea3109bd0c3..61f75bfcd0938901673ba80f6f4b26f5b2939433 100644 --- a/dm/test/systemtest/screen_manager_test.cpp +++ b/dm/test/systemtest/screen_manager_test.cpp @@ -15,13 +15,20 @@ // gtest #include - +#include +#include "display_type.h" #include "display_test_utils.h" #include "future.h" #include "screen.h" +#include "transaction/rs_transaction.h" +#include "ui/rs_root_node.h" +#include "ui/rs_display_node.h" +#include "ui/rs_surface_node.h" +#include "ui/rs_ui_director.h" #include "window.h" #include "window_option.h" #include "window_manager_hilog.h" + using namespace testing; using namespace testing::ext; @@ -101,6 +108,7 @@ VirtualScreenOption ScreenManagerTest::defaultOption_ = { defaultName_, defaultWidth_, defaultHeight_, defaultDensity_, nullptr, defaultFlags_ }; uint32_t ScreenManagerTest::waitCount_ = 0; +std::shared_ptr rootNode; void ScreenManagerTest::SetUpTestCase() { @@ -125,6 +133,16 @@ void ScreenManagerTest::TearDown() { } +void RootNodeInit(std::shared_ptr rsUiDirector, int width, int height) +{ + std::cout << "rs app demo Init Rosen Backend!" << std::endl; + rootNode = RSRootNode::Create(); + rootNode->SetBounds(0, 0, width, height); + rootNode->SetFrame(0, 0, width, height); + rootNode->SetBackgroundColor(SK_ColorRED); + rsUiDirector->SetRoot(rootNode->GetId()); +} + sptr ScreenManagerTest::CreateWindowByDisplayId(DisplayId displayId) { sptr option = new WindowOption(); @@ -135,10 +153,8 @@ sptr ScreenManagerTest::CreateWindowByDisplayId(DisplayId displayId) option->SetDisplayId(displayId); option->SetWindowRect(displayRect); option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); - option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); - option->SetWindowName("CreateVirtualWindow01"); - option->AddWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID); - option->RemoveWindowFlag(WindowFlag::WINDOW_FLAG_PARENT_LIMIT); + option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); + option->SetWindowName("VirtualWindow01"); sptr window = Window::Create(option->GetWindowName(), option); window->Show(); return window; @@ -363,20 +379,8 @@ HWTEST_F(ScreenManagerTest, ScreenManager09, Function | MediumTest | Level2) ScreenId virtualScreenId = ScreenManager::GetInstance().CreateVirtualScreen(defaultOption_); ScreenId screenId = screenListener->connectFuture_.GetResult(TIME_OUT); screenListener->connectFuture_.Reset(); - ASSERT_EQ(virtualScreenId, screenId); - std::vector> screens = ScreenManager::GetInstance().GetAllScreens(); - sptr DefaultScreen = screens.front(); - DisplayId virtualDisplayId = DISPLAY_ID_INVALD; - std::vector displayIds = DisplayManager::GetInstance().GetAllDisplayIds(); - for (auto& id : displayIds) { - if (id != defaultDisplayId_) { - virtualDisplayId = id; // find the display id of virtual screen - } - } - sptr window = CreateWindowByDisplayId(virtualDisplayId); - ASSERT_NE(nullptr, window); sleep(TEST_SPEEP_S); - std::vector options = {{DefaultScreen->GetId(), 0, 0}, {virtualScreenId, defaultWidth_, 0}}; + std::vector options = {{defaultScreenId_, 0, 0}, {virtualScreenId, defaultWidth_, 0}}; ScreenId expansionId = ScreenManager::GetInstance().MakeExpand(options); auto pair = screenGroupChangeListener->changeFuture_.GetResult(TIME_OUT); screenGroupChangeListener->changeFuture_.Reset(); @@ -384,6 +388,21 @@ HWTEST_F(ScreenManagerTest, ScreenManager09, Function | MediumTest | Level2) ASSERT_EQ(ScreenGroupChangeEvent::ADD_TO_GROUP, pair.second); sleep(TEST_SPEEP_S); ASSERT_NE(SCREEN_ID_INVALID, expansionId); + DisplayId virtualDisplayId = DisplayManager::GetInstance().GetDisplayByScreen(virtualScreenId)->GetId(); + ASSERT_NE(DISPLAY_ID_INVALD, virtualDisplayId); + + sptr window = CreateWindowByDisplayId(virtualDisplayId); + ASSERT_NE(nullptr, window); + sleep(TEST_SPEEP_S); + auto surfaceNode = window->GetSurfaceNode(); + auto rsUiDirector = RSUIDirector::Create(); + rsUiDirector->Init(); + RSTransaction::FlushImplicitTransaction(); + sleep(TEST_SPEEP_S); + rsUiDirector->SetRSSurfaceNode(surfaceNode); + RootNodeInit(rsUiDirector, 200, 400); + rsUiDirector->SendMessages(); + sleep(TEST_SPEEP_S); ASSERT_EQ(DMError::DM_OK, ScreenManager::GetInstance().DestroyVirtualScreen(virtualScreenId)); screenId = screenListener->disconnectFuture_.GetResult(TIME_OUT); screenListener->disconnectFuture_.Reset(); @@ -395,8 +414,9 @@ HWTEST_F(ScreenManagerTest, ScreenManager09, Function | MediumTest | Level2) ScreenManager::GetInstance().UnregisterScreenListener(screenListener); ScreenManager::GetInstance().UnregisterScreenGroupListener(screenGroupChangeListener); sleep(TEST_SPEEP_S); + DisplayId windowDisplayId = window->GetDisplayId(); + ASSERT_EQ(windowDisplayId, defaultDisplayId_); window->Destroy(); - // will add NotifyExpandDisconnect check logic. } /** diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 75f425e60b24201d9eabe4a2c6c45a10dc8ada5b..93c3b8561561f5d3cd717699ed08ba42f8192599 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -80,6 +80,7 @@ public: virtual Rect GetRect() const = 0; virtual WindowType GetType() const = 0; virtual WindowMode GetMode() const = 0; + virtual DisplayId GetDisplayId() const = 0; virtual WindowBlurLevel GetWindowBackgroundBlur() const = 0; virtual float GetAlpha() const = 0; virtual const std::string& GetWindowName() const = 0; diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index 30c5c63dbcba2b49b229cea37fd012764200ec32..cf0726cd491b0b6677a48041aab1cd380cd87b6d 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -59,6 +59,7 @@ public: virtual Rect GetRect() const override; virtual WindowType GetType() const override; virtual WindowMode GetMode() const override; + virtual DisplayId GetDisplayId() const override; virtual WindowBlurLevel GetWindowBackgroundBlur() const override; virtual float GetAlpha() const override; virtual bool GetShowState() const override; diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 46fd6b131cb19308cd94e1e0d626e60790933652..11603d089f7be73110cc1b4e1f73867c926ff918 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -184,6 +184,11 @@ float WindowImpl::GetAlpha() const return property_->GetAlpha(); } +DisplayId WindowImpl::GetDisplayId() const +{ + return property_->GetDisplayId(); +} + bool WindowImpl::GetShowState() const { return state_ == WindowState::STATE_SHOWN; @@ -1245,6 +1250,7 @@ void WindowImpl::UpdateDisplayId(DisplayId from, DisplayId to) listener->OnDisplayMove(from, to); } } + property_->SetDisplayId(to); } void WindowImpl::SetDefaultOption()