diff --git a/services/screenclient/test/unittest/src/screen_client_test.cpp b/services/screenclient/test/unittest/src/screen_client_test.cpp index bd6176a15e1d095395e21879f2639d0adbbc986b..d6f4eda77cd471a3dc39eb57370f1b26256944e4 100644 --- a/services/screenclient/test/unittest/src/screen_client_test.cpp +++ b/services/screenclient/test/unittest/src/screen_client_test.cpp @@ -38,8 +38,8 @@ void ScreenClientTest::TearDown() {} HWTEST_F(ScreenClientTest, AddWindow_001, TestSize.Level1) { std::shared_ptr windowProperty = nullptr; - int32_t actual = ScreenClient::GetInstance().AddWindow(windowProperty); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_ADD_WINDOW_ERROR, actual); + int32_t ret = ScreenClient::GetInstance().AddWindow(windowProperty); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_ADD_WINDOW_ERROR, ret); } /** @@ -51,11 +51,10 @@ HWTEST_F(ScreenClientTest, AddWindow_001, TestSize.Level1) HWTEST_F(ScreenClientTest, AddWindow_002, TestSize.Level1) { std::shared_ptr windowProperty = std::make_shared(); - int32_t windowId = 0; - int32_t actual = ScreenClient::GetInstance().AddWindow(windowProperty); - EXPECT_EQ(windowId, actual); - actual = ScreenClient::GetInstance().RemoveWindow(actual); - EXPECT_EQ(DH_SUCCESS, actual); + int32_t expectId = ScreenClient::GetInstance().AddWindow(windowProperty); + EXPECT_EQ(0, expectId); + int32_t ret = ScreenClient::GetInstance().RemoveWindow(expectId); + EXPECT_EQ(DH_SUCCESS, ret); } /** @@ -66,9 +65,8 @@ HWTEST_F(ScreenClientTest, AddWindow_002, TestSize.Level1) */ HWTEST_F(ScreenClientTest, ShowWindow_001, TestSize.Level1) { - int32_t windowId = 0; - int32_t actual = ScreenClient::GetInstance().ShowWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, actual); + int32_t ret = ScreenClient::GetInstance().ShowWindow(0); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, ret); } /** @@ -81,10 +79,10 @@ HWTEST_F(ScreenClientTest, ShowWindow_002, TestSize.Level1) { std::shared_ptr windowProperty = std::make_shared(); int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty); - int32_t actual = ScreenClient::GetInstance().ShowWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); - actual = ScreenClient::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); + int32_t ret = ScreenClient::GetInstance().ShowWindow(windowId); + EXPECT_EQ(DH_SUCCESS, ret); + ret = ScreenClient::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(DH_SUCCESS, ret); } /** @@ -96,12 +94,11 @@ HWTEST_F(ScreenClientTest, ShowWindow_002, TestSize.Level1) HWTEST_F(ScreenClientTest, ShowWindow_003, TestSize.Level1) { int32_t windowId = 100; - sptr surface = nullptr; - ScreenClient::GetInstance().surfaceMap_.emplace(windowId, surface); - int32_t actual = ScreenClient::GetInstance().ShowWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, actual); - actual = ScreenClient::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, actual); + ScreenClient::GetInstance().surfaceMap_.emplace(windowId, nullptr); + int32_t ret = ScreenClient::GetInstance().ShowWindow(windowId); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, ret); + ret = ScreenClient::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, ret); } /** @@ -112,9 +109,8 @@ HWTEST_F(ScreenClientTest, ShowWindow_003, TestSize.Level1) */ HWTEST_F(ScreenClientTest, HideWindow_001, TestSize.Level1) { - int32_t windowId = 0; - int32_t actual = ScreenClient::GetInstance().HideWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_HIDE_WINDOW_ERROR, actual); + int32_t ret = ScreenClient::GetInstance().HideWindow(0); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_HIDE_WINDOW_ERROR, ret); } /** @@ -127,10 +123,10 @@ HWTEST_F(ScreenClientTest, HideWindow_002, TestSize.Level1) { std::shared_ptr windowProperty = std::make_shared(); int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty); - int32_t actual = ScreenClient::GetInstance().HideWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); - actual = ScreenClient::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); + int32_t ret = ScreenClient::GetInstance().HideWindow(windowId); + EXPECT_EQ(DH_SUCCESS, ret); + ret = ScreenClient::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(DH_SUCCESS, ret); } /** @@ -142,12 +138,11 @@ HWTEST_F(ScreenClientTest, HideWindow_002, TestSize.Level1) HWTEST_F(ScreenClientTest, HideWindow_003, TestSize.Level1) { int32_t windowId = 0; - sptr surface = nullptr; - ScreenClient::GetInstance().surfaceMap_.emplace(windowId, surface); - int32_t actual = ScreenClient::GetInstance().HideWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_HIDE_WINDOW_ERROR, actual); - actual = ScreenClient::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, actual); + ScreenClient::GetInstance().surfaceMap_.emplace(windowId, nullptr); + int32_t ret = ScreenClient::GetInstance().HideWindow(windowId); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_HIDE_WINDOW_ERROR, ret); + ret = ScreenClient::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, ret); } /** @@ -158,11 +153,8 @@ HWTEST_F(ScreenClientTest, HideWindow_003, TestSize.Level1) */ HWTEST_F(ScreenClientTest, MoveWindow_001, TestSize.Level1) { - int32_t windowId = 0; - int32_t startX = 0; - int32_t startY = 0; - int32_t actual = ScreenClient::GetInstance().MoveWindow(windowId, startX, startY); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_MOVE_WINDOW_ERROR, actual); + int32_t ret = ScreenClient::GetInstance().MoveWindow(0, 0, 0); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_MOVE_WINDOW_ERROR, ret); } /** @@ -175,12 +167,10 @@ HWTEST_F(ScreenClientTest, MoveWindow_002, TestSize.Level1) { std::shared_ptr windowProperty = std::make_shared(); int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty); - int32_t startX = 0; - int32_t startY = 0; - int32_t actual = ScreenClient::GetInstance().MoveWindow(windowId, startX, startY); - EXPECT_EQ(DH_SUCCESS, actual); - actual = ScreenClient::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); + int32_t ret = ScreenClient::GetInstance().MoveWindow(windowId, 0, 0); + EXPECT_EQ(DH_SUCCESS, ret); + ret = ScreenClient::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(DH_SUCCESS, ret); } /** @@ -192,14 +182,11 @@ HWTEST_F(ScreenClientTest, MoveWindow_002, TestSize.Level1) HWTEST_F(ScreenClientTest, MoveWindow_003, TestSize.Level1) { int32_t windowId = 0; - sptr surface = nullptr; - ScreenClient::GetInstance().surfaceMap_.emplace(windowId, surface); - int32_t startX = 0; - int32_t startY = 0; - int32_t actual = ScreenClient::GetInstance().MoveWindow(windowId, startX, startY); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_MOVE_WINDOW_ERROR, actual); - actual = ScreenClient::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, actual); + ScreenClient::GetInstance().surfaceMap_.emplace(windowId, nullptr); + int32_t ret = ScreenClient::GetInstance().MoveWindow(windowId, 0, 0); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_MOVE_WINDOW_ERROR, ret); + ret = ScreenClient::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, ret); } /** @@ -210,9 +197,8 @@ HWTEST_F(ScreenClientTest, MoveWindow_003, TestSize.Level1) */ HWTEST_F(ScreenClientTest, RemoveWindow_001, TestSize.Level1) { - int32_t windowId = 0; - int32_t actual = ScreenClient::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, actual); + int32_t ret = ScreenClient::GetInstance().RemoveWindow(0); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, ret); } /** @@ -225,8 +211,8 @@ HWTEST_F(ScreenClientTest, RemoveWindow_002, TestSize.Level1) { std::shared_ptr windowProperty = std::make_shared(); int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty); - int32_t actual = ScreenClient::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); + int32_t ret = ScreenClient::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(DH_SUCCESS, ret); } /** @@ -238,10 +224,9 @@ HWTEST_F(ScreenClientTest, RemoveWindow_002, TestSize.Level1) HWTEST_F(ScreenClientTest, RemoveWindow_003, TestSize.Level1) { int32_t windowId = 0; - sptr surface = nullptr; - ScreenClient::GetInstance().surfaceMap_.emplace(windowId, surface); - int32_t actual = ScreenClient::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, actual); + ScreenClient::GetInstance().surfaceMap_.emplace(windowId, nullptr); + int32_t ret = ScreenClient::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, ret); } /** @@ -252,9 +237,7 @@ HWTEST_F(ScreenClientTest, RemoveWindow_003, TestSize.Level1) */ HWTEST_F(ScreenClientTest, GetSurface_001, TestSize.Level1) { - int32_t windowId = 0; - sptr actualSurface = ScreenClient::GetInstance().GetSurface(windowId); - EXPECT_EQ(nullptr, actualSurface); + EXPECT_EQ(nullptr, ScreenClient::GetInstance().GetSurface(0)); } /** @@ -269,8 +252,8 @@ HWTEST_F(ScreenClientTest, GetSurface_002, TestSize.Level1) int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty); sptr actualSurface = ScreenClient::GetInstance().GetSurface(windowId); EXPECT_NE(nullptr, actualSurface); - int32_t actual = ScreenClient::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); + int32_t ret = ScreenClient::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(DH_SUCCESS, ret); } /** @@ -283,8 +266,8 @@ HWTEST_F(ScreenClientTest, DestroyAllWindow_001, TestSize.Level1) { std::shared_ptr windowProperty = std::make_shared(); ScreenClient::GetInstance().AddWindow(windowProperty); - int32_t actual = ScreenClient::GetInstance().DestroyAllWindow(); - EXPECT_EQ(DH_SUCCESS, actual); + int32_t ret = ScreenClient::GetInstance().DestroyAllWindow(); + EXPECT_EQ(DH_SUCCESS, ret); } } // DistributedHardware diff --git a/services/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp b/services/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp index d2537172a186d5d8b3d8f79e66b69e603dce190e..ac490a2736ea97746ecb720cf27097ccb8a5e04b 100644 --- a/services/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp +++ b/services/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp @@ -38,10 +38,7 @@ void ScreenClientWindowAdapterTest::TearDown() {} HWTEST_F(ScreenClientWindowAdapterTest, CreateWindow_001, TestSize.Level1) { std::shared_ptr windowProperty = nullptr; - int32_t windowId = 0; - sptr surface = nullptr; - sptr actualSurface = ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId); - EXPECT_EQ(surface, actualSurface); + EXPECT_EQ(nullptr, ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, 0)); } /** @@ -54,11 +51,10 @@ HWTEST_F(ScreenClientWindowAdapterTest, CreateWindow_002, TestSize.Level1) { std::shared_ptr windowProperty = std::make_shared(); int32_t windowId = 0; - sptr surface = nullptr; sptr actualSurface = ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId); - EXPECT_NE(surface, actualSurface); - int32_t actual = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); + EXPECT_NE(nullptr, actualSurface); + int32_t ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(DH_SUCCESS, ret); } /** @@ -69,9 +65,8 @@ HWTEST_F(ScreenClientWindowAdapterTest, CreateWindow_002, TestSize.Level1) */ HWTEST_F(ScreenClientWindowAdapterTest, ShowWindow_001, TestSize.Level1) { - int32_t windowId = 100; - int32_t actual = ScreenClientWindowAdapter::GetInstance().ShowWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, actual); + int32_t ret = ScreenClientWindowAdapter::GetInstance().ShowWindow(100); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, ret); } /** @@ -85,10 +80,10 @@ HWTEST_F(ScreenClientWindowAdapterTest, ShowWindow_002, TestSize.Level1) std::shared_ptr windowProperty = std::make_shared(); int32_t windowId = 100; ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId); - int32_t actual = ScreenClientWindowAdapter::GetInstance().ShowWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); - actual = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); + int32_t ret = ScreenClientWindowAdapter::GetInstance().ShowWindow(windowId); + EXPECT_EQ(DH_SUCCESS, ret); + ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(DH_SUCCESS, ret); } /** @@ -100,12 +95,11 @@ HWTEST_F(ScreenClientWindowAdapterTest, ShowWindow_002, TestSize.Level1) HWTEST_F(ScreenClientWindowAdapterTest, ShowWindow_003, TestSize.Level1) { int32_t windowId = 0; - sptr window = nullptr; - ScreenClientWindowAdapter::GetInstance().windowIdMap_.emplace(windowId, window); - int32_t actual = ScreenClientWindowAdapter::GetInstance().ShowWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, actual); - actual = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, actual); + ScreenClientWindowAdapter::GetInstance().windowIdMap_.emplace(windowId, nullptr); + int32_t ret = ScreenClientWindowAdapter::GetInstance().ShowWindow(windowId); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, ret); + ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, ret); } /** * @tc.name: HideWindow_001 @@ -115,9 +109,8 @@ HWTEST_F(ScreenClientWindowAdapterTest, ShowWindow_003, TestSize.Level1) */ HWTEST_F(ScreenClientWindowAdapterTest, HideWindow_001, TestSize.Level1) { - int32_t windowId = 0; - int32_t actual = ScreenClientWindowAdapter::GetInstance().HideWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_HIDE_WINDOW_ERROR, actual); + int32_t ret = ScreenClientWindowAdapter::GetInstance().HideWindow(0); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_HIDE_WINDOW_ERROR, ret); } /** @@ -131,10 +124,10 @@ HWTEST_F(ScreenClientWindowAdapterTest, HideWindow_002, TestSize.Level1) std::shared_ptr windowProperty = std::make_shared(); int32_t windowId = 0; ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId); - int32_t actual = ScreenClientWindowAdapter::GetInstance().HideWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); - actual = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); + int32_t ret = ScreenClientWindowAdapter::GetInstance().HideWindow(windowId); + EXPECT_EQ(DH_SUCCESS, ret); + ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(DH_SUCCESS, ret); } /** @@ -146,12 +139,11 @@ HWTEST_F(ScreenClientWindowAdapterTest, HideWindow_002, TestSize.Level1) HWTEST_F(ScreenClientWindowAdapterTest, HideWindow_003, TestSize.Level1) { int32_t windowId = 0; - sptr window = nullptr; - ScreenClientWindowAdapter::GetInstance().windowIdMap_.emplace(windowId, window); - int32_t actual = ScreenClientWindowAdapter::GetInstance().HideWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_HIDE_WINDOW_ERROR, actual); - actual = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, actual); + ScreenClientWindowAdapter::GetInstance().windowIdMap_.emplace(windowId, nullptr); + int32_t ret = ScreenClientWindowAdapter::GetInstance().HideWindow(windowId); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_HIDE_WINDOW_ERROR, ret); + ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, ret); } /** @@ -162,11 +154,8 @@ HWTEST_F(ScreenClientWindowAdapterTest, HideWindow_003, TestSize.Level1) */ HWTEST_F(ScreenClientWindowAdapterTest, MoveWindow_001, TestSize.Level1) { - int32_t windowId = 0; - int32_t startX = 0; - int32_t startY = 0; - int32_t actual = ScreenClientWindowAdapter::GetInstance().MoveWindow(windowId, startX, startY); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_MOVE_WINDOW_ERROR, actual); + int32_t ret = ScreenClientWindowAdapter::GetInstance().MoveWindow(0, 0, 0); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_MOVE_WINDOW_ERROR, ret); } /** @@ -180,12 +169,10 @@ HWTEST_F(ScreenClientWindowAdapterTest, MoveWindow_002, TestSize.Level1) std::shared_ptr windowProperty = std::make_shared(); int32_t windowId = 0; ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId); - int32_t startX = 0; - int32_t startY = 0; - int32_t actual = ScreenClientWindowAdapter::GetInstance().MoveWindow(windowId, startX, startY); - EXPECT_EQ(DH_SUCCESS, actual); - actual = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); + int32_t ret = ScreenClientWindowAdapter::GetInstance().MoveWindow(windowId, 0, 0); + EXPECT_EQ(DH_SUCCESS, ret); + ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(DH_SUCCESS, ret); } /** @@ -197,14 +184,11 @@ HWTEST_F(ScreenClientWindowAdapterTest, MoveWindow_002, TestSize.Level1) HWTEST_F(ScreenClientWindowAdapterTest, MoveWindow_003, TestSize.Level1) { int32_t windowId = 0; - int32_t startX = 0; - int32_t startY = 0; - sptr window = nullptr; - ScreenClientWindowAdapter::GetInstance().windowIdMap_.emplace(windowId, window); - int32_t actual = ScreenClientWindowAdapter::GetInstance().MoveWindow(windowId, startX, startY); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_MOVE_WINDOW_ERROR, actual); - actual = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, actual); + ScreenClientWindowAdapter::GetInstance().windowIdMap_.emplace(windowId, nullptr); + int32_t ret = ScreenClientWindowAdapter::GetInstance().MoveWindow(windowId, 0, 0); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_MOVE_WINDOW_ERROR, ret); + ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, ret); } /** @@ -215,9 +199,8 @@ HWTEST_F(ScreenClientWindowAdapterTest, MoveWindow_003, TestSize.Level1) */ HWTEST_F(ScreenClientWindowAdapterTest, RemoveWindow_001, TestSize.Level1) { - int32_t windowId = 0; - int32_t actual = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, actual); + int32_t ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(0); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, ret); } /** @@ -231,8 +214,8 @@ HWTEST_F(ScreenClientWindowAdapterTest, RemoveWindow_002, TestSize.Level1) std::shared_ptr windowProperty = std::make_shared(); int32_t windowId = 0; ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId); - int32_t actual = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); + int32_t ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(DH_SUCCESS, ret); } /** @@ -244,10 +227,9 @@ HWTEST_F(ScreenClientWindowAdapterTest, RemoveWindow_002, TestSize.Level1) HWTEST_F(ScreenClientWindowAdapterTest, RemoveWindow_003, TestSize.Level1) { int32_t windowId = 0; - sptr window = nullptr; - ScreenClientWindowAdapter::GetInstance().windowIdMap_.emplace(windowId, window); - int32_t actual = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, actual); + ScreenClientWindowAdapter::GetInstance().windowIdMap_.emplace(windowId, nullptr); + int32_t ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); + EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, ret); } /** @@ -258,11 +240,9 @@ HWTEST_F(ScreenClientWindowAdapterTest, RemoveWindow_003, TestSize.Level1) */ HWTEST_F(ScreenClientWindowAdapterTest, DestroyAllWindow_001, TestSize.Level1) { - int32_t windowId = 0; - sptr window = nullptr; - ScreenClientWindowAdapter::GetInstance().windowIdMap_.emplace(windowId, window); - int32_t actual = ScreenClientWindowAdapter::GetInstance().DestroyAllWindow(); - EXPECT_EQ(DH_SUCCESS, actual); + ScreenClientWindowAdapter::GetInstance().windowIdMap_.emplace(0, nullptr); + int32_t ret = ScreenClientWindowAdapter::GetInstance().DestroyAllWindow(); + EXPECT_EQ(DH_SUCCESS, ret); } } // DistributedHardware } // OHOS \ No newline at end of file diff --git a/services/screentransport/test/unittest/screendatachannel/src/screen_data_channel_impl_test.cpp b/services/screentransport/test/unittest/screendatachannel/src/screen_data_channel_impl_test.cpp index 29c098465f4575c94a17cb251db8020fa25a1348..a731ca5e8b53b9d2b025be8dd640afe5b5c512ae 100644 --- a/services/screentransport/test/unittest/screendatachannel/src/screen_data_channel_impl_test.cpp +++ b/services/screentransport/test/unittest/screendatachannel/src/screen_data_channel_impl_test.cpp @@ -79,9 +79,7 @@ HWTEST_F(ScreenDataChannelImplTest, close_session_test_001, TestSize.Level1) */ HWTEST_F(ScreenDataChannelImplTest, close_session_test_002, TestSize.Level1) { - std::shared_ptr listener = - std::make_shared(); - dataChannelImpl_->channelListener_ = listener; + dataChannelImpl_->channelListener_ = std::make_shared(); StreamData *ext = nullptr; StreamFrameInfo *param = nullptr; @@ -108,8 +106,7 @@ HWTEST_F(ScreenDataChannelImplTest, send_data_test_002, TestSize.Level1) std::shared_ptr listener = nullptr; dataChannelImpl_->channelListener_ = listener; int32_t sessionId = 0; - int32_t result = 0; - dataChannelImpl_->OnSessionOpened(sessionId, result); + dataChannelImpl_->OnSessionOpened(sessionId, 0); dataChannelImpl_->OnSessionClosed(sessionId); std::shared_ptr data = nullptr; EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, dataChannelImpl_->SendData(data)); @@ -123,13 +120,11 @@ HWTEST_F(ScreenDataChannelImplTest, send_data_test_002, TestSize.Level1) */ HWTEST_F(ScreenDataChannelImplTest, on_session_opened_test_001, TestSize.Level1) { - std::shared_ptr listener = - std::make_shared(); + std::shared_ptr listener = std::make_shared(); dataChannelImpl_->channelListener_ = listener; int32_t sessionId = 1; - int32_t result = 0; - dataChannelImpl_->OnSessionOpened(sessionId, result); - EXPECT_EQ(1, dataChannelImpl_->sessionId_); + dataChannelImpl_->OnSessionOpened(sessionId, 0); + EXPECT_EQ(sessionId, dataChannelImpl_->sessionId_); } /** @@ -140,12 +135,8 @@ HWTEST_F(ScreenDataChannelImplTest, on_session_opened_test_001, TestSize.Level1) */ HWTEST_F(ScreenDataChannelImplTest, on_session_opened_test_002, TestSize.Level1) { - std::shared_ptr listener = - std::make_shared(); - dataChannelImpl_->channelListener_ = listener; - int32_t sessionId = -1; - int32_t result = -1; - dataChannelImpl_->OnSessionOpened(sessionId, result); + dataChannelImpl_->channelListener_ = std::make_shared(); + dataChannelImpl_->OnSessionOpened(-1, -1); EXPECT_EQ(0, dataChannelImpl_->sessionId_); } } // DistributedHardware diff --git a/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_decoder_test.cpp b/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_decoder_test.cpp index d7f06346b689997d1dd4cddd23ef18b6262c259f..e86261bcfda4cbce883f8d14f3400a92edace7b6 100644 --- a/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_decoder_test.cpp +++ b/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_decoder_test.cpp @@ -283,14 +283,13 @@ HWTEST_F(ImageSinkDecoderTest, set_decoder_format_test_007, TestSize.Level1) */ HWTEST_F(ImageSinkDecoderTest, set_output_surface_test_001, TestSize.Level1) { + Media::AVCodecErrorType errorType = Media::AVCODEC_ERROR_EXTEND_START; + imageDecoder_->OnError(errorType, DH_SUCCESS); sptr surface = IConsumerSurface::Create("test"); sptr bp = surface->GetProducer(); sptr pSurface = Surface::CreateSurfaceAsProducer(bp); imageDecoder_->videoDecoder_ = nullptr; EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, imageDecoder_->SetOutputSurface(pSurface)); - Media::AVCodecErrorType errorType = Media::AVCODEC_ERROR_EXTEND_START; - int32_t errorCode = DH_SUCCESS; - imageDecoder_->OnError(errorType, errorCode); } /** @@ -301,15 +300,14 @@ HWTEST_F(ImageSinkDecoderTest, set_output_surface_test_001, TestSize.Level1) */ HWTEST_F(ImageSinkDecoderTest, on_input_buffer_available_test_001, TestSize.Level1) { - uint32_t index = 0; - unsigned int len = 1; - imageDecoder_->OnInputBufferAvailable(index); - EXPECT_EQ(len, imageDecoder_->bufferIndexQueue_.size()); Media::AVCodecErrorType errorType = Media::AVCODEC_ERROR_EXTEND_START; int32_t errorCode = DH_SUCCESS; std::shared_ptr listener= nullptr; imageDecoder_->imageProcessorListener_ = listener; imageDecoder_->OnError(errorType, errorCode); + unsigned int len = 1; + imageDecoder_->OnInputBufferAvailable(0); + EXPECT_EQ(len, imageDecoder_->bufferIndexQueue_.size()); } /** @@ -324,7 +322,6 @@ HWTEST_F(ImageSinkDecoderTest, on_output_buffer_available_test_001, TestSize.Lev Media::AVCodecBufferFlag flag = Media::AVCODEC_BUFFER_FLAG_CODEC_DATA; Media::AVCodecBufferInfo info; info.presentationTimeUs = 1; - imageDecoder_->OnOutputBufferAvailable(index, info, flag); EXPECT_EQ(info.presentationTimeUs, imageDecoder_->decoderBufferInfo_.presentationTimeUs); } @@ -342,7 +339,6 @@ HWTEST_F(ImageSinkDecoderTest, on_output_buffer_available_test_002, TestSize.Lev Media::AVCodecBufferInfo info; info.presentationTimeUs = 1; imageDecoder_->decoderBufferInfo_.presentationTimeUs = 0; - imageDecoder_->videoDecoder_ = nullptr; imageDecoder_->OnOutputBufferAvailable(index, info, flag); EXPECT_NE(info.presentationTimeUs, imageDecoder_->decoderBufferInfo_.presentationTimeUs); @@ -358,7 +354,6 @@ HWTEST_F(ImageSinkDecoderTest, on_output_format_changed_test_001, TestSize.Level { Media::Format format; imageDecoder_->OnOutputFormatChanged(format); - EXPECT_EQ(false, imageDecoder_->isDecoderReady_); } @@ -384,10 +379,8 @@ HWTEST_F(ImageSinkDecoderTest, ProcessData_001, TestSize.Level1) HWTEST_F(ImageSinkDecoderTest, start_input_thread_test_001, TestSize.Level1) { imageDecoder_->videoDecoder_ = nullptr; - imageDecoder_->StartInputThread(); EXPECT_EQ(true, imageDecoder_->isDecoderReady_); - imageDecoder_->StopInputThread(); EXPECT_EQ(false, imageDecoder_->isDecoderReady_); } diff --git a/services/screentransport/test/unittest/screensinktrans/src/screen_sink_trans_test.cpp b/services/screentransport/test/unittest/screensinktrans/src/screen_sink_trans_test.cpp index e49906dc1bb538e0e49c9e2efbf55268821f7062..5a6a088ab9d18308bcd5bf9d4df657e5ccee5d75 100644 --- a/services/screentransport/test/unittest/screensinktrans/src/screen_sink_trans_test.cpp +++ b/services/screentransport/test/unittest/screensinktrans/src/screen_sink_trans_test.cpp @@ -161,9 +161,8 @@ HWTEST_F(ScreenSinkTransTest, register_state_callback_test_001, TestSize.Level1) HWTEST_F(ScreenSinkTransTest, register_state_callback_test_002, TestSize.Level1) { std::shared_ptr callback = nullptr; - int32_t state = DH_SUCCESS; trans_->transCallback_ = callback; - trans_->OnProcessorStateNotify(state); + trans_->OnProcessorStateNotify(DH_SUCCESS); EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, trans_->RegisterStateCallback(callback)); } @@ -189,14 +188,11 @@ HWTEST_F(ScreenSinkTransTest, set_image_surface_test_001, TestSize.Level1) */ HWTEST_F(ScreenSinkTransTest, set_image_surface_test_002, TestSize.Level1) { - sptr surface = nullptr; trans_->transCallback_ = std::make_shared(); trans_->OnSessionClosed(); - int32_t state = DH_SUCCESS; - trans_->OnProcessorStateNotify(state); - std::shared_ptr dataBuffer = nullptr; - trans_->OnDataReceived(dataBuffer); - EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, trans_->SetImageSurface(surface)); + trans_->OnProcessorStateNotify(DH_SUCCESS); + trans_->OnDataReceived(nullptr); + EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, trans_->SetImageSurface(nullptr)); } /** diff --git a/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp b/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp index 29b15a9581687d32de586364d8f0e28290f7ff30..61553bf41125edc3e21c541195024b81bbc05635 100644 --- a/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp +++ b/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp @@ -242,9 +242,7 @@ HWTEST_F(SoftbusAdapterTest, OpenSoftbusSession_001, TestSize.Level1) std::string mySessionName = DATA_SESSION_NAME; std::string peerSessionName = DATA_SESSION_NAME; std::string peerDevId = "testDevId"; - int32_t actual = softbusAdapter.OpenSoftbusSession(mySessionName, peerSessionName, peerDevId); - EXPECT_EQ(ERR_DH_SCREEN_ADAPTER_OPEN_SESSION_FAIL, actual); } @@ -259,9 +257,7 @@ HWTEST_F(SoftbusAdapterTest, OpenSoftbusSession_002, TestSize.Level1) std::string mySessionName = "mySessionName"; std::string peerSessionName = DATA_SESSION_NAME; std::string peerDevId = "testDevId"; - int32_t actual = softbusAdapter.OpenSoftbusSession(mySessionName, peerSessionName, peerDevId); - EXPECT_EQ(ERR_DH_SCREEN_ADAPTER_OPEN_SESSION_FAIL, actual); } @@ -273,10 +269,7 @@ HWTEST_F(SoftbusAdapterTest, OpenSoftbusSession_002, TestSize.Level1) */ HWTEST_F(SoftbusAdapterTest, CloseSoftbusSession_001, TestSize.Level1) { - int32_t sessionId = 0; - - int32_t actual = softbusAdapter.CloseSoftbusSession(sessionId); - + int32_t actual = softbusAdapter.CloseSoftbusSession(0); EXPECT_EQ(DH_SUCCESS, actual); } @@ -307,9 +300,7 @@ HWTEST_F(SoftbusAdapterTest, SendSoftbusStream_001, TestSize.Level1) StreamData *data = nullptr; StreamData *ext = nullptr; StreamFrameInfo *param = nullptr; - int32_t actual = softbusAdapter.SendSoftbusStream(sessionId, data, ext, param); - EXPECT_EQ(ERR_DH_SCREEN_TRANS_ERROR, actual); } @@ -321,10 +312,9 @@ HWTEST_F(SoftbusAdapterTest, SendSoftbusStream_001, TestSize.Level1) */ HWTEST_F(SoftbusAdapterTest, GetSoftbusListener_001, TestSize.Level1) { - int32_t sessionId = 0; - std::shared_ptr actual = softbusAdapter.GetSoftbusListenerById(sessionId); + softbusAdapter.OnSoftbusSessionClosed(0); + std::shared_ptr actual = softbusAdapter.GetSoftbusListenerById(0); EXPECT_EQ(nullptr, actual); - softbusAdapter.OnSoftbusSessionClosed(sessionId); } /** @@ -336,7 +326,6 @@ HWTEST_F(SoftbusAdapterTest, GetSoftbusListener_001, TestSize.Level1) HWTEST_F(SoftbusAdapterTest, GetSoftbusListener_002, TestSize.Level1) { int32_t sessionId = 0; - SessionInfo sessionInfo; sessionInfo.sessionName = "hello"; sessionInfo.peerDevId = "world"; @@ -345,7 +334,6 @@ HWTEST_F(SoftbusAdapterTest, GetSoftbusListener_002, TestSize.Level1) softbusAdapter.mapListeners_["hello_world"] = listener; std::shared_ptr actual = softbusAdapter.GetSoftbusListenerById(sessionId); EXPECT_EQ(nullptr, actual); - softbusAdapter.OnSoftbusSessionClosed(sessionId); } /** @@ -373,10 +361,14 @@ HWTEST_F(SoftbusAdapterTest, OnSoftbusSessionOpened_001, TestSize.Level1) HWTEST_F(SoftbusAdapterTest, OnSoftbusSessionOpened_002, TestSize.Level1) { int32_t sessionId = 0; + SessionInfo sessionInfo; + sessionInfo.sessionName = "hello"; + sessionInfo.peerDevId = "world"; + softbusAdapter.mapSessionInfos_[sessionId] = sessionInfo; + softbusAdapter.mapListeners_["hello_world"] = nullptr; + softbusAdapter.OnSoftbusSessionClosed(sessionId); int32_t result = -1; - int32_t actual = softbusAdapter.OnSoftbusSessionOpened(sessionId, result); - EXPECT_EQ(ERR_DH_SCREEN_ADAPTER_OPEN_SESSION_FAIL, actual); }