diff --git a/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp b/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp index 085496a9717edb8bf09af6c1aaf8ca41cad7d17d..3eff950205fb712da54d7967cc9f34a59207d8da 100644 --- a/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp +++ b/test/fuzztest/wms/window_fuzzer/window_fuzzer.cpp @@ -195,6 +195,14 @@ public: void AfterInactive() override { } + + void AfterResumed() override + { + } + + void AfterPaused() override + { + } }; template @@ -449,6 +457,7 @@ void CheckWindowImplFunctionsPart4(sptr window, const uint8_t* data, bool boolVal; startPos += GetObject(boolVal, data + startPos, size - startPos); window->UpdateActiveStatus(boolVal); + window->NotifyForegroundInteractiveStatus(boolVal); Transform trans; startPos += GetObject(trans, data + startPos, size - startPos); diff --git a/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp b/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp index c0fa2ce8fbfbf6d12fb141a02bd32c9c19d20a55..e884c8e0d9c0aefb2fa681a08fbcc81e262b076c 100644 --- a/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp +++ b/test/fuzztest/wms/windowagent_fuzzer/window_agent_fuzzer.cpp @@ -65,6 +65,7 @@ void CheckWindowAgentFunctionsPart1(sptr agent, const uint8_t* data startPos += GetObject(modeSupportInfo, data + startPos, size - startPos); agent->UpdateWindowModeSupportInfo(modeSupportInfo); agent->UpdateFocusStatus(boolVal); + agent->NotifyForegroundInteractiveStatus(boolVal); sptr avoidArea = new AvoidArea(); startPos += GetObject(rect, data + startPos, size - startPos); diff --git a/test/fuzztest/wms/windowscene_fuzzer/windowscene_fuzzer.cpp b/test/fuzztest/wms/windowscene_fuzzer/windowscene_fuzzer.cpp index ddd31aed740b51ea05d5b18ae31c9747fb034c0a..470819f7b3db871afa523fe94b75f90b2789e880 100644 --- a/test/fuzztest/wms/windowscene_fuzzer/windowscene_fuzzer.cpp +++ b/test/fuzztest/wms/windowscene_fuzzer/windowscene_fuzzer.cpp @@ -54,6 +54,12 @@ public: virtual void AfterInactive() override { } + virtual void AfterResumed() override + { + } + virtual void AfterPaused() override + { + } }; template diff --git a/window_scene/test/unittest/scene_session_manager_test.cpp b/window_scene/test/unittest/scene_session_manager_test.cpp index 8cb7f703ec19dcb87f64bf83105b20837672c42b..090f5434cd7e49fcfe732156e8e6c7876045d851 100644 --- a/window_scene/test/unittest/scene_session_manager_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_test.cpp @@ -1833,6 +1833,25 @@ HWTEST_F(SceneSessionManagerTest, RequestSceneSessionDestruction, Function | Sma delete scensession; } +/** + * @tc.name: NotifyForegroundInteractiveStatus + * @tc.desc: SceneSesionManager notify scene session interactive status + * @tc.type: FUNC +*/ +HWTEST_F(SceneSessionManagerTest, NotifyForegroundInteractiveStatus, Function | SmallTest | Level3) +{ + bool interactive = false; + SessionInfo info; + info.abilityName_ = "Foreground01"; + info.bundleName_ = "Foreground01"; + sptr scensession; + scensession = new (std::nothrow) SceneSession(info, nullptr); + int ret = 0; + ssm_->NotifyForegroundInteractiveStatus(scensession, interactive); + ASSERT_EQ(ret, 0); + delete scensession; +} + /** * @tc.name: AddClientDeathRecipient * @tc.desc: SceneSesionManager add client death recipient diff --git a/window_scene/test/unittest/session_stage_proxy_test.cpp b/window_scene/test/unittest/session_stage_proxy_test.cpp index 126214968e8f88f3e88975c9731e291b747bb2a8..275bb4cac1fde2776578e2e188128c5091d7c343 100644 --- a/window_scene/test/unittest/session_stage_proxy_test.cpp +++ b/window_scene/test/unittest/session_stage_proxy_test.cpp @@ -239,6 +239,19 @@ HWTEST_F(SessionStageProxyTest, UpdateWindowMode, Function | SmallTest | Level1) ASSERT_TRUE((sessionStage_ != nullptr)); sessionStage_->UpdateWindowMode(mode); } + +/** + * @tc.name: NotifyForegroundInteractiveStatus + * @tc.desc: test function : NotifyForegroundInteractiveStatus + * @tc.type: FUNC + */ +HWTEST_F(SessionStageProxyTest, NotifyForegroundInteractiveStatus, Function | SmallTest | Level1) +{ + bool interactive = true; + ASSERT_TRUE((sessionStage_ != nullptr)); + sessionStage_->NotifyForegroundInteractiveStatus(interactive); +} + } } } \ No newline at end of file diff --git a/window_scene/test/unittest/session_stage_stub_test.cpp b/window_scene/test/unittest/session_stage_stub_test.cpp index 76eb133661756f0045e3d942c1cc7f2fc4cd5c10..fd5318bbc1bb72f4d25666490b29e4b20694f5a9 100644 --- a/window_scene/test/unittest/session_stage_stub_test.cpp +++ b/window_scene/test/unittest/session_stage_stub_test.cpp @@ -280,6 +280,22 @@ HWTEST_F(SessionStageStubTest, HandleUpdateWindowMode, Function | SmallTest | Le ASSERT_TRUE((sessionStageStub_ != nullptr)); ASSERT_EQ(0, sessionStageStub_->HandleUpdateWindowMode(data, reply)); } + +/** + * @tc.name: HandleNotifyForegroundInteractiveStatus + * @tc.desc: test function : HandleNotifyForegroundInteractiveStatus + * @tc.type: FUNC + */ +HWTEST_F(SessionStageStubTest, HandleNotifyForegroundInteractiveStatus, Function | SmallTest | Level1) +{ + MessageParcel data; + MessageParcel reply; + + data.WriteBool(true); + ASSERT_TRUE((sessionStageStub_ != nullptr)); + ASSERT_EQ(0, sessionStageStub_->HandleNotifyForegroundInteractiveStatus(data, reply)); +} + } } } \ No newline at end of file diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index 51bbf624f9aa7b493ae6df89379d3cff20613e98..445f8d11d6d232e469342bb683b3a2ee4b30e0bc 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -2013,6 +2013,31 @@ HWTEST_F(WindowSessionTest, SetBufferAvailable, Function | SmallTest | Level2) session_->SetBufferAvailable(111); ASSERT_EQ(true, session_->GetBufferAvailable()); } + +/** + * @tc.name: NotifyForegroundInteractiveStatus + * @tc.desc: NotifyForegroundInteractiveStatus Test + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest, NotifyForegroundInteractiveStatus, Function | SmallTest | Level2) +{ + ASSERT_NE(session_, nullptr); + + session_->sessionStage_ = nullptr; + bool interactive = true; + session_->NotifyForegroundInteractiveStatus(interactive); + + sptr mockSessionStage = new(std::nothrow) SessionStageMocker(); + ASSERT_NE(mockSessionStage, nullptr); + session_->sessionStage_ = mockSessionStage; + session_->state_ = SessionState::STATE_FOREGROUND; + interactive = false; + session_->NotifyForegroundInteractiveStatus(interactive); + + session_->state_ = SessionState::STATE_DISCONNECT; + ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, session_->SetFocusable(false)); +} + } } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/wm/test/unittest/window_agent_test.cpp b/wm/test/unittest/window_agent_test.cpp index aaf27c0ff3fc3723704af363b99246401641c3d3..94683746bec3e6c1e57dd859329ff8cf688210f0 100644 --- a/wm/test/unittest/window_agent_test.cpp +++ b/wm/test/unittest/window_agent_test.cpp @@ -402,6 +402,24 @@ HWTEST_F(WindowAgentTest, ConsumeKeyEvent, Function | SmallTest | Level2) ASSERT_EQ(0, res); } +/** + * @tc.name: NotifyForegroundInteractiveStatus + * @tc.desc: NotifyForegroundInteractiveStatus + * @tc.type: FUNC + */ +HWTEST_F(WindowAgentTest, NotifyForegroundInteractiveStatus, Function | SmallTest | Level2) +{ + auto res = 0; + bool interactive = false; + windowAgent_->NotifyForegroundInteractiveStatus(interactive); + ASSERT_EQ(0, res); + + interactive = true; + windowAgent_->window_ = nullptr; + windowAgent_->NotifyForegroundInteractiveStatus(interactive); + ASSERT_EQ(0, res); +} + } } } \ No newline at end of file diff --git a/wm/test/unittest/window_impl_test.cpp b/wm/test/unittest/window_impl_test.cpp index bae0b9bf859a1555d1d9db4c16cfacf08855d89d..930c0fe2c254075b976231a26abfec834b5141e2 100644 --- a/wm/test/unittest/window_impl_test.cpp +++ b/wm/test/unittest/window_impl_test.cpp @@ -3743,6 +3743,26 @@ HWTEST_F(WindowImplTest, GetTopWindowWithId, Function | SmallTest | Level3) ASSERT_EQ(WMError::WM_OK, window->Destroy()); } + +/** + * @tc.name: NotifyForegroundInteractiveStatus + * @tc.desc: NotifyForegroundInteractiveStatus Test + * @tc.type: FUNC + */ +HWTEST_F(WindowImplTest, NotifyForegroundInteractiveStatus, Function | SmallTest | Level2) +{ + sptr option = new WindowOption(); + ASSERT_NE(option, nullptr); + sptr window = new WindowImpl(option); + ASSERT_NE(window, nullptr); + bool interactive = false; + window->NotifyForegroundInteractiveStatus(interactive); + window->SetWindowState(WindowState::STATE_DESTROYED); + interactive = true; + window->NotifyForegroundInteractiveStatus(interactive); + ASSERT_EQ(WindowState::STATE_DESTROYED, window->GetWindowState()); +} + } } // namespace Rosen } // namespace OHOS diff --git a/wm/test/unittest/window_proxy_test.cpp b/wm/test/unittest/window_proxy_test.cpp index bf352fc223fdd1bba874d0810febb11437d20285..2f32ede0371648594de7d18678247f526f0f8e7a 100644 --- a/wm/test/unittest/window_proxy_test.cpp +++ b/wm/test/unittest/window_proxy_test.cpp @@ -284,6 +284,20 @@ HWTEST_F(WindowProxyTest, NotifyScreenshot, Function | SmallTest | Level2) ASSERT_EQ(err, WMError::WM_OK); } +/** + * @tc.name: NotifyForegroundInteractiveStatus + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(WindowProxyTest, NotifyForegroundInteractiveStatus, Function | SmallTest | Level2) +{ + ASSERT_NE(windowProxy_, nullptr); + WMError err = WMError::WM_OK; + bool interactive = false; + windowProxy_->NotifyForegroundInteractiveStatus(interactive); + ASSERT_EQ(err, WMError::WM_OK); +} + } } } diff --git a/wm/test/unittest/window_scene_session_impl_test.cpp b/wm/test/unittest/window_scene_session_impl_test.cpp index 6b6a385412db477ee4589c3d69dad37fe1d58c68..14db65aa2c7bfbd31c171156399799d84d9fdd3b 100644 --- a/wm/test/unittest/window_scene_session_impl_test.cpp +++ b/wm/test/unittest/window_scene_session_impl_test.cpp @@ -44,6 +44,8 @@ public: MOCK_METHOD1(ForegroundFailed, void(int32_t)); MOCK_METHOD0(AfterActive, void(void)); MOCK_METHOD0(AfterInactive, void(void)); + MOCK_METHOD0(AfterResumed, void(void)); + MOCK_METHOD0(AfterPaused, void(void)); }; class WindowSceneSessionImplTest : public testing::Test { diff --git a/wm/test/unittest/window_session_impl_test.cpp b/wm/test/unittest/window_session_impl_test.cpp index faccb087c4bb7f2f4ec9374531c0f00dc8b8dc95..884e5c725218ea2d2ac9b01e590b87b62c4ed5ab 100644 --- a/wm/test/unittest/window_session_impl_test.cpp +++ b/wm/test/unittest/window_session_impl_test.cpp @@ -40,6 +40,8 @@ public: MOCK_METHOD1(ForegroundFailed, void(int32_t)); MOCK_METHOD0(AfterActive, void(void)); MOCK_METHOD0(AfterInactive, void(void)); + MOCK_METHOD0(AfterResumed, void(void)); + MOCK_METHOD0(AfterPaused, void(void)); }; class WindowSessionImplTest : public testing::Test { @@ -974,6 +976,29 @@ HWTEST_F(WindowSessionImplTest, NotifyAfterUnfocused, Function | SmallTest | Lev GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyAfterUnfocused end"; } +/** + * @tc.name: NotifyForegroundInteractiveStatus + * @tc.desc: NotifyForegroundInteractiveStatus + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest, NotifyForegroundInteractiveStatus, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyForegroundInteractiveStatus start"; + sptr option = new WindowOption(); + ASSERT_NE(option, nullptr); + option->SetWindowName("NotifyForegroundInteractiveStatus"); + sptr window = + new (std::nothrow) WindowSessionImpl(option); + ASSERT_NE(window, nullptr); + + int res = 0; + window->NotifyForegroundInteractiveStatus(true); + window->NotifyForegroundInteractiveStatus(false); + ASSERT_EQ(res, 0); + + GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyForegroundInteractiveStatus end"; +} + /** * @tc.name: NotifyBeforeDestroy * @tc.desc: NotifyBeforeDestroy diff --git a/wm/test/unittest/window_stub_test.cpp b/wm/test/unittest/window_stub_test.cpp index 30ac50c4f234ea27e1d05dfad20f732d03030366..91584ab4110e25d4b7c5387e881872d9feb7da5e 100644 --- a/wm/test/unittest/window_stub_test.cpp +++ b/wm/test/unittest/window_stub_test.cpp @@ -237,6 +237,25 @@ HWTEST_F(WindowStubTest, OnRemoteRequest08, Function | SmallTest | Level2) EXPECT_EQ(res, -1); } + +/** + * @tc.name: OnRemoteRequest09 + * @tc.desc: test TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS success + * @tc.type: FUNC + */ +HWTEST_F(WindowStubTest, OnRemoteRequest09, Function | SmallTest | Level2) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + + data.WriteInterfaceToken(WindowStub::GetDescriptor()); + data.WriteBool(false); + uint32_t code = static_cast(IWindow::WindowMessage::TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS); + int res = windowStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(res, 0); +} + } } }