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/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 |
OLD | NEW |