Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(544)

Unified Diff: media/gpu/android/media_codec_video_decoder_unittest.cc

Issue 2561653002: media: Add a unittest for MediaCodecVideoDecoder (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/android/media_codec_video_decoder_unittest.cc
diff --git a/media/gpu/android/media_codec_video_decoder_unittest.cc b/media/gpu/android/media_codec_video_decoder_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7ce5e5da15f02c737c47afbeb0808645f7589389
--- /dev/null
+++ b/media/gpu/android/media_codec_video_decoder_unittest.cc
@@ -0,0 +1,68 @@
+// 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698