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