Commit 7fa9f4ce authored by watk's avatar watk Committed by Commit bot

media: Add a unittest for MediaCodecVideoDecoder

BUG=660942
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2561653002
Cr-Commit-Position: refs/heads/master@{#437663}
parent ce1a32c1
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/bind.h"
#include "base/run_loop.h"
#include "media/base/android/media_codec_util.h"
#include "media/base/test_helpers.h"
#include "media/gpu/android/media_codec_video_decoder.h"
#include "testing/gtest/include/gtest/gtest.h"
#define SKIP_IF_MEDIA_CODEC_IS_BLACKLISTED() \
do { \
if (!MediaCodecUtil::IsMediaCodecAvailable()) { \
DVLOG(0) << "Skipping test: MediaCodec is blacklisted on this device"; \
return; \
} \
} while (0)
namespace media {
namespace {
void InitCb(bool* result_out, bool result) {
*result_out = result;
}
void OutputCb(const scoped_refptr<VideoFrame>& frame) {}
} // namespace
class MediaCodecVideoDecoderTest : public testing::Test {
public:
~MediaCodecVideoDecoderTest() override {}
bool Initialize(const VideoDecoderConfig& config) {
bool result = false;
mcvd_.Initialize(config, false, nullptr, base::Bind(&InitCb, &result),
base::Bind(&OutputCb));
base::RunLoop().RunUntilIdle();
return result;
}
private:
MediaCodecVideoDecoder mcvd_;
base::MessageLoop message_loop_;
};
TEST_F(MediaCodecVideoDecoderTest, DestructWithoutInit) {
// Do nothing.
}
TEST_F(MediaCodecVideoDecoderTest, UnknownCodecIsRejected) {
SKIP_IF_MEDIA_CODEC_IS_BLACKLISTED();
ASSERT_FALSE(Initialize(TestVideoConfig::Invalid()));
}
TEST_F(MediaCodecVideoDecoderTest, H264IsSupported) {
SKIP_IF_MEDIA_CODEC_IS_BLACKLISTED();
// H264 is always supported by MCVD.
ASSERT_TRUE(Initialize(TestVideoConfig::NormalH264()));
}
TEST_F(MediaCodecVideoDecoderTest, SmallVp8IsRejected) {
SKIP_IF_MEDIA_CODEC_IS_BLACKLISTED();
ASSERT_TRUE(Initialize(TestVideoConfig::NormalH264()));
}
} // namespace media
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment