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..5858b1e7676f4922954cc188700e864738b644bb |
--- /dev/null |
+++ b/ppapi/tests/test_video_decoder.cc |
@@ -0,0 +1,77 @@ |
+// 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/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); |
+} |
+ |
+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. |
+ // Accept PP_ERROR_NOTSUPPORTED since some platforms may not support VP8. |
Ami GONE FROM CHROMIUM
2014/06/06 17:14:33
how's that?
(all shipping chromes support VP8 exce
bbudge
2014/06/07 00:31:08
I did this because the Create success test was fai
|
+ { |
+ 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 || |
+ callback.result() == PP_ERROR_NOTSUPPORTED); |
+ } |
+ |
+ PASS(); |
+} |