OLD | NEW |
(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/cpp/graphics_3d.h" |
| 9 #include "ppapi/cpp/video_decoder.h" |
| 10 #include "ppapi/tests/testing_instance.h" |
| 11 |
| 12 REGISTER_TEST_CASE(VideoDecoder); |
| 13 |
| 14 static const bool kAllowSoftwareFallback = true; |
| 15 |
| 16 bool TestVideoDecoder::Init() { |
| 17 video_decoder_interface_ = static_cast<const PPB_VideoDecoder_0_1*>( |
| 18 pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_INTERFACE_0_1)); |
| 19 return video_decoder_interface_ && CheckTestingInterface(); |
| 20 } |
| 21 |
| 22 void TestVideoDecoder::RunTests(const std::string& filter) { |
| 23 RUN_CALLBACK_TEST(TestVideoDecoder, Create, filter); |
| 24 } |
| 25 |
| 26 std::string TestVideoDecoder::TestCreate() { |
| 27 // Test that Initialize fails with a bad Graphics3D resource. |
| 28 { |
| 29 pp::VideoDecoder video_decoder(instance_); |
| 30 ASSERT_FALSE(video_decoder.is_null()); |
| 31 |
| 32 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
| 33 pp::Graphics3D context; // null context |
| 34 callback.WaitForResult(video_decoder.Initialize(context, |
| 35 PP_VIDEOPROFILE_VP8MAIN, |
| 36 kAllowSoftwareFallback, |
| 37 callback.GetCallback())); |
| 38 ASSERT_EQ(PP_ERROR_BADRESOURCE, callback.result()); |
| 39 } |
| 40 // Test that Initialize fails with a bad profile enum value. |
| 41 { |
| 42 pp::VideoDecoder video_decoder(instance_); |
| 43 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
| 44 const int width = 16; |
| 45 const int height = 16; |
| 46 const int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, width, |
| 47 PP_GRAPHICS3DATTRIB_HEIGHT, height, |
| 48 PP_GRAPHICS3DATTRIB_NONE}; |
| 49 pp::Graphics3D context(instance_, attribs); |
| 50 const PP_VideoProfile kInvalidProfile = static_cast<PP_VideoProfile>(-1); |
| 51 callback.WaitForResult(video_decoder.Initialize(context, |
| 52 kInvalidProfile, |
| 53 kAllowSoftwareFallback, |
| 54 callback.GetCallback())); |
| 55 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result()); |
| 56 } |
| 57 // Test that Initialize succeeds when we allow software fallback to VP8. |
| 58 // Accept PP_ERROR_NOTSUPPORTED since some platforms may not support VP8. |
| 59 { |
| 60 pp::VideoDecoder video_decoder(instance_); |
| 61 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
| 62 const int width = 16; |
| 63 const int height = 16; |
| 64 const int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, width, |
| 65 PP_GRAPHICS3DATTRIB_HEIGHT, height, |
| 66 PP_GRAPHICS3DATTRIB_NONE}; |
| 67 pp::Graphics3D context(instance_, attribs); |
| 68 callback.WaitForResult(video_decoder.Initialize(context, |
| 69 PP_VIDEOPROFILE_VP8MAIN, |
| 70 kAllowSoftwareFallback, |
| 71 callback.GetCallback())); |
| 72 ASSERT_TRUE(callback.result() == PP_OK || |
| 73 callback.result() == PP_ERROR_NOTSUPPORTED); |
| 74 } |
| 75 |
| 76 PASS(); |
| 77 } |
OLD | NEW |