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

Unified Diff: ppapi/tests/test_video_decoder.cc

Issue 311853005: Implement software fallback for PPB_VideoDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use WeakPtr to tie VideoDecoderProxy and Delegate. Created 6 years, 6 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
« ppapi/tests/test_video_decoder.h ('K') | « 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..5a3607483301101bd89ae1cd5294d4e0010e65fa
--- /dev/null
+++ b/ppapi/tests/test_video_decoder.cc
@@ -0,0 +1,80 @@
+// 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"
dmichael (off chromium) 2014/06/05 23:00:43 nit: unused?
bbudge 2014/06/06 02:03:44 Done.
+#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());
+}
dmichael (off chromium) 2014/06/05 23:00:43 You don't seem to use this function
bbudge 2014/06/06 02:03:44 Done.
+
+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();
+}
« ppapi/tests/test_video_decoder.h ('K') | « ppapi/tests/test_video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698