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

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: Moved constant to shared header, validate min_picture_size now in resource proxy as well as host co… 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
« no previous file with comments | « ppapi/tests/test_video_decoder.h ('k') | ppapi/thunk/interfaces_ppb_public_dev_channel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 namespace {
13
14 // The maximum number of pictures that the client can pass in for
15 // min_picture_count, just as a sanity check on the argument.
16 // This should match the value of kMaximumPictureCount in
17 // video_decoder_resource.cc.
18 const uint32_t kMaximumPictureCount = 100;
19
20 } // namespace
21
12 REGISTER_TEST_CASE(VideoDecoder); 22 REGISTER_TEST_CASE(VideoDecoder);
13 23
14 bool TestVideoDecoder::Init() { 24 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; 25 const int width = 16;
18 const int height = 16; 26 const int height = 16;
19 const int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, width, 27 const int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, width,
20 PP_GRAPHICS3DATTRIB_HEIGHT, height, 28 PP_GRAPHICS3DATTRIB_HEIGHT, height,
21 PP_GRAPHICS3DATTRIB_NONE}; 29 PP_GRAPHICS3DATTRIB_NONE};
22 graphics_3d_ = pp::Graphics3D(instance_, attribs); 30 graphics_3d_ = pp::Graphics3D(instance_, attribs);
23 return video_decoder_interface_ && CheckTestingInterface(); 31 return (pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_INTERFACE) &&
32 CheckTestingInterface());
24 } 33 }
25 34
26 void TestVideoDecoder::RunTests(const std::string& filter) { 35 void TestVideoDecoder::RunTests(const std::string& filter) {
27 RUN_CALLBACK_TEST(TestVideoDecoder, Create, filter); 36 RUN_CALLBACK_TEST(TestVideoDecoder, Create, filter);
28 } 37 }
29 38
30 std::string TestVideoDecoder::TestCreate() { 39 std::string TestVideoDecoder::TestCreate() {
31 // Test that Initialize fails with a bad Graphics3D resource. 40 // Test that Initialize fails with a bad Graphics3D resource.
32 { 41 {
33 pp::VideoDecoder video_decoder(instance_); 42 pp::VideoDecoder video_decoder(instance_);
34 ASSERT_FALSE(video_decoder.is_null()); 43 ASSERT_FALSE(video_decoder.is_null());
35 44
36 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); 45 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
37 pp::Graphics3D null_graphics_3d; 46 pp::Graphics3D null_graphics_3d;
38 callback.WaitForResult( 47 callback.WaitForResult(
39 video_decoder.Initialize(null_graphics_3d, 48 video_decoder.Initialize(null_graphics_3d,
40 PP_VIDEOPROFILE_VP8_ANY, 49 PP_VIDEOPROFILE_VP8_ANY,
41 PP_HARDWAREACCELERATION_WITHFALLBACK, 50 PP_HARDWAREACCELERATION_WITHFALLBACK,
51 0,
42 callback.GetCallback())); 52 callback.GetCallback()));
43 ASSERT_EQ(PP_ERROR_BADRESOURCE, callback.result()); 53 ASSERT_EQ(PP_ERROR_BADRESOURCE, callback.result());
44 } 54 }
45 // Test that Initialize fails with a bad profile enum value. 55 // Test that Initialize fails with a bad profile enum value.
46 { 56 {
47 pp::VideoDecoder video_decoder(instance_); 57 pp::VideoDecoder video_decoder(instance_);
48 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); 58 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
49 const PP_VideoProfile kInvalidProfile = static_cast<PP_VideoProfile>(-1); 59 const PP_VideoProfile kInvalidProfile = static_cast<PP_VideoProfile>(-1);
50 callback.WaitForResult( 60 callback.WaitForResult(
51 video_decoder.Initialize(graphics_3d_, 61 video_decoder.Initialize(graphics_3d_,
52 kInvalidProfile, 62 kInvalidProfile,
53 PP_HARDWAREACCELERATION_WITHFALLBACK, 63 PP_HARDWAREACCELERATION_WITHFALLBACK,
64 0,
54 callback.GetCallback())); 65 callback.GetCallback()));
55 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result()); 66 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result());
56 } 67 }
57 // Test that Initialize succeeds if we can create a Graphics3D resources and 68 // 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. 69 // if we allow software fallback to VP8, which should always be supported.
59 if (!graphics_3d_.is_null()) { 70 if (!graphics_3d_.is_null()) {
60 pp::VideoDecoder video_decoder(instance_); 71 pp::VideoDecoder video_decoder(instance_);
61 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); 72 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
62 callback.WaitForResult( 73 callback.WaitForResult(
63 video_decoder.Initialize(graphics_3d_, 74 video_decoder.Initialize(graphics_3d_,
64 PP_VIDEOPROFILE_VP8_ANY, 75 PP_VIDEOPROFILE_VP8_ANY,
65 PP_HARDWAREACCELERATION_WITHFALLBACK, 76 PP_HARDWAREACCELERATION_WITHFALLBACK,
77 0,
66 callback.GetCallback())); 78 callback.GetCallback()));
67 ASSERT_EQ(PP_OK, callback.result()); 79 ASSERT_EQ(PP_OK, callback.result());
68 } 80 }
81 // Test that Initialize succeeds with a larger than normal number of requested
82 // picture buffers, if we can create a Graphics3D resource and if we allow
83 // software fallback to VP8, which should always be supported.
84 if (!graphics_3d_.is_null()) {
85 pp::VideoDecoder video_decoder(instance_);
86 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
87 callback.WaitForResult(
88 video_decoder.Initialize(graphics_3d_,
89 PP_VIDEOPROFILE_VP8_ANY,
90 PP_HARDWAREACCELERATION_WITHFALLBACK,
91 kMaximumPictureCount,
92 callback.GetCallback()));
93 ASSERT_EQ(PP_OK, callback.result());
94 }
95 // Test that Initialize fails if we request an unreasonable number of picture
96 // buffers.
97 if (!graphics_3d_.is_null()) {
98 pp::VideoDecoder video_decoder(instance_);
99 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
100 callback.WaitForResult(
101 video_decoder.Initialize(graphics_3d_,
102 PP_VIDEOPROFILE_VP8_ANY,
103 PP_HARDWAREACCELERATION_WITHFALLBACK,
104 kMaximumPictureCount + 1,
105 callback.GetCallback()));
106 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result());
107 }
69 108
70 PASS(); 109 PASS();
71 } 110 }
OLDNEW
« no previous file with comments | « ppapi/tests/test_video_decoder.h ('k') | ppapi/thunk/interfaces_ppb_public_dev_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698