Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Unified Diff: media/video/gpu_memory_buffer_video_frame_pool_unittest.cc

Issue 1304843005: Deal with AllocateGpuMemoryBuffer returning null. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/fail_to_allocated/fail_to_allocate Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/video/gpu_memory_buffer_video_frame_pool_unittest.cc
diff --git a/media/video/gpu_memory_buffer_video_frame_pool_unittest.cc b/media/video/gpu_memory_buffer_video_frame_pool_unittest.cc
index 6d891b2487440832c6033556489f8c812eeef785..707624d490798e42e01c597bf009128ee7b70696 100644
--- a/media/video/gpu_memory_buffer_video_frame_pool_unittest.cc
+++ b/media/video/gpu_memory_buffer_video_frame_pool_unittest.cc
@@ -16,11 +16,19 @@ namespace {
class TestGLES2Interface : public gpu::gles2::GLES2InterfaceStub {
public:
unsigned gen_textures = 0u;
+ unsigned gen_images = 0u;
void GenTextures(GLsizei n, GLuint* textures) override {
DCHECK_EQ(1, n);
*textures = ++gen_textures;
}
+ GLuint CreateImageCHROMIUM(ClientBuffer buffer,
+ GLsizei width,
+ GLsizei height,
+ GLenum inetrnalformat) override {
+ return ++gen_images;
+ }
+
GLuint InsertSyncPointCHROMIUM() override { return ++sync_point; }
void GenMailboxCHROMIUM(GLbyte* mailbox) override {
@@ -253,4 +261,41 @@ TEST_F(GpuMemoryBufferVideoFramePoolTest, CreateOneHardwareNV12Frame) {
EXPECT_EQ(1u, gles2_->gen_textures);
}
+// AllocateGpuMemoryBuffer can return null (e.g: when the GPU process is down).
+// This test checks that in that case we don't crash and still create the
+// textures.
+// If we try to create another VideoFrame after the GPU process became active
+// again we should discard the previous created resources and create new ones.
+TEST_F(GpuMemoryBufferVideoFramePoolTest, AllocateGMBFail) {
+ scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10);
+ scoped_refptr<MockGpuVideoAcceleratorFactories> mock_gpu_factories(
+ new MockGpuVideoAcceleratorFactories);
+ mock_gpu_factories->SetFailToAllocateGpuMemoryBuffer(true);
+ scoped_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool_ =
+ make_scoped_ptr(new GpuMemoryBufferVideoFramePool(
+ media_task_runner_, copy_task_runner_.get(), mock_gpu_factories));
+
+ EXPECT_CALL(*mock_gpu_factories.get(), GetGLES2Interface())
+ .WillRepeatedly(testing::Return(gles2_.get()));
+
+ scoped_refptr<VideoFrame> frame;
+ gpu_memory_buffer_pool_->MaybeCreateHardwareFrame(
+ software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
+
+ RunUntilIdle();
+
+ EXPECT_NE(software_frame.get(), frame.get());
+ EXPECT_EQ(3u, gles2_->gen_textures);
+ EXPECT_EQ(0u, gles2_->gen_images);
+
+ mock_gpu_factories->SetFailToAllocateGpuMemoryBuffer(false);
+ gpu_memory_buffer_pool_->MaybeCreateHardwareFrame(
+ software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
+
+ RunUntilIdle();
+ EXPECT_NE(software_frame.get(), frame.get());
+ EXPECT_EQ(6u, gles2_->gen_textures);
+ EXPECT_EQ(3u, gles2_->gen_images);
+}
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698