Respond with QuotaExceededError when IndexedDB has no disk space on open.
[chromium-blink-merge.git] / content / common / gpu / media / android_video_decode_accelerator_unittest.cc
blob4e25e683498d310f390c9b3c46f5ff212f2cb71f
1 // Copyright (c) 2013 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.
5 #include "content/common/gpu/media/android_video_decode_accelerator.h"
7 #include "base/android/jni_android.h"
8 #include "base/bind.h"
9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "content/common/gpu/media/android_video_decode_accelerator.h"
12 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
13 #include "media/base/android/media_codec_bridge.h"
14 #include "media/base/android/media_jni_registrar.h"
15 #include "media/video/picture.h"
16 #include "media/video/video_decode_accelerator.h"
17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "ui/gl/android/surface_texture.h"
20 namespace {
22 bool MockMakeContextCurrent() {
23 return true;
26 } // namespace
28 namespace content {
30 // TODO(felipeg): Add more unit tests to test the ordinary behavior of
31 // AndroidVideoDecodeAccelerator.
32 // http://crbug.com/178647
33 class MockVideoDecodeAcceleratorClient
34 : public media::VideoDecodeAccelerator::Client {
35 public:
36 MockVideoDecodeAcceleratorClient() {};
37 virtual ~MockVideoDecodeAcceleratorClient() {};
39 // VideoDecodeAccelerator::Client implementation.
40 virtual void NotifyInitializeDone() OVERRIDE {};
41 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers,
42 const gfx::Size& dimensions,
43 uint32 texture_target) OVERRIDE {};
44 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE {};
45 virtual void PictureReady(const media::Picture& picture) OVERRIDE {};
46 virtual void NotifyEndOfBitstreamBuffer(
47 int32 bitstream_buffer_id) OVERRIDE {};
48 virtual void NotifyFlushDone() OVERRIDE {};
49 virtual void NotifyResetDone() OVERRIDE {};
50 virtual void NotifyError(
51 media::VideoDecodeAccelerator::Error error) OVERRIDE {};
54 class AndroidVideoDecodeAcceleratorTest : public testing::Test {
55 public:
56 virtual ~AndroidVideoDecodeAcceleratorTest() {}
58 protected:
59 virtual void SetUp() OVERRIDE {
60 JNIEnv* env = base::android::AttachCurrentThread();
61 media::RegisterJni(env);
62 // TODO(felipeg): fix GL bindings, so that the decoder can perform GL
63 // calls.
64 scoped_ptr<gpu::gles2::MockGLES2Decoder> decoder(
65 new gpu::gles2::MockGLES2Decoder());
66 scoped_ptr<MockVideoDecodeAcceleratorClient> client(
67 new MockVideoDecodeAcceleratorClient());
68 accelerator_.reset(new AndroidVideoDecodeAccelerator(
69 client.get(), decoder->AsWeakPtr(),
70 base::Bind(&MockMakeContextCurrent)));
73 bool Configure(media::VideoCodec codec) {
74 AndroidVideoDecodeAccelerator* accelerator =
75 static_cast<AndroidVideoDecodeAccelerator*>(accelerator_.get());
76 accelerator->surface_texture_ = new gfx::SurfaceTexture(0);
77 accelerator->codec_ = codec;
78 return accelerator->ConfigureMediaCodec();
81 private:
82 scoped_ptr<media::VideoDecodeAccelerator> accelerator_;
85 TEST_F(AndroidVideoDecodeAcceleratorTest, ConfigureUnsupportedCodec) {
86 if (!media::MediaCodecBridge::IsAvailable())
87 return;
88 EXPECT_FALSE(Configure(media::kUnknownVideoCodec));
91 TEST_F(AndroidVideoDecodeAcceleratorTest, ConfigureSupportedCodec) {
92 if (!media::MediaCodecBridge::IsAvailable())
93 return;
94 EXPECT_TRUE(Configure(media::kCodecVP8));
97 } // namespace content
99 int main(int argc, char **argv) {
100 testing::InitGoogleTest(&argc, argv);
101 return RUN_ALL_TESTS();