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

Side by Side Diff: ppapi/tests/test_video_decoder.cc

Issue 1207043002: Introduce a client minimum picture pool size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
OLDNEW
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;
bbudge 2015/08/12 17:47:09 This could break if the constant ever changes in t
lpique 2015/08/12 22:48:54 I wrote the tests to test the boundary case. Alloc
bbudge 2015/08/12 23:39:22 A comment to connect the two is fine. Thanks.
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_);
34 ASSERT_FALSE(video_decoder.is_null()); 35 ASSERT_FALSE(video_decoder.is_null());
35 36
36 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); 37 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
37 pp::Graphics3D null_graphics_3d; 38 pp::Graphics3D null_graphics_3d;
38 callback.WaitForResult( 39 callback.WaitForResult(
39 video_decoder.Initialize(null_graphics_3d, 40 video_decoder.Initialize(null_graphics_3d,
40 PP_VIDEOPROFILE_VP8_ANY, 41 PP_VIDEOPROFILE_VP8_ANY,
41 PP_HARDWAREACCELERATION_WITHFALLBACK, 42 PP_HARDWAREACCELERATION_WITHFALLBACK,
43 0,
42 callback.GetCallback())); 44 callback.GetCallback()));
43 ASSERT_EQ(PP_ERROR_BADRESOURCE, callback.result()); 45 ASSERT_EQ(PP_ERROR_BADRESOURCE, callback.result());
44 } 46 }
45 // Test that Initialize fails with a bad profile enum value. 47 // Test that Initialize fails with a bad profile enum value.
46 { 48 {
47 pp::VideoDecoder video_decoder(instance_); 49 pp::VideoDecoder video_decoder(instance_);
48 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); 50 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
49 const PP_VideoProfile kInvalidProfile = static_cast<PP_VideoProfile>(-1); 51 const PP_VideoProfile kInvalidProfile = static_cast<PP_VideoProfile>(-1);
50 callback.WaitForResult( 52 callback.WaitForResult(
51 video_decoder.Initialize(graphics_3d_, 53 video_decoder.Initialize(graphics_3d_,
52 kInvalidProfile, 54 kInvalidProfile,
53 PP_HARDWAREACCELERATION_WITHFALLBACK, 55 PP_HARDWAREACCELERATION_WITHFALLBACK,
56 0,
54 callback.GetCallback())); 57 callback.GetCallback()));
55 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result()); 58 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result());
56 } 59 }
57 // Test that Initialize succeeds if we can create a Graphics3D resources and 60 // Test that Initialize succeeds if we can create a Graphics3D resources and
58 // if we allow software fallback to VP8, which should always be supported. 61 // if we allow software fallback to VP8, which should always be supported.
59 if (!graphics_3d_.is_null()) { 62 if (!graphics_3d_.is_null()) {
60 pp::VideoDecoder video_decoder(instance_); 63 pp::VideoDecoder video_decoder(instance_);
61 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); 64 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
62 callback.WaitForResult( 65 callback.WaitForResult(
63 video_decoder.Initialize(graphics_3d_, 66 video_decoder.Initialize(graphics_3d_,
64 PP_VIDEOPROFILE_VP8_ANY, 67 PP_VIDEOPROFILE_VP8_ANY,
65 PP_HARDWAREACCELERATION_WITHFALLBACK, 68 PP_HARDWAREACCELERATION_WITHFALLBACK,
69 0,
66 callback.GetCallback())); 70 callback.GetCallback()));
67 ASSERT_EQ(PP_OK, callback.result()); 71 ASSERT_EQ(PP_OK, callback.result());
68 } 72 }
73 // Test that Initialize succeeds with a larger than normal number of requested
74 // picture buffers, if we can create a Graphics3D resources and if we allow
bbudge 2015/08/12 17:47:09 nit s/resources/resource
lpique 2015/08/12 22:48:54 Done.
75 // software fallback to VP8, which should always be supported.
76 if (!graphics_3d_.is_null()) {
77 pp::VideoDecoder video_decoder(instance_);
78 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
79 callback.WaitForResult(
80 video_decoder.Initialize(graphics_3d_,
81 PP_VIDEOPROFILE_VP8_ANY,
82 PP_HARDWAREACCELERATION_WITHFALLBACK,
83 kMaxRequestedPictureCount,
84 callback.GetCallback()));
85 ASSERT_EQ(PP_OK, callback.result());
86 }
87 // Test that Initialize fails if we request an unreasonable number of picture
88 // buffers.
89 if (!graphics_3d_.is_null()) {
90 pp::VideoDecoder video_decoder(instance_);
91 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
92 callback.WaitForResult(
93 video_decoder.Initialize(graphics_3d_,
94 PP_VIDEOPROFILE_VP8_ANY,
95 PP_HARDWAREACCELERATION_WITHFALLBACK,
96 kMaxRequestedPictureCount + 1,
97 callback.GetCallback()));
98 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result());
99 }
69 100
70 PASS(); 101 PASS();
71 } 102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698