OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "content/common/gpu/media/android_video_decode_accelerator.h" | |
6 | |
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_bridge.h" | |
19 | |
20 namespace { | |
brettw
2013/05/22 18:33:07
Namespace formatting: blank lines around beginning
qinmin
2013/05/22 19:02:17
Done.
| |
21 bool MockMakeContextCurrent() { | |
22 return true; | |
23 } | |
24 } | |
25 | |
26 namespace content { | |
brettw
2013/05/22 18:33:07
Blank line after.
qinmin
2013/05/22 19:02:17
Done.
| |
27 // TODO(felipeg): Add more unit tests to test the ordinary behavior of | |
28 // AndroidVideoDecodeAccelerator. | |
29 // http://crbug.com/178647 | |
30 class MockVideoDecodeAcceleratorClient | |
31 : public media::VideoDecodeAccelerator::Client { | |
32 public: | |
33 MockVideoDecodeAcceleratorClient() {}; | |
34 virtual ~MockVideoDecodeAcceleratorClient() {}; | |
35 | |
36 // VideoDecodeAccelerator::Client implementation. | |
37 virtual void NotifyInitializeDone() OVERRIDE {}; | |
38 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers, | |
39 const gfx::Size& dimensions, | |
40 uint32 texture_target) OVERRIDE {}; | |
41 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE {}; | |
42 virtual void PictureReady(const media::Picture& picture) OVERRIDE {}; | |
43 virtual void NotifyEndOfBitstreamBuffer( | |
44 int32 bitstream_buffer_id) OVERRIDE {}; | |
45 virtual void NotifyFlushDone() OVERRIDE {}; | |
46 virtual void NotifyResetDone() OVERRIDE {}; | |
47 virtual void NotifyError( | |
48 media::VideoDecodeAccelerator::Error error) OVERRIDE {}; | |
49 }; | |
50 | |
51 class AndroidVideoDecodeAcceleratorTest : public testing::Test { | |
52 public: | |
53 virtual ~AndroidVideoDecodeAcceleratorTest() {} | |
54 | |
55 protected: | |
56 virtual void SetUp() OVERRIDE { | |
57 JNIEnv* env = base::android::AttachCurrentThread(); | |
58 media::RegisterJni(env); | |
59 // TODO(felipeg): fix GL bindings, so that the decoder can perform GL | |
60 // calls. | |
61 scoped_ptr<gpu::gles2::MockGLES2Decoder> decoder( | |
62 new gpu::gles2::MockGLES2Decoder()); | |
63 scoped_ptr<MockVideoDecodeAcceleratorClient> client( | |
64 new MockVideoDecodeAcceleratorClient()); | |
65 accelerator_.reset(new AndroidVideoDecodeAccelerator( | |
66 client.get(), decoder->AsWeakPtr(), | |
67 base::Bind(&MockMakeContextCurrent))); | |
68 } | |
69 | |
70 bool Configure(media::VideoCodec codec) { | |
71 AndroidVideoDecodeAccelerator* accelerator = | |
72 static_cast<AndroidVideoDecodeAccelerator*>(accelerator_.get()); | |
73 accelerator->surface_texture_ = new gfx::SurfaceTextureBridge(0); | |
74 accelerator->codec_ = codec; | |
75 return accelerator->ConfigureMediaCodec(); | |
76 } | |
77 | |
78 private: | |
79 scoped_ptr<media::VideoDecodeAccelerator> accelerator_; | |
80 }; | |
81 | |
82 TEST_F(AndroidVideoDecodeAcceleratorTest, ConfigureUnsupportedCodec) { | |
83 if (!media::MediaCodecBridge::IsAvailable()) | |
84 return; | |
85 EXPECT_FALSE(Configure(media::kUnknownVideoCodec)); | |
86 } | |
87 | |
88 TEST_F(AndroidVideoDecodeAcceleratorTest, ConfigureSupportedCodec) { | |
89 if (!media::MediaCodecBridge::IsAvailable()) | |
90 return; | |
91 EXPECT_TRUE(Configure(media::kCodecVP8)); | |
92 } | |
93 | |
94 } // namespace content | |
95 | |
96 int main(int argc, char **argv) { | |
brettw
2013/05/22 18:33:07
I don't understand why this individual test file h
qinmin
2013/05/22 19:02:17
This is because the file is built as a single test
| |
97 testing::InitGoogleTest(&argc, argv); | |
98 return RUN_ALL_TESTS(); | |
99 } | |
OLD | NEW |