15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "ppapi/tests/test_video_decoder_dev.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/dev/ppb_video_decoder_dev.h"
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/pp_errors.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/c/ppb_var.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ppapi/tests/testing_instance.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)REGISTER_TEST_CASE(VideoDecoderDev);
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)bool TestVideoDecoderDev::Init() {
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  video_decoder_interface_ = static_cast<const PPB_VideoDecoder_Dev*>(
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_DEV_INTERFACE));
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return video_decoder_interface_ && CheckTestingInterface();
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
20010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)void TestVideoDecoderDev::RunTests(const std::string& filter) {
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  RUN_TEST(CreateFailure, filter);
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
24010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)void TestVideoDecoderDev::QuitMessageLoop() {
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  testing_interface_->QuitMessageLoop(instance_->pp_instance());
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
28010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)std::string TestVideoDecoderDev::TestCreateFailure() {
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PP_Resource decoder = video_decoder_interface_->Create(
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      instance_->pp_instance(), 0, static_cast<PP_VideoDecoder_Profile>(-1));
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (decoder != 0)
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return "Create: error detecting invalid context & configs";
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  PASS();
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
36