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

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

Issue 213313003: Experimental patch for MediaCodec APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update. Requires chromium @r273920 Created 6 years, 6 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
« no previous file with comments | « ppapi/tests/test_video_decoder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/c/ppb_var.h"
9 #include "ppapi/cpp/graphics_3d.h"
10 #include "ppapi/cpp/video_decoder.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 video_decoder_interface_ = static_cast<const PPB_VideoDecoder_0_1*>(
19 pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_INTERFACE_0_1));
20 return video_decoder_interface_ && CheckTestingInterface();
21 }
22
23 void TestVideoDecoder::RunTests(const std::string& filter) {
24 RUN_CALLBACK_TEST(TestVideoDecoder, Create, filter);
25 }
26
27 void TestVideoDecoder::QuitMessageLoop() {
28 testing_interface_->QuitMessageLoop(instance_->pp_instance());
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.
63 {
64 pp::VideoDecoder video_decoder(instance_);
65 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
66 const int width = 16;
67 const int height = 16;
68 const int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, width,
69 PP_GRAPHICS3DATTRIB_HEIGHT, height,
70 PP_GRAPHICS3DATTRIB_NONE};
71 pp::Graphics3D context(instance_, attribs);
72 callback.WaitForResult(video_decoder.Initialize(context,
73 PP_VIDEOPROFILE_VP8MAIN,
74 kAllowSoftwareFallback,
75 callback.GetCallback()));
76 ASSERT_TRUE(callback.result() == PP_OK);
77 }
78
79 PASS();
80 }
81
82 // std::string TestVideoDecoder::TestGetBitstreamBuffer() {
83 // pp::VideoDecoder video_decoder(instance_);
84 // TestCompletionCallback callback1(instance_->pp_instance(),
85 // callback_type());
86 // const int width = 16;
87 // const int height = 16;
88 // const int32_t attribs[] = {
89 // PP_GRAPHICS3DATTRIB_WIDTH, width,
90 // PP_GRAPHICS3DATTRIB_HEIGHT, height,
91 // PP_GRAPHICS3DATTRIB_NONE
92 // };
93 // pp::Graphics3D context(instance_, attribs);
94 // callback1.WaitForResult(
95 // video_decoder.Initialize(&context,
96 // PP_VIDEOPROFILE_VP8MAIN,
97 // callback1.GetCallback()));
98 // TestCompletionCallbackWithOutput<PP__BitstreamBuffer> callback2(
99 // instance_->pp_instance(), callback_type());
100 // callback2.WaitForResult(
101 // video_decoder.GetBitstreamBuffer(1024,
102 // callback2.GetCallback()));
103 // ASSERT_EQ(PP_OK, callback2.result());
104 // const PP__BitstreamBuffer& bitstream_buffer = callback2.output();
105 // ASSERT_EQ(1024, bitstream_buffer.size);
106 // ASSERT_NE(NULL, bitstream_buffer.addr);
107
108 // PASS();
109 // }
OLDNEW
« no previous file with comments | « ppapi/tests/test_video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698