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

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: Address reveman's comment. 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..9f95517affcb16f9b1402ff94e1a7cba19e8cfb9 100644
--- a/media/video/gpu_memory_buffer_video_frame_pool_unittest.cc
+++ b/media/video/gpu_memory_buffer_video_frame_pool_unittest.cc
@@ -253,4 +253,31 @@ 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) {
reveman 2015/09/10 00:09:12 nit: s/AllocateGMBFail/FailToAllocateGpuMemoryBuff
Daniele Castagna 2015/09/10 00:15:35 Done.
+ 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);
+}
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698