From 7d3dd13893b11103b224e81c63f693e8a472b00c Mon Sep 17 00:00:00 2001 From: zhanglei Date: Sat, 16 Sep 2023 11:06:42 +0800 Subject: [PATCH 1/4] UT add Signed-off-by: zhanglei --- .../src/screen_data_channel_impl_test.cpp | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) 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 6a9754ce..4339fc85 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 @@ -37,6 +37,8 @@ void ScreenDataChannelImplTest::TearDown(void) dataChannelImpl_ = nullptr; } + + /** * @tc.name: CreateSession_001 * @tc.desc: Verify the CreateSession function. @@ -66,6 +68,25 @@ HWTEST_F(ScreenDataChannelImplTest, CreateSession_002, TestSize.Level1) EXPECT_EQ(-1, ret); } + +/** + * @tc.name: ReleaseSession_001 + * @tc.desc: Verify the CreateSession function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ + +HWTEST_F(ScreenDataChannelImplTest, ReleaseSession_001, TestSize.Level1) +{ + std::shared_ptr listener = std::make_shared(); + dataChannelImpl_->SetJpegSessionFlag(true); + EXPECT_EQ(ERR_DH_SCREEN_TRANS_ILLEGAL_OPERATION, dataChannelImpl_->ReleaseSession()); + +} + + + + /** * @tc.name: OpenSession_001 * @tc.desc: Verify the OpenSession function. @@ -79,6 +100,27 @@ HWTEST_F(ScreenDataChannelImplTest, OpenSession_001, TestSize.Level1) EXPECT_EQ(ERR_DH_SCREEN_TRANS_ERROR, ret); } + + +/** + * @tc.name: OpenSession_002 + * @tc.desc: Verify the OpenSession function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDataChannelImplTest, OpenSession_002, TestSize.Level1) +{ + dataChannelImpl_->SetJpegSessionFlag(true); + + int32_t ret = dataChannelImpl_->OpenSession(); + + EXPECT_EQ(ERR_DH_SCREEN_TRANS_ERROR, ret); +} + + + + + /** * @tc.name: SendFullData_001 * @tc.desc: Verify the SendFullData function. @@ -184,6 +226,34 @@ HWTEST_F(ScreenDataChannelImplTest, close_session_test_002, TestSize.Level1) EXPECT_EQ(ERR_DH_SCREEN_TRANS_SESSION_NOT_OPEN, dataChannelImpl_->CloseSession()); } +/** + * @tc.name: close_session_test_003 + * @tc.desc: Verify the CloseSession function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDataChannelImplTest, close_session_test_003, TestSize.Level1) +{ + dataChannelImpl_->channelListener_ = std::make_shared(); + + StreamData ext = {0}; + StreamFrameInfo *param = nullptr; + + int32_t sessionId = 0; + StreamData data; + data.buf = new char[DATA_LEN]; + data.bufLen = DATA_LEN; + + auto dataBuffer = std::make_shared(10); + dataChannelImpl_->ProcessDirtyData(&data, dataBuffer, &ext); + dataChannelImpl_->OnStreamReceived(sessionId, &data, &ext, param); + delete[] data.buf; + dataChannelImpl_->sessionId_ = 0; + EXPECT_EQ(ERR_DH_SCREEN_TRANS_SESSION_NOT_OPEN, dataChannelImpl_->CloseSession()); +} + + + /** * @tc.name: send_data_test_001 * @tc.desc: Verify the SendData function. @@ -237,6 +307,47 @@ HWTEST_F(ScreenDataChannelImplTest, send_data_test_003, TestSize.Level1) EXPECT_EQ(ERR_DH_SCREEN_TRANS_ERROR, dataChannelImpl_->SendData(data)); } +/** + * @tc.name: send_data_test_004 + * @tc.desc: Verify the SendData function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDataChannelImplTest, send_data_test_004, TestSize.Level1) +{ + std::shared_ptr listener = nullptr; + dataChannelImpl_->channelListener_ = listener; + dataChannelImpl_->jpegSessionFlag_ = true; + int32_t sessionId = 0; + dataChannelImpl_->OnSessionOpened(sessionId, 10); + dataChannelImpl_->OnSessionClosed(sessionId); + std::shared_ptr data = std::make_shared(10); + data->SetDataType(VIDEO_FULL_SCREEN_DATA); + EXPECT_EQ(ERR_DH_SCREEN_TRANS_ERROR, dataChannelImpl_->SendData(data)); +} + +/** + * @tc.name: send_data_test_004 + * @tc.desc: Verify the SendData function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDataChannelImplTest, send_data_test_005, TestSize.Level1) +{ + std::shared_ptr listener = nullptr; + dataChannelImpl_->channelListener_ = listener; + dataChannelImpl_->jpegSessionFlag_ = true; + dataChannelImpl_->sessionId_ = 1; + int32_t sessionId = 0; + dataChannelImpl_->OnSessionOpened(sessionId, 10); + dataChannelImpl_->OnSessionClosed(sessionId); + std::shared_ptr data = std::make_shared(10); + data->SetDataType(VIDEO_FULL_SCREEN_DATA); + EXPECT_EQ(ERR_DH_SCREEN_TRANS_ERROR, dataChannelImpl_->SendData(data)); +} + + + /** * @tc.name: on_session_opened_test_001 * @tc.desc: Verify the OnSessionOpened function. -- Gitee From 4d32be48f453ef2647e0079cdfa1c1982dd92657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=9B=B7?= Date: Sat, 16 Sep 2023 07:30:53 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张雷 --- .../src/screen_data_channel_impl_test.cpp | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) 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 4339fc85..72c26cab 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 @@ -38,7 +38,6 @@ void ScreenDataChannelImplTest::TearDown(void) } - /** * @tc.name: CreateSession_001 * @tc.desc: Verify the CreateSession function. @@ -68,7 +67,6 @@ HWTEST_F(ScreenDataChannelImplTest, CreateSession_002, TestSize.Level1) EXPECT_EQ(-1, ret); } - /** * @tc.name: ReleaseSession_001 * @tc.desc: Verify the CreateSession function. @@ -84,9 +82,6 @@ HWTEST_F(ScreenDataChannelImplTest, ReleaseSession_001, TestSize.Level1) } - - - /** * @tc.name: OpenSession_001 * @tc.desc: Verify the OpenSession function. @@ -100,8 +95,6 @@ HWTEST_F(ScreenDataChannelImplTest, OpenSession_001, TestSize.Level1) EXPECT_EQ(ERR_DH_SCREEN_TRANS_ERROR, ret); } - - /** * @tc.name: OpenSession_002 * @tc.desc: Verify the OpenSession function. @@ -117,10 +110,6 @@ HWTEST_F(ScreenDataChannelImplTest, OpenSession_002, TestSize.Level1) EXPECT_EQ(ERR_DH_SCREEN_TRANS_ERROR, ret); } - - - - /** * @tc.name: SendFullData_001 * @tc.desc: Verify the SendFullData function. @@ -252,8 +241,6 @@ HWTEST_F(ScreenDataChannelImplTest, close_session_test_003, TestSize.Level1) EXPECT_EQ(ERR_DH_SCREEN_TRANS_SESSION_NOT_OPEN, dataChannelImpl_->CloseSession()); } - - /** * @tc.name: send_data_test_001 * @tc.desc: Verify the SendData function. @@ -327,7 +314,7 @@ HWTEST_F(ScreenDataChannelImplTest, send_data_test_004, TestSize.Level1) } /** - * @tc.name: send_data_test_004 + * @tc.name: send_data_test_005 * @tc.desc: Verify the SendData function. * @tc.type: FUNC * @tc.require: Issue Number @@ -346,8 +333,6 @@ HWTEST_F(ScreenDataChannelImplTest, send_data_test_005, TestSize.Level1) EXPECT_EQ(ERR_DH_SCREEN_TRANS_ERROR, dataChannelImpl_->SendData(data)); } - - /** * @tc.name: on_session_opened_test_001 * @tc.desc: Verify the OnSessionOpened function. -- Gitee From bc39f72f8da8d6df8ab73378b7944adaf26771b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=9B=B7?= Date: Sat, 16 Sep 2023 07:37:23 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张雷 --- .../screendatachannel/src/screen_data_channel_impl_test.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 72c26cab..1d018c03 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 @@ -73,13 +73,12 @@ HWTEST_F(ScreenDataChannelImplTest, CreateSession_002, TestSize.Level1) * @tc.type: FUNC * @tc.require: Issue Number */ - HWTEST_F(ScreenDataChannelImplTest, ReleaseSession_001, TestSize.Level1) { std::shared_ptr listener = std::make_shared(); dataChannelImpl_->SetJpegSessionFlag(true); - EXPECT_EQ(ERR_DH_SCREEN_TRANS_ILLEGAL_OPERATION, dataChannelImpl_->ReleaseSession()); - + + EXPECT_EQ(ERR_DH_SCREEN_TRANS_ILLEGAL_OPERATION, dataChannelImpl_->ReleaseSession()); } /** @@ -104,7 +103,6 @@ HWTEST_F(ScreenDataChannelImplTest, OpenSession_001, TestSize.Level1) HWTEST_F(ScreenDataChannelImplTest, OpenSession_002, TestSize.Level1) { dataChannelImpl_->SetJpegSessionFlag(true); - int32_t ret = dataChannelImpl_->OpenSession(); EXPECT_EQ(ERR_DH_SCREEN_TRANS_ERROR, ret); -- Gitee From e050a9476324a8bdab31ef3f77d4e97811e1fa85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=9B=B7?= Date: Sat, 16 Sep 2023 07:48:22 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8D=E5=90=88?= =?UTF-8?q?=E7=90=86=E7=A9=BA=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张雷 --- .../src/screen_data_channel_impl_test.cpp | 9 --------- 1 file changed, 9 deletions(-) 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 1d018c03..afa7cf0b 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 @@ -48,7 +48,6 @@ HWTEST_F(ScreenDataChannelImplTest, CreateSession_001, TestSize.Level1) { std::shared_ptr listener = nullptr; int32_t ret = dataChannelImpl_->CreateSession(listener); - EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, ret); } @@ -63,7 +62,6 @@ HWTEST_F(ScreenDataChannelImplTest, CreateSession_002, TestSize.Level1) std::shared_ptr listener = std::make_shared(); dataChannelImpl_->jpegSessionFlag_ = false; int32_t ret = dataChannelImpl_->CreateSession(listener); - EXPECT_EQ(-1, ret); } @@ -77,7 +75,6 @@ HWTEST_F(ScreenDataChannelImplTest, ReleaseSession_001, TestSize.Level1) { std::shared_ptr listener = std::make_shared(); dataChannelImpl_->SetJpegSessionFlag(true); - EXPECT_EQ(ERR_DH_SCREEN_TRANS_ILLEGAL_OPERATION, dataChannelImpl_->ReleaseSession()); } @@ -90,7 +87,6 @@ HWTEST_F(ScreenDataChannelImplTest, ReleaseSession_001, TestSize.Level1) HWTEST_F(ScreenDataChannelImplTest, OpenSession_001, TestSize.Level1) { int32_t ret = dataChannelImpl_->OpenSession(); - EXPECT_EQ(ERR_DH_SCREEN_TRANS_ERROR, ret); } @@ -104,7 +100,6 @@ HWTEST_F(ScreenDataChannelImplTest, OpenSession_002, TestSize.Level1) { dataChannelImpl_->SetJpegSessionFlag(true); int32_t ret = dataChannelImpl_->OpenSession(); - EXPECT_EQ(ERR_DH_SCREEN_TRANS_ERROR, ret); } @@ -118,7 +113,6 @@ HWTEST_F(ScreenDataChannelImplTest, SendFullData_001, TestSize.Level1) { std::shared_ptr screenData = nullptr; int32_t ret = dataChannelImpl_->SendFullData(screenData); - EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, ret); } @@ -133,7 +127,6 @@ HWTEST_F(ScreenDataChannelImplTest, SendFullData_002, TestSize.Level1) std::shared_ptr data = std::make_shared(10); dataChannelImpl_->sessionId_ = 1; int32_t ret = dataChannelImpl_->SendFullData(data); - EXPECT_EQ(ERR_DH_SCREEN_TRANS_ERROR, ret); } @@ -147,7 +140,6 @@ HWTEST_F(ScreenDataChannelImplTest, SendDirtyData_001, TestSize.Level1) { std::shared_ptr screenData = nullptr; int32_t ret = dataChannelImpl_->SendDirtyData(screenData); - EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, ret); } @@ -162,7 +154,6 @@ HWTEST_F(ScreenDataChannelImplTest, SendDirtyData_002, TestSize.Level1) std::shared_ptr data = std::make_shared(10); dataChannelImpl_->jpegSessionId_ = 1; int32_t ret = dataChannelImpl_->SendFullData(data); - EXPECT_EQ(ERR_DH_SCREEN_TRANS_ERROR, ret); } -- Gitee