OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/tests/test_video_decoder.h" | 5 #include "ppapi/tests/test_video_decoder.h" |
6 | 6 |
7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
8 #include "ppapi/cpp/video_decoder.h" | 8 #include "ppapi/cpp/video_decoder.h" |
9 #include "ppapi/lib/gl/gles2/gl2ext_ppapi.h" | 9 #include "ppapi/lib/gl/gles2/gl2ext_ppapi.h" |
10 #include "ppapi/tests/testing_instance.h" | 10 #include "ppapi/tests/testing_instance.h" |
11 | 11 |
| 12 const uint32_t kMaxRequestedPictureCount = 100; |
| 13 |
12 REGISTER_TEST_CASE(VideoDecoder); | 14 REGISTER_TEST_CASE(VideoDecoder); |
13 | 15 |
14 bool TestVideoDecoder::Init() { | 16 bool TestVideoDecoder::Init() { |
15 video_decoder_interface_ = static_cast<const PPB_VideoDecoder_0_1*>( | |
16 pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_INTERFACE_0_1)); | |
17 const int width = 16; | 17 const int width = 16; |
18 const int height = 16; | 18 const int height = 16; |
19 const int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, width, | 19 const int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, width, |
20 PP_GRAPHICS3DATTRIB_HEIGHT, height, | 20 PP_GRAPHICS3DATTRIB_HEIGHT, height, |
21 PP_GRAPHICS3DATTRIB_NONE}; | 21 PP_GRAPHICS3DATTRIB_NONE}; |
22 graphics_3d_ = pp::Graphics3D(instance_, attribs); | 22 graphics_3d_ = pp::Graphics3D(instance_, attribs); |
23 return video_decoder_interface_ && CheckTestingInterface(); | 23 return (pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_INTERFACE) && |
| 24 CheckTestingInterface()); |
24 } | 25 } |
25 | 26 |
26 void TestVideoDecoder::RunTests(const std::string& filter) { | 27 void TestVideoDecoder::RunTests(const std::string& filter) { |
27 RUN_CALLBACK_TEST(TestVideoDecoder, Create, filter); | 28 RUN_CALLBACK_TEST(TestVideoDecoder, Create, filter); |
28 } | 29 } |
29 | 30 |
30 std::string TestVideoDecoder::TestCreate() { | 31 std::string TestVideoDecoder::TestCreate() { |
31 // Test that Initialize fails with a bad Graphics3D resource. | 32 // Test that Initialize fails with a bad Graphics3D resource. |
32 { | 33 { |
33 pp::VideoDecoder video_decoder(instance_); | 34 pp::VideoDecoder video_decoder(instance_); |
(...skipping 25 matching lines...) Expand all Loading... |
59 if (!graphics_3d_.is_null()) { | 60 if (!graphics_3d_.is_null()) { |
60 pp::VideoDecoder video_decoder(instance_); | 61 pp::VideoDecoder video_decoder(instance_); |
61 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); | 62 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
62 callback.WaitForResult( | 63 callback.WaitForResult( |
63 video_decoder.Initialize(graphics_3d_, | 64 video_decoder.Initialize(graphics_3d_, |
64 PP_VIDEOPROFILE_VP8_ANY, | 65 PP_VIDEOPROFILE_VP8_ANY, |
65 PP_HARDWAREACCELERATION_WITHFALLBACK, | 66 PP_HARDWAREACCELERATION_WITHFALLBACK, |
66 callback.GetCallback())); | 67 callback.GetCallback())); |
67 ASSERT_EQ(PP_OK, callback.result()); | 68 ASSERT_EQ(PP_OK, callback.result()); |
68 } | 69 } |
| 70 // Test that Initialize succeeds with a larger than normal number of requested |
| 71 // picture buffers, if we can create a Graphics3D resources and if we allow |
| 72 // software fallback to VP8, which should always be supported. |
| 73 if (!graphics_3d_.is_null()) { |
| 74 pp::VideoDecoder video_decoder(instance_); |
| 75 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
| 76 callback.WaitForResult( |
| 77 video_decoder.Initialize(graphics_3d_, |
| 78 PP_VIDEOPROFILE_VP8_ANY, |
| 79 PP_HARDWAREACCELERATION_WITHFALLBACK, |
| 80 kMaxRequestedPictureCount, |
| 81 callback.GetCallback())); |
| 82 ASSERT_EQ(PP_OK, callback.result()); |
| 83 } |
| 84 // Test that Initialize fails if we request an unreasonable number of picture |
| 85 // buffers. |
| 86 if (!graphics_3d_.is_null()) { |
| 87 pp::VideoDecoder video_decoder(instance_); |
| 88 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
| 89 callback.WaitForResult( |
| 90 video_decoder.Initialize(graphics_3d_, |
| 91 PP_VIDEOPROFILE_VP8_ANY, |
| 92 PP_HARDWAREACCELERATION_WITHFALLBACK, |
| 93 kMaxRequestedPictureCount + 1, |
| 94 callback.GetCallback())); |
| 95 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result()); |
| 96 } |
69 | 97 |
70 PASS(); | 98 PASS(); |
71 } | 99 } |
OLD | NEW |