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

Unified Diff: content/common/gpu/media/android_video_decode_accelerator_unittest.cc

Issue 14932020: Add Create() function to AudioCodecBridge and VideoCodecBridge to allow return of null pointers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove dependency, remove target in another CL Created 7 years, 7 months 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 | « content/common/gpu/media/android_video_decode_accelerator.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/media/android_video_decode_accelerator_unittest.cc
diff --git a/content/common/gpu/media/android_video_decode_accelerator_unittest.cc b/content/common/gpu/media/android_video_decode_accelerator_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..baf516d29e2324b5841148d88ab53e9f05b90629
--- /dev/null
+++ b/content/common/gpu/media/android_video_decode_accelerator_unittest.cc
@@ -0,0 +1,102 @@
+// Copyright (c) 2013 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 "content/common/gpu/media/android_video_decode_accelerator.h"
+
+#include "base/android/jni_android.h"
+#include "base/bind.h"
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/common/gpu/media/android_video_decode_accelerator.h"
+#include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
+#include "media/base/android/media_codec_bridge.h"
+#include "media/base/android/media_jni_registrar.h"
+#include "media/video/picture.h"
+#include "media/video/video_decode_accelerator.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gl/android/surface_texture_bridge.h"
+
+namespace {
+
+bool MockMakeContextCurrent() {
+ return true;
+}
+
+} // namespace
+
+namespace content {
+
+// TODO(felipeg): Add more unit tests to test the ordinary behavior of
+// AndroidVideoDecodeAccelerator.
+// http://crbug.com/178647
+class MockVideoDecodeAcceleratorClient
+ : public media::VideoDecodeAccelerator::Client {
+ public:
+ MockVideoDecodeAcceleratorClient() {};
+ virtual ~MockVideoDecodeAcceleratorClient() {};
+
+ // VideoDecodeAccelerator::Client implementation.
+ virtual void NotifyInitializeDone() OVERRIDE {};
+ virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers,
+ const gfx::Size& dimensions,
+ uint32 texture_target) OVERRIDE {};
+ virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE {};
+ virtual void PictureReady(const media::Picture& picture) OVERRIDE {};
+ virtual void NotifyEndOfBitstreamBuffer(
+ int32 bitstream_buffer_id) OVERRIDE {};
+ virtual void NotifyFlushDone() OVERRIDE {};
+ virtual void NotifyResetDone() OVERRIDE {};
+ virtual void NotifyError(
+ media::VideoDecodeAccelerator::Error error) OVERRIDE {};
+};
+
+class AndroidVideoDecodeAcceleratorTest : public testing::Test {
+ public:
+ virtual ~AndroidVideoDecodeAcceleratorTest() {}
+
+ protected:
+ virtual void SetUp() OVERRIDE {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ media::RegisterJni(env);
+ // TODO(felipeg): fix GL bindings, so that the decoder can perform GL
+ // calls.
+ scoped_ptr<gpu::gles2::MockGLES2Decoder> decoder(
+ new gpu::gles2::MockGLES2Decoder());
+ scoped_ptr<MockVideoDecodeAcceleratorClient> client(
+ new MockVideoDecodeAcceleratorClient());
+ accelerator_.reset(new AndroidVideoDecodeAccelerator(
+ client.get(), decoder->AsWeakPtr(),
+ base::Bind(&MockMakeContextCurrent)));
+ }
+
+ bool Configure(media::VideoCodec codec) {
+ AndroidVideoDecodeAccelerator* accelerator =
+ static_cast<AndroidVideoDecodeAccelerator*>(accelerator_.get());
+ accelerator->surface_texture_ = new gfx::SurfaceTextureBridge(0);
+ accelerator->codec_ = codec;
+ return accelerator->ConfigureMediaCodec();
+ }
+
+ private:
+ scoped_ptr<media::VideoDecodeAccelerator> accelerator_;
+};
+
+TEST_F(AndroidVideoDecodeAcceleratorTest, ConfigureUnsupportedCodec) {
+ if (!media::MediaCodecBridge::IsAvailable())
+ return;
+ EXPECT_FALSE(Configure(media::kUnknownVideoCodec));
+}
+
+TEST_F(AndroidVideoDecodeAcceleratorTest, ConfigureSupportedCodec) {
+ if (!media::MediaCodecBridge::IsAvailable())
+ return;
+ EXPECT_TRUE(Configure(media::kCodecVP8));
+}
+
+} // namespace content
+
+int main(int argc, char **argv) {
+ testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
« no previous file with comments | « content/common/gpu/media/android_video_decode_accelerator.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698