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

Unified Diff: ppapi/tests/test_video_decoder.cc

Issue 213313003: Experimental patch for MediaCodec APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update. Requires chromium @r273920 Created 6 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 | « ppapi/tests/test_video_decoder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_video_decoder.cc
diff --git a/ppapi/tests/test_video_decoder.cc b/ppapi/tests/test_video_decoder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..77e3031bee179ea77c26ba9439dbb5a3d1c88954
--- /dev/null
+++ b/ppapi/tests/test_video_decoder.cc
@@ -0,0 +1,109 @@
+// Copyright (c) 2014 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 "ppapi/tests/test_video_decoder.h"
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/ppb_var.h"
+#include "ppapi/cpp/graphics_3d.h"
+#include "ppapi/cpp/video_decoder.h"
+#include "ppapi/tests/testing_instance.h"
+
+REGISTER_TEST_CASE(VideoDecoder);
+
+static const bool kAllowSoftwareFallback = true;
+
+bool TestVideoDecoder::Init() {
+ video_decoder_interface_ = static_cast<const PPB_VideoDecoder_0_1*>(
+ pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_INTERFACE_0_1));
+ return video_decoder_interface_ && CheckTestingInterface();
+}
+
+void TestVideoDecoder::RunTests(const std::string& filter) {
+ RUN_CALLBACK_TEST(TestVideoDecoder, Create, filter);
+}
+
+void TestVideoDecoder::QuitMessageLoop() {
+ testing_interface_->QuitMessageLoop(instance_->pp_instance());
+}
+
+std::string TestVideoDecoder::TestCreate() {
+ // Test that Initialize fails with a bad Graphics3D resource.
+ {
+ pp::VideoDecoder video_decoder(instance_);
+ ASSERT_FALSE(video_decoder.is_null());
+
+ TestCompletionCallback callback(instance_->pp_instance(), callback_type());
+ pp::Graphics3D context; // null context
+ callback.WaitForResult(video_decoder.Initialize(context,
+ PP_VIDEOPROFILE_VP8MAIN,
+ kAllowSoftwareFallback,
+ callback.GetCallback()));
+ ASSERT_EQ(PP_ERROR_BADRESOURCE, callback.result());
+ }
+ // Test that Initialize fails with a bad profile enum value.
+ {
+ pp::VideoDecoder video_decoder(instance_);
+ TestCompletionCallback callback(instance_->pp_instance(), callback_type());
+ const int width = 16;
+ const int height = 16;
+ const int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, width,
+ PP_GRAPHICS3DATTRIB_HEIGHT, height,
+ PP_GRAPHICS3DATTRIB_NONE};
+ pp::Graphics3D context(instance_, attribs);
+ const PP_VideoProfile kInvalidProfile = static_cast<PP_VideoProfile>(-1);
+ callback.WaitForResult(video_decoder.Initialize(context,
+ kInvalidProfile,
+ kAllowSoftwareFallback,
+ callback.GetCallback()));
+ ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result());
+ }
+ // Test that Initialize succeeds when we allow software fallback to VP8.
+ {
+ pp::VideoDecoder video_decoder(instance_);
+ TestCompletionCallback callback(instance_->pp_instance(), callback_type());
+ const int width = 16;
+ const int height = 16;
+ const int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, width,
+ PP_GRAPHICS3DATTRIB_HEIGHT, height,
+ PP_GRAPHICS3DATTRIB_NONE};
+ pp::Graphics3D context(instance_, attribs);
+ callback.WaitForResult(video_decoder.Initialize(context,
+ PP_VIDEOPROFILE_VP8MAIN,
+ kAllowSoftwareFallback,
+ callback.GetCallback()));
+ ASSERT_TRUE(callback.result() == PP_OK);
+ }
+
+ PASS();
+}
+
+// std::string TestVideoDecoder::TestGetBitstreamBuffer() {
+// pp::VideoDecoder video_decoder(instance_);
+// TestCompletionCallback callback1(instance_->pp_instance(),
+// callback_type());
+// const int width = 16;
+// const int height = 16;
+// const int32_t attribs[] = {
+// PP_GRAPHICS3DATTRIB_WIDTH, width,
+// PP_GRAPHICS3DATTRIB_HEIGHT, height,
+// PP_GRAPHICS3DATTRIB_NONE
+// };
+// pp::Graphics3D context(instance_, attribs);
+// callback1.WaitForResult(
+// video_decoder.Initialize(&context,
+// PP_VIDEOPROFILE_VP8MAIN,
+// callback1.GetCallback()));
+// TestCompletionCallbackWithOutput<PP__BitstreamBuffer> callback2(
+// instance_->pp_instance(), callback_type());
+// callback2.WaitForResult(
+// video_decoder.GetBitstreamBuffer(1024,
+// callback2.GetCallback()));
+// ASSERT_EQ(PP_OK, callback2.result());
+// const PP__BitstreamBuffer& bitstream_buffer = callback2.output();
+// ASSERT_EQ(1024, bitstream_buffer.size);
+// ASSERT_NE(NULL, bitstream_buffer.addr);
+
+// PASS();
+// }
« no previous file with comments | « ppapi/tests/test_video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698