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

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

Issue 496203002: Pepper: PPB_VideoDecoder software-only mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 6 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 | Annotate | Revision Log
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 REGISTER_TEST_CASE(VideoDecoder); 12 REGISTER_TEST_CASE(VideoDecoder);
13 13
14 static const bool kAllowSoftwareFallback = true;
15
16 bool TestVideoDecoder::Init() { 14 bool TestVideoDecoder::Init() {
17 video_decoder_interface_ = static_cast<const PPB_VideoDecoder_0_1*>( 15 video_decoder_interface_ = static_cast<const PPB_VideoDecoder_0_1*>(
18 pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_INTERFACE_0_1)); 16 pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_INTERFACE_0_1));
19 const int width = 16; 17 const int width = 16;
20 const int height = 16; 18 const int height = 16;
21 const int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, width, 19 const int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, width,
22 PP_GRAPHICS3DATTRIB_HEIGHT, height, 20 PP_GRAPHICS3DATTRIB_HEIGHT, height,
23 PP_GRAPHICS3DATTRIB_NONE}; 21 PP_GRAPHICS3DATTRIB_NONE};
24 graphics_3d_ = pp::Graphics3D(instance_, attribs); 22 graphics_3d_ = pp::Graphics3D(instance_, attribs);
25 return video_decoder_interface_ && CheckTestingInterface(); 23 return video_decoder_interface_ && CheckTestingInterface();
26 } 24 }
27 25
28 void TestVideoDecoder::RunTests(const std::string& filter) { 26 void TestVideoDecoder::RunTests(const std::string& filter) {
29 RUN_CALLBACK_TEST(TestVideoDecoder, Create, filter); 27 RUN_CALLBACK_TEST(TestVideoDecoder, Create, filter);
30 } 28 }
31 29
32 std::string TestVideoDecoder::TestCreate() { 30 std::string TestVideoDecoder::TestCreate() {
33 // Test that Initialize fails with a bad Graphics3D resource. 31 // Test that Initialize fails with a bad Graphics3D resource.
34 { 32 {
35 pp::VideoDecoder video_decoder(instance_); 33 pp::VideoDecoder video_decoder(instance_);
36 ASSERT_FALSE(video_decoder.is_null()); 34 ASSERT_FALSE(video_decoder.is_null());
37 35
38 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); 36 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
39 pp::Graphics3D null_graphics_3d; 37 pp::Graphics3D null_graphics_3d;
40 callback.WaitForResult(video_decoder.Initialize(null_graphics_3d, 38 callback.WaitForResult(
41 PP_VIDEOPROFILE_VP8_ANY, 39 video_decoder.Initialize(null_graphics_3d,
42 kAllowSoftwareFallback, 40 PP_VIDEOPROFILE_VP8_ANY,
43 callback.GetCallback())); 41 PP_HARDWAREACCELERATION_WITHFALLBACK,
42 callback.GetCallback()));
44 ASSERT_EQ(PP_ERROR_BADRESOURCE, callback.result()); 43 ASSERT_EQ(PP_ERROR_BADRESOURCE, callback.result());
45 } 44 }
46 // Test that Initialize fails with a bad profile enum value. 45 // Test that Initialize fails with a bad profile enum value.
47 { 46 {
48 pp::VideoDecoder video_decoder(instance_); 47 pp::VideoDecoder video_decoder(instance_);
49 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); 48 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
50 const PP_VideoProfile kInvalidProfile = static_cast<PP_VideoProfile>(-1); 49 const PP_VideoProfile kInvalidProfile = static_cast<PP_VideoProfile>(-1);
51 callback.WaitForResult(video_decoder.Initialize(graphics_3d_, 50 callback.WaitForResult(
52 kInvalidProfile, 51 video_decoder.Initialize(graphics_3d_,
53 kAllowSoftwareFallback, 52 kInvalidProfile,
54 callback.GetCallback())); 53 PP_HARDWAREACCELERATION_WITHFALLBACK,
54 callback.GetCallback()));
55 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result()); 55 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result());
56 } 56 }
57 // Test that Initialize succeeds if we can create a Graphics3D resources and 57 // 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. 58 // if we allow software fallback to VP8, which should always be supported.
59 if (!graphics_3d_.is_null()) { 59 if (!graphics_3d_.is_null()) {
60 pp::VideoDecoder video_decoder(instance_); 60 pp::VideoDecoder video_decoder(instance_);
61 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); 61 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
62 callback.WaitForResult(video_decoder.Initialize(graphics_3d_, 62 callback.WaitForResult(
63 PP_VIDEOPROFILE_VP8_ANY, 63 video_decoder.Initialize(graphics_3d_,
64 kAllowSoftwareFallback, 64 PP_VIDEOPROFILE_VP8_ANY,
65 callback.GetCallback())); 65 PP_HARDWAREACCELERATION_WITHFALLBACK,
66 callback.GetCallback()));
66 ASSERT_EQ(PP_OK, callback.result()); 67 ASSERT_EQ(PP_OK, callback.result());
67 } 68 }
68 69
69 PASS(); 70 PASS();
70 } 71 }
OLDNEW
« no previous file with comments | « ppapi/proxy/video_decoder_resource_unittest.cc ('k') | ppapi/thunk/interfaces_ppb_public_dev_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698