[TTVD] Add test for initialization video decoder without facade 95/321095/4
authorJakub Gajownik <j.gajownik2@samsung.com>
Mon, 18 Nov 2024 20:15:02 +0000 (21:15 +0100)
committerBot Blink <blinkbot@samsung.com>
Thu, 28 Nov 2024 05:58:56 +0000 (05:58 +0000)
In case video decoder cannot create facade for itself, it
should fail initialization with appropriate error.

Bug: https://jira-eu.sec.samsung.net/browse/VDGAME-625
Change-Id: Ibd5ad9756a7447e768dd5fadeece7c168cb65a28
Signed-off-by: Jakub Gajownik <j.gajownik2@samsung.com>
media/filters/tizen/ttvd_video_decoder_impl.cc
media/filters/tizen/ttvd_video_decoder_test.cc
packaging/chromium-efl.spec

index 7fba82433a5b2570e570cc204ab999ba33dd5f6c..cb4126d1203326a06d04de2869629691ebc93491 100644 (file)
@@ -1456,6 +1456,7 @@ void TTvdVideoDecoderImpl::OnInitializationDone(bool success) {
   decoder_state_ = (success ? DecoderState::kRunning : DecoderState::kError);
 
   if (!success) {
+    NotifyInitializationFailed();
     return;
   }
 
index 0113d3f7b970b0e4d1aae32a751efada6ba12f7b..eb6e52893fe18f7a155a7f552e948252a67860c3 100644 (file)
@@ -6,11 +6,13 @@
 
 #include "absl/types/optional.h"
 #include "base/at_exit.h"
+#include "base/test/mock_callback.h"
 #include "base/test/task_environment.h"
 #include "base/threading/thread.h"
 #include "base/tizen/global_resource_manager.h"
 #include "base/tizen/provider_callbacks_helper.h"
 #include "base/tizen/resource_manager.h"
+#include "media/base/test_data_util.h"
 #include "media/base/test_helpers.h"
 #include "media/filters/tizen/decoder_promotion.h"
 #include "media/filters/tizen/media_video_codec.h"
@@ -194,4 +196,65 @@ INSTANTIATE_TEST_SUITE_P(MultipleStartingStates,
                          TTvdVideoDecoderTestInitialize,
                          testing::ValuesIn(kPartialViewTests));
 
+TEST_F(TTvdVideoDecoderTest, DecodeStatusIsErrorWhenNullFacade) {
+  FakeResourceManager fake_resource_manager;
+  SetGlobalResourceManagerForTesting(&fake_resource_manager);
+  DecoderPromotion* decoder_promotion = DecoderPromotion::GetInstance();
+  decoder_promotion->SetResourceManagerForTesting(&fake_resource_manager);
+
+  base::test::TaskEnvironment task_environment{
+      base::test::TaskEnvironment::MainThreadType::IO};
+
+  base::Thread gpu_thread("gpu_thread");
+  ASSERT_TRUE(gpu_thread.StartAndWaitForTesting());
+
+  gpu::GpuDriverBugWorkarounds gpu_workarounds;
+
+  TTvdVideoDecoder video_decoder(
+      base::BindRepeating(
+          [](scoped_refptr<base::SingleThreadTaskRunner> task_runner)
+              -> scoped_refptr<CommandBufferHelper> {
+            return base::MakeRefCounted<FakeCommandBufferHelper>(task_runner);
+          },
+          gpu_thread.task_runner()),
+      gpu_thread.task_runner(),
+      base::BindRepeating(
+          [](const gpu::GpuDriverBugWorkarounds*)
+              -> std::unique_ptr<DecoderFacadeVideo> { return nullptr; }),
+      gpu_workarounds);
+
+  VideoDecoderConfig config = TestVideoConfig::NormalH264();
+  config.set_is_rtc(true);
+
+  constexpr const bool kLowLatency = true;
+  CdmContext* kNullCdmContextLowLatency = nullptr;
+
+  {
+    base::RunLoop run_loop;
+    video_decoder.Initialize(
+        config, kLowLatency, kNullCdmContextLowLatency,
+        base::BindOnce(
+            [](base::RunLoop* run_loop, DecoderStatus status) {
+              EXPECT_TRUE(status.is_ok());
+              run_loop->Quit();
+            },
+            &run_loop),
+        base::DoNothing(), base::DoNothing());
+    run_loop.Run();
+  }
+
+  {
+    auto buffer = ReadTestDataFile("h264-320x180-frame-0");
+    base::RunLoop run_loop;
+    base::MockCallback<VideoDecoder::DecodeCB> mock_decode_cb;
+    EXPECT_CALL(mock_decode_cb,
+                Run(DecoderStatus{DecoderStatus::Codes::kPlatformDecodeFailure}))
+        .WillOnce([&]() { run_loop.Quit(); });
+    video_decoder.Decode(buffer, mock_decode_cb.Get());
+    run_loop.Run();
+  }
+
+  gpu_thread.FlushForTesting();
+}
+
 }  // namespace media
index 4fdf10056666ab8e7ce438aa7bec8f13d9e08719..b3de81168e5a15bc3a297fb82f97c6ed753d2cf1 100644 (file)
@@ -1313,6 +1313,8 @@ install -m 0644 -p -D %{OUTPUT_FOLDER}/icudtl.dat %{buildroot}%{TIZEN_MEDIA_UT_D
 %endif
 install -m 0664 -p -D $PWD%{MEDIA_UT_DATA_DIR}bear.h264 \
                       %{buildroot}%{TIZEN_MEDIA_UT_DIR}%{MEDIA_UT_DATA_DIR}
+install -m 0664 -p -D $PWD%{MEDIA_UT_DATA_DIR}h264-320x180-frame-0 \
+                      %{buildroot}%{TIZEN_MEDIA_UT_DIR}%{MEDIA_UT_DATA_DIR}
 %endif
 
 %if 0%{?build_rtc_unittests}