Chromium Code Reviews| 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..2f6606a3ee45ddef8ca8d86349a18dc2885bd9e5 |
| --- /dev/null |
| +++ b/ppapi/tests/test_video_decoder.cc |
| @@ -0,0 +1,76 @@ |
| +// 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/07 18:26:40
There are no chromium platforms that don't support
bbudge
2014/06/07 21:28:33
Yes, the 1 failure I see is because of a bad graph
|
| + { |
| + 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_EQ(PP_OK, callback.result()); |
| + } |
| + |
| + PASS(); |
| +} |