| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/dev/ppb_video_decoder_dev.h" | 7 #include "ppapi/c/dev/ppb_video_decoder_dev.h" |
| 8 #include "ppapi/c/dev/ppb_testing_dev.h" | 8 #include "ppapi/c/dev/ppb_testing_dev.h" |
| 9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/c/ppb_var.h" | 10 #include "ppapi/c/ppb_var.h" |
| 11 #include "ppapi/tests/testing_instance.h" | 11 #include "ppapi/tests/testing_instance.h" |
| 12 | 12 |
| 13 REGISTER_TEST_CASE(VideoDecoder); | 13 REGISTER_TEST_CASE(VideoDecoder); |
| 14 | 14 |
| 15 bool TestVideoDecoder::Init() { | 15 bool TestVideoDecoder::Init() { |
| 16 video_decoder_interface_ = reinterpret_cast<PPB_VideoDecoder_Dev const*>( | 16 video_decoder_interface_ = reinterpret_cast<PPB_VideoDecoder_Dev const*>( |
| 17 pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_DEV_INTERFACE)); | 17 pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_DEV_INTERFACE)); |
| 18 var_interface_ = reinterpret_cast<PPB_Var const*>( | 18 return video_decoder_interface_ && InitTestingInterface(); |
| 19 pp::Module::Get()->GetBrowserInterface(PPB_VAR_INTERFACE)); | |
| 20 return video_decoder_interface_ && var_interface_ && InitTestingInterface(); | |
| 21 } | 19 } |
| 22 | 20 |
| 23 void TestVideoDecoder::RunTest() { | 21 void TestVideoDecoder::RunTest() { |
| 24 RUN_TEST(CreateAndInitialize); | 22 RUN_TEST(CreateFailure); |
| 25 } | 23 } |
| 26 | 24 |
| 27 void TestVideoDecoder::QuitMessageLoop() { | 25 void TestVideoDecoder::QuitMessageLoop() { |
| 28 testing_interface_->QuitMessageLoop(instance_->pp_instance()); | 26 testing_interface_->QuitMessageLoop(instance_->pp_instance()); |
| 29 } | 27 } |
| 30 | 28 |
| 31 std::string TestVideoDecoder::TestCreateAndInitialize() { | 29 std::string TestVideoDecoder::TestCreateFailure() { |
| 32 PP_Resource decoder = video_decoder_interface_->Create( | 30 PP_Resource decoder = video_decoder_interface_->Create( |
| 33 instance_->pp_instance()); | 31 instance_->pp_instance(), 0, NULL); |
| 34 if (decoder == 0) | 32 if (decoder != 0) |
| 35 return "Create: error creating the decoder"; | 33 return "Create: error detecting invalid context & configs"; |
| 36 | |
| 37 int32_t pp_error = video_decoder_interface_->Initialize( | |
| 38 decoder, 0, NULL, PP_BlockUntilComplete()); | |
| 39 pp::Module::Get()->core()->ReleaseResource(decoder); | |
| 40 if (pp_error != PP_ERROR_BADARGUMENT) | |
| 41 return "Initialize: error detecting null callback"; | |
| 42 | 34 |
| 43 PASS(); | 35 PASS(); |
| 44 } | 36 } |
| OLD | NEW |