| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/bind.h" |
| 6 #include "base/run_loop.h" |
| 7 #include "media/base/android/media_codec_util.h" |
| 8 #include "media/base/test_helpers.h" |
| 9 #include "media/gpu/android/media_codec_video_decoder.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 #define SKIP_IF_MEDIA_CODEC_IS_BLACKLISTED() \ |
| 13 do { \ |
| 14 if (!MediaCodecUtil::IsMediaCodecAvailable()) { \ |
| 15 DVLOG(0) << "Skipping test: MediaCodec is blacklisted on this device"; \ |
| 16 return; \ |
| 17 } \ |
| 18 } while (0) |
| 19 |
| 20 namespace media { |
| 21 namespace { |
| 22 |
| 23 void InitCb(bool* result_out, bool result) { |
| 24 *result_out = result; |
| 25 } |
| 26 |
| 27 void OutputCb(const scoped_refptr<VideoFrame>& frame) {} |
| 28 |
| 29 } // namespace |
| 30 |
| 31 class MediaCodecVideoDecoderTest : public testing::Test { |
| 32 public: |
| 33 ~MediaCodecVideoDecoderTest() override {} |
| 34 |
| 35 bool Initialize(const VideoDecoderConfig& config) { |
| 36 bool result = false; |
| 37 mcvd_.Initialize(config, false, nullptr, base::Bind(&InitCb, &result), |
| 38 base::Bind(&OutputCb)); |
| 39 base::RunLoop().RunUntilIdle(); |
| 40 return result; |
| 41 } |
| 42 |
| 43 private: |
| 44 MediaCodecVideoDecoder mcvd_; |
| 45 base::MessageLoop message_loop_; |
| 46 }; |
| 47 |
| 48 TEST_F(MediaCodecVideoDecoderTest, DestructWithoutInit) { |
| 49 // Do nothing. |
| 50 } |
| 51 |
| 52 TEST_F(MediaCodecVideoDecoderTest, UnknownCodecIsRejected) { |
| 53 SKIP_IF_MEDIA_CODEC_IS_BLACKLISTED(); |
| 54 ASSERT_FALSE(Initialize(TestVideoConfig::Invalid())); |
| 55 } |
| 56 |
| 57 TEST_F(MediaCodecVideoDecoderTest, H264IsSupported) { |
| 58 SKIP_IF_MEDIA_CODEC_IS_BLACKLISTED(); |
| 59 // H264 is always supported by MCVD. |
| 60 ASSERT_TRUE(Initialize(TestVideoConfig::NormalH264())); |
| 61 } |
| 62 |
| 63 TEST_F(MediaCodecVideoDecoderTest, SmallVp8IsRejected) { |
| 64 SKIP_IF_MEDIA_CODEC_IS_BLACKLISTED(); |
| 65 ASSERT_TRUE(Initialize(TestVideoConfig::NormalH264())); |
| 66 } |
| 67 |
| 68 } // namespace media |
| OLD | NEW |