OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ppapi/tests/test_video_decoder.h" |
| 6 |
| 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/cpp/graphics_3d.h" |
| 9 #include "ppapi/cpp/video_decoder.h" |
| 10 #include "ppapi/lib/gl/gles2/gl2ext_ppapi.h" |
| 11 #include "ppapi/tests/testing_instance.h" |
| 12 |
| 13 REGISTER_TEST_CASE(VideoDecoder); |
| 14 |
| 15 static const bool kAllowSoftwareFallback = true; |
| 16 |
| 17 bool TestVideoDecoder::Init() { |
| 18 // Initialize GL so we can create a shareable Graphics3D resource. |
| 19 glInitializePPAPI(pp::Module::Get()->get_browser_interface()); |
| 20 |
| 21 video_decoder_interface_ = static_cast<const PPB_VideoDecoder_0_1*>( |
| 22 pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_INTERFACE_0_1)); |
| 23 return video_decoder_interface_ && CheckTestingInterface(); |
| 24 } |
| 25 |
| 26 void TestVideoDecoder::RunTests(const std::string& filter) { |
| 27 RUN_CALLBACK_TEST(TestVideoDecoder, Create, filter); |
| 28 // TODO(bbudge) More tests when we have a way to generate test pattern video. |
| 29 } |
| 30 |
| 31 std::string TestVideoDecoder::TestCreate() { |
| 32 // Test that Initialize fails with a bad Graphics3D resource. |
| 33 { |
| 34 pp::VideoDecoder video_decoder(instance_); |
| 35 ASSERT_FALSE(video_decoder.is_null()); |
| 36 |
| 37 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
| 38 pp::Graphics3D context; // null context |
| 39 callback.WaitForResult(video_decoder.Initialize(context, |
| 40 PP_VIDEOPROFILE_VP8MAIN, |
| 41 kAllowSoftwareFallback, |
| 42 callback.GetCallback())); |
| 43 ASSERT_EQ(PP_ERROR_BADRESOURCE, callback.result()); |
| 44 } |
| 45 // Test that Initialize fails with a bad profile enum value. |
| 46 { |
| 47 pp::VideoDecoder video_decoder(instance_); |
| 48 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
| 49 const int width = 16; |
| 50 const int height = 16; |
| 51 const int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, width, |
| 52 PP_GRAPHICS3DATTRIB_HEIGHT, height, |
| 53 PP_GRAPHICS3DATTRIB_NONE}; |
| 54 pp::Graphics3D context(instance_, attribs); |
| 55 const PP_VideoProfile kInvalidProfile = static_cast<PP_VideoProfile>(-1); |
| 56 callback.WaitForResult(video_decoder.Initialize(context, |
| 57 kInvalidProfile, |
| 58 kAllowSoftwareFallback, |
| 59 callback.GetCallback())); |
| 60 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result()); |
| 61 } |
| 62 // Test that Initialize succeeds when we allow software fallback to VP8, which |
| 63 // should always be supported. |
| 64 { |
| 65 pp::VideoDecoder video_decoder(instance_); |
| 66 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
| 67 const int width = 16; |
| 68 const int height = 16; |
| 69 const int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, width, |
| 70 PP_GRAPHICS3DATTRIB_HEIGHT, height, |
| 71 PP_GRAPHICS3DATTRIB_NONE}; |
| 72 pp::Graphics3D context(instance_, attribs); |
| 73 callback.WaitForResult(video_decoder.Initialize(context, |
| 74 PP_VIDEOPROFILE_VP8MAIN, |
| 75 kAllowSoftwareFallback, |
| 76 callback.GetCallback())); |
| 77 ASSERT_EQ(PP_OK, callback.result()); |
| 78 } |
| 79 |
| 80 PASS(); |
| 81 } |
OLD | NEW |