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

Side by Side 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: Add "ForTesting" suffix. 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 unified diff | Download patch
« no previous file with comments | « media/video/gpu_memory_buffer_video_frame_pool.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/test/test_simple_task_runner.h" 6 #include "base/test/test_simple_task_runner.h"
7 #include "gpu/command_buffer/client/gles2_interface_stub.h" 7 #include "gpu/command_buffer/client/gles2_interface_stub.h"
8 #include "media/base/video_frame.h" 8 #include "media/base/video_frame.h"
9 #include "media/renderers/mock_gpu_video_accelerator_factories.h" 9 #include "media/renderers/mock_gpu_video_accelerator_factories.h"
10 #include "media/video/gpu_memory_buffer_video_frame_pool.h" 10 #include "media/video/gpu_memory_buffer_video_frame_pool.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 scoped_refptr<VideoFrame> frame; 246 scoped_refptr<VideoFrame> frame;
247 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 247 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame(
248 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame)); 248 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
249 249
250 RunUntilIdle(); 250 RunUntilIdle();
251 251
252 EXPECT_NE(software_frame.get(), frame.get()); 252 EXPECT_NE(software_frame.get(), frame.get());
253 EXPECT_EQ(1u, gles2_->gen_textures); 253 EXPECT_EQ(1u, gles2_->gen_textures);
254 } 254 }
255 255
256 // AllocateGpuMemoryBuffer can return null (e.g: when the GPU process is down).
257 // This test checks that in that case we don't crash and still create the
258 // textures.
259 TEST_F(GpuMemoryBufferVideoFramePoolTest, AllocateGpuMemoryBufferBFail) {
260 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10);
261 scoped_refptr<MockGpuVideoAcceleratorFactories> mock_gpu_factories(
262 new MockGpuVideoAcceleratorFactories);
263 mock_gpu_factories->SetFailToAllocateGpuMemoryBufferForTesting(true);
264 scoped_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool_ =
265 make_scoped_ptr(new GpuMemoryBufferVideoFramePool(
266 media_task_runner_, copy_task_runner_.get(), mock_gpu_factories));
267
268 EXPECT_CALL(*mock_gpu_factories.get(), GetGLES2Interface())
269 .WillRepeatedly(testing::Return(gles2_.get()));
270
271 scoped_refptr<VideoFrame> frame;
272 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame(
273 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
274
275 RunUntilIdle();
276
277 EXPECT_NE(software_frame.get(), frame.get());
278 EXPECT_EQ(3u, gles2_->gen_textures);
279 }
280
256 } // namespace media 281 } // namespace media
OLDNEW
« no previous file with comments | « media/video/gpu_memory_buffer_video_frame_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698