diff --git a/frameworks/native/player/test/unittest/include/player_mock.h b/frameworks/native/player/test/unittest/include/player_mock.h index 2fcaa6bccea165ee60f9bf125e46be13802b18aa..9e6b676d0419eb93388fe8ddcd6975811acb8af3 100644 --- a/frameworks/native/player/test/unittest/include/player_mock.h +++ b/frameworks/native/player/test/unittest/include/player_mock.h @@ -179,6 +179,8 @@ public: int32_t EnableReportMediaProgress(bool enable); void ReleaseClientListener(); int32_t EnableReportAudioInterrupt(bool enable); + int32_t SetSeiMessageCbStatus(bool status, const std::vector &payloadTypes); + int32_t SetStartFrameRateOptEnabled(bool enabled); private: void SeekPrepare(int32_t &mseconds, PlayerSeekMode &mode); std::shared_ptr player_ = nullptr; diff --git a/frameworks/native/player/test/unittest/src/player_mock.cpp b/frameworks/native/player/test/unittest/src/player_mock.cpp index 7e4706446160980c402d6891079b979935e69c31..51fa69edd8fe426bc0d03bc24154a8a23412dc4c 100644 --- a/frameworks/native/player/test/unittest/src/player_mock.cpp +++ b/frameworks/native/player/test/unittest/src/player_mock.cpp @@ -855,5 +855,17 @@ void PlayerMock::ReleaseClientListener() UNITTEST_CHECK_AND_RETURN_LOG(player_ != nullptr, "player_ == nullptr"); player_->ReleaseClientListener(); } + +int32_t PlayerMock::SetSeiMessageCbStatus(bool status, const std::vector &payloadTypes) +{ + UNITTEST_CHECK_AND_RETURN_RET_LOG(player_ != nullptr, -1, "player_ == nullptr"); + return player_->SetSeiMessageCbStatus(status, payloadTypes); +} + +int32_t PlayerMock::SetStartFrameRateOptEnabled(bool enabled) +{ + UNITTEST_CHECK_AND_RETURN_RET_LOG(player_ != nullptr, -1, "player_ == nullptr"); + return player_->SetStartFrameRateOptEnabled(enabled); +} } // namespace Media } // namespace OHOS diff --git a/frameworks/native/player/test/unittest/src/player_unit_test.cpp b/frameworks/native/player/test/unittest/src/player_unit_test.cpp index e8a75c839c16c38fac3a2a23a43abfd621849c04..3e731492f596a30a7309a664f6976b0bbdee2a94 100644 --- a/frameworks/native/player/test/unittest/src/player_unit_test.cpp +++ b/frameworks/native/player/test/unittest/src/player_unit_test.cpp @@ -4741,5 +4741,238 @@ HWTEST_F(PlayerUnitTest, Player_EnableReportMediaProgress_004, TestSize.Level0) ASSERT_EQ(MSERR_OK, player_->EnableReportMediaProgress(true)); EXPECT_EQ(MSERR_OK, player_->Play()); } + + +/** + * @tc.name : Test SetSeiMessageCbStatus API - Basic functionality + * @tc.number: Player_SetSeiMessageCbStatus_001 + * @tc.desc : Test SetSeiMessageCbStatus basic enable/disable functionality + */ +HWTEST_F(PlayerUnitTest, Player_SetSeiMessageCbStatus_001, TestSize.Level0) +{ + std::vector payloadTypes = {1, 2, 3, 4, 5}; + ASSERT_EQ(MSERR_OK, player_->SetSource(VIDEO_FILE1)); + + // Test enable SEI message callback + ASSERT_EQ(MSERR_OK, player_->SetSeiMessageCbStatus(true, payloadTypes)); + + // Test disable SEI message callback + ASSERT_EQ(MSERR_OK, player_->SetSeiMessageCbStatus(false, payloadTypes)); + + // Test enable again with different payload types + std::vector newPayloadTypes = {6, 7, 8}; + ASSERT_EQ(MSERR_OK, player_->SetSeiMessageCbStatus(true, newPayloadTypes)); +} + +/** + * @tc.name : Test SetSeiMessageCbStatus API - Empty payload types + * @tc.number: Player_SetSeiMessageCbStatus_002 + * @tc.desc : Test SetSeiMessageCbStatus with empty payload types vector + */ +HWTEST_F(PlayerUnitTest, Player_SetSeiMessageCbStatus_002, TestSize.Level1) +{ + std::vector emptyPayloadTypes = {}; + ASSERT_EQ(MSERR_OK, player_->SetSource(VIDEO_FILE1)); + + // Test with empty payload types + ASSERT_EQ(MSERR_OK, player_->SetSeiMessageCbStatus(true, emptyPayloadTypes)); + ASSERT_EQ(MSERR_OK, player_->SetSeiMessageCbStatus(false, emptyPayloadTypes)); + + sptr videoSurface = player_->GetVideoSurface(); + ASSERT_NE(nullptr, videoSurface); + EXPECT_EQ(MSERR_OK, player_->SetVideoSurface(videoSurface)); + EXPECT_EQ(MSERR_OK, player_->Prepare()); + EXPECT_EQ(MSERR_OK, player_->Play()); + sleep(PLAYING_TIME_2_SEC); + EXPECT_EQ(MSERR_OK, player_->Stop()); +} + +/** + * @tc.name : Test SetSeiMessageCbStatus API - Large payload types + * @tc.number: Player_SetSeiMessageCbStatus_003 + * @tc.desc : Test SetSeiMessageCbStatus with large number of payload types + */ +HWTEST_F(PlayerUnitTest, Player_SetSeiMessageCbStatus_003, TestSize.Level1) +{ + std::vector largePayloadTypes = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + ASSERT_EQ(MSERR_OK, player_->SetSource(VIDEO_FILE1)); + + // Test with large number of payload types + ASSERT_EQ(MSERR_OK, player_->SetSeiMessageCbStatus(true, largePayloadTypes)); + ASSERT_EQ(MSERR_OK, player_->SetSeiMessageCbStatus(false, largePayloadTypes)); + + sptr videoSurface = player_->GetVideoSurface(); + ASSERT_NE(nullptr, videoSurface); + EXPECT_EQ(MSERR_OK, player_->SetVideoSurface(videoSurface)); + EXPECT_EQ(MSERR_OK, player_->Prepare()); + EXPECT_EQ(MSERR_OK, player_->Play()); + sleep(PLAYING_TIME_2_SEC); + EXPECT_EQ(MSERR_OK, player_->Stop()); +} + +/** + * @tc.name : Test SetSuperResolution API - Basic functionality + * @tc.number: Player_SetSuperResolution_005 + * @tc.desc : Test SetSuperResolution basic enable/disable functionality + */ +HWTEST_F(PlayerUnitTest, Player_SetSuperResolution_005, TestSize.Level0) +{ + AVPlayStrategy playbackStrategy = { + .enableSuperResolution = true + }; + ASSERT_EQ(MSERR_OK, player_->SetSource(VIDEO_FILE1)); + ASSERT_EQ(MSERR_OK, player_->SetPlaybackStrategy(playbackStrategy)); + + // Test enable super resolution + ASSERT_EQ(MSERR_OK, player_->SetSuperResolution(true)); + + // Test disable super resolution + ASSERT_EQ(MSERR_OK, player_->SetSuperResolution(false)); + + // Test enable again + ASSERT_EQ(MSERR_OK, player_->SetSuperResolution(true)); + + sptr videoSurface = player_->GetVideoSurface(); + ASSERT_NE(nullptr, videoSurface); + EXPECT_EQ(MSERR_OK, player_->SetVideoSurface(videoSurface)); + EXPECT_EQ(MSERR_OK, player_->Prepare()); + EXPECT_EQ(MSERR_OK, player_->Play()); + sleep(PLAYING_TIME_2_SEC); + EXPECT_EQ(MSERR_OK, player_->Stop()); +} + +/** + * @tc.name : Test SetSuperResolution API - Multiple enable/disable cycles + * @tc.number: Player_SetSuperResolution_006 + * @tc.desc : Test SetSuperResolution with multiple enable/disable cycles + */ +HWTEST_F(PlayerUnitTest, Player_SetSuperResolution_006, TestSize.Level1) +{ + AVPlayStrategy playbackStrategy = { + .enableSuperResolution = true + }; + ASSERT_EQ(MSERR_OK, player_->SetSource(VIDEO_FILE1)); + ASSERT_EQ(MSERR_OK, player_->SetPlaybackStrategy(playbackStrategy)); + + // Multiple enable/disable cycles + ASSERT_EQ(MSERR_OK, player_->SetSuperResolution(true)); + ASSERT_EQ(MSERR_OK, player_->SetSuperResolution(false)); + ASSERT_EQ(MSERR_OK, player_->SetSuperResolution(true)); + ASSERT_EQ(MSERR_OK, player_->SetSuperResolution(false)); + ASSERT_EQ(MSERR_OK, player_->SetSuperResolution(true)); + ASSERT_EQ(MSERR_OK, player_->SetSuperResolution(false)); + ASSERT_EQ(MSERR_OK, player_->SetSuperResolution(true)); + + sptr videoSurface = player_->GetVideoSurface(); + ASSERT_NE(nullptr, videoSurface); + EXPECT_EQ(MSERR_OK, player_->SetVideoSurface(videoSurface)); + EXPECT_EQ(MSERR_OK, player_->Prepare()); + EXPECT_EQ(MSERR_OK, player_->Play()); + sleep(PLAYING_TIME_2_SEC); + EXPECT_EQ(MSERR_OK, player_->Stop()); +} + +/** + * @tc.name : Test SetSuperResolution API - Without super resolution enabled + * @tc.number: Player_SetSuperResolution_007 + * @tc.desc : Test SetSuperResolution when super resolution is not enabled in strategy + */ +HWTEST_F(PlayerUnitTest, Player_SetSuperResolution_007, TestSize.Level1) +{ + ASSERT_EQ(MSERR_OK, player_->SetSource(VIDEO_FILE1)); + + // Should fail when super resolution is not enabled in strategy + ASSERT_EQ(MSERR_SUPER_RESOLUTION_NOT_ENABLED, player_->SetSuperResolution(true)); + ASSERT_EQ(MSERR_SUPER_RESOLUTION_NOT_ENABLED, player_->SetSuperResolution(false)); + + sptr videoSurface = player_->GetVideoSurface(); + ASSERT_NE(nullptr, videoSurface); + EXPECT_EQ(MSERR_OK, player_->SetVideoSurface(videoSurface)); + EXPECT_EQ(MSERR_OK, player_->Prepare()); + EXPECT_EQ(MSERR_OK, player_->Play()); + sleep(PLAYING_TIME_2_SEC); + EXPECT_EQ(MSERR_OK, player_->Stop()); +} + +/** + * @tc.name : Test SetVideoWindowSize API - Basic functionality + * @tc.number: Player_SetVideoWindowSize_001 + * @tc.desc : Test SetVideoWindowSize basic functionality with common resolutions + */ +HWTEST_F(PlayerUnitTest, Player_SetVideoWindowSize_001, TestSize.Level0) +{ + AVPlayStrategy playbackStrategy = { + .enableSuperResolution = true + }; + ASSERT_EQ(MSERR_OK, player_->SetSource(VIDEO_FILE1)); + ASSERT_EQ(MSERR_OK, player_->SetPlaybackStrategy(playbackStrategy)); + + // Test common resolutions + ASSERT_EQ(MSERR_OK, player_->SetVideoWindowSize(1920, 1080)); // Full HD + ASSERT_EQ(MSERR_OK, player_->SetVideoWindowSize(1280, 720)); // HD + ASSERT_EQ(MSERR_OK, player_->SetVideoWindowSize(800, 600)); // SVGA + + sptr videoSurface = player_->GetVideoSurface(); + ASSERT_NE(nullptr, videoSurface); + EXPECT_EQ(MSERR_OK, player_->SetVideoSurface(videoSurface)); + EXPECT_EQ(MSERR_OK, player_->Prepare()); + EXPECT_EQ(MSERR_OK, player_->Play()); + sleep(PLAYING_TIME_2_SEC); + EXPECT_EQ(MSERR_OK, player_->Stop()); +} + +/** + * @tc.name : Test SetVideoWindowSize API - Extreme resolutions + * @tc.number: Player_SetVideoWindowSize_002 + * @tc.desc : Test SetVideoWindowSize with extreme resolution values + */ +HWTEST_F(PlayerUnitTest, Player_SetVideoWindowSize_002, TestSize.Level1) +{ + AVPlayStrategy playbackStrategy = { + .enableSuperResolution = true + }; + ASSERT_EQ(MSERR_OK, player_->SetSource(VIDEO_FILE1)); + ASSERT_EQ(MSERR_OK, player_->SetPlaybackStrategy(playbackStrategy)); + + // Test extreme resolutions + ASSERT_EQ(MSERR_OK, player_->SetVideoWindowSize(3840, 2160)); // 4K + ASSERT_EQ(MSERR_OK, player_->SetVideoWindowSize(320, 240)); // QVGA + ASSERT_EQ(MSERR_OK, player_->SetVideoWindowSize(160, 120)); // QQVGA + + sptr videoSurface = player_->GetVideoSurface(); + ASSERT_NE(nullptr, videoSurface); + EXPECT_EQ(MSERR_OK, player_->SetVideoSurface(videoSurface)); + EXPECT_EQ(MSERR_OK, player_->Prepare()); + EXPECT_EQ(MSERR_OK, player_->Play()); + sleep(PLAYING_TIME_2_SEC); + EXPECT_EQ(MSERR_OK, player_->Stop()); +} + +/** + * @tc.name : Test SetVideoWindowSize API - Non-standard aspect ratios + * @tc.number: Player_SetVideoWindowSize_003 + * @tc.desc : Test SetVideoWindowSize with non-standard aspect ratios + */ +HWTEST_F(PlayerUnitTest, Player_SetVideoWindowSize_003, TestSize.Level1) +{ + AVPlayStrategy playbackStrategy = { + .enableSuperResolution = true + }; + ASSERT_EQ(MSERR_OK, player_->SetSource(VIDEO_FILE1)); + ASSERT_EQ(MSERR_OK, player_->SetPlaybackStrategy(playbackStrategy)); + + // Test non-standard aspect ratios + ASSERT_EQ(MSERR_OK, player_->SetVideoWindowSize(1920, 1440)); // 4:3 + ASSERT_EQ(MSERR_OK, player_->SetVideoWindowSize(1440, 1080)); // 4:3 + ASSERT_EQ(MSERR_OK, player_->SetVideoWindowSize(960, 720)); // 4:3 + + sptr videoSurface = player_->GetVideoSurface(); + ASSERT_NE(nullptr, videoSurface); + EXPECT_EQ(MSERR_OK, player_->SetVideoSurface(videoSurface)); + EXPECT_EQ(MSERR_OK, player_->Prepare()); + EXPECT_EQ(MSERR_OK, player_->Play()); + sleep(PLAYING_TIME_2_SEC); + EXPECT_EQ(MSERR_OK, player_->Stop()); +} } // namespace Media } // namespace OHOS