Chromium Code Reviews| Index: content/browser/renderer_host/media/video_capture_controller_unittest.cc |
| diff --git a/content/browser/renderer_host/media/video_capture_controller_unittest.cc b/content/browser/renderer_host/media/video_capture_controller_unittest.cc |
| index f650397de7bfc0c59890c91a0ce7997e9caa29ec..74c70e3e2888968d6eaa578d1551cec3983e0bf1 100644 |
| --- a/content/browser/renderer_host/media/video_capture_controller_unittest.cc |
| +++ b/content/browser/renderer_host/media/video_capture_controller_unittest.cc |
| @@ -16,6 +16,7 @@ |
| #include "content/browser/renderer_host/media/video_capture_controller.h" |
| #include "content/browser/renderer_host/media/video_capture_controller_event_handler.h" |
| #include "content/browser/renderer_host/media/video_capture_manager.h" |
| +#include "content/common/gpu/client/gl_helper.h" |
| #include "content/common/media/media_stream_options.h" |
| #include "content/public/test/test_browser_thread_bundle.h" |
| #include "gpu/command_buffer/common/mailbox_holder.h" |
| @@ -24,6 +25,14 @@ |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +#if defined(OS_ANDROID) |
| +#include "content/browser/renderer_host/image_transport_factory_android.h" |
| +#include "content/browser/renderer_host/no_image_transport_factory_android.h" |
| +#else |
| +#include "content/browser/compositor/image_transport_factory.h" |
| +#include "ui/compositor/test/in_process_context_factory.h" |
| +#endif |
| + |
| using ::testing::InSequence; |
| using ::testing::Mock; |
| @@ -70,7 +79,7 @@ class MockVideoCaptureControllerEventHandler |
| id, |
| this, |
| buffer_id, |
| - std::vector<uint32>())); |
| + 0)); |
| } |
| virtual void OnMailboxBufferReady(const VideoCaptureControllerID& id, |
| int buffer_id, |
| @@ -78,9 +87,6 @@ class MockVideoCaptureControllerEventHandler |
| const media::VideoCaptureFormat& format, |
| base::TimeTicks timestamp) OVERRIDE { |
| DoMailboxBufferReady(id); |
| - // Use a very different syncpoint value when returning a new syncpoint. |
| - std::vector<uint32> release_sync_points; |
| - release_sync_points.push_back(~mailbox_holder.sync_point); |
| base::MessageLoop::current()->PostTask( |
| FROM_HERE, |
| base::Bind(&VideoCaptureController::ReturnBuffer, |
| @@ -88,7 +94,7 @@ class MockVideoCaptureControllerEventHandler |
| id, |
| this, |
| buffer_id, |
| - release_sync_points)); |
| + mailbox_holder.sync_point)); |
| } |
| virtual void OnEnded(const VideoCaptureControllerID& id) OVERRIDE { |
| DoEnded(id); |
| @@ -263,17 +269,24 @@ TEST_F(VideoCaptureControllerTest, AddAndRemoveClients) { |
| << "Client count should return to zero after all clients are gone."; |
| } |
| -static void CacheSyncPoint(std::vector<uint32>* called_release_sync_points, |
| - const std::vector<uint32>& release_sync_points) { |
| - DCHECK(called_release_sync_points->empty()); |
| - called_release_sync_points->assign(release_sync_points.begin(), |
| - release_sync_points.end()); |
| +static void CacheSyncPoint(uint32* called_release_sync_point, |
| + uint32 release_sync_point) { |
| + *called_release_sync_point = release_sync_point; |
| } |
| // This test will connect and disconnect several clients while simulating an |
| // active capture device being started and generating frames. It runs on one |
| // thread and is intended to behave deterministically. |
| TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) { |
| +// VideoCaptureController::ReturnBuffer() uses ImageTransportFactory. |
| +#if defined(OS_ANDROID) |
| + ImageTransportFactoryAndroid::InitializeForUnitTests( |
| + new NoImageTransportFactoryAndroid); |
| +#else |
| + ImageTransportFactory::InitializeForUnitTests( |
| + scoped_ptr<ui::ContextFactory>(new ui::InProcessContextFactory)); |
| +#endif |
| + |
| media::VideoCaptureParams session_100; |
| session_100.requested_format = media::VideoCaptureFormat( |
| gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420); |
| @@ -484,12 +497,18 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) { |
| buffer = NULL; |
| } |
| std::vector<uint32> mailbox_syncpoints(mailbox_buffers); |
| - std::vector<std::vector<uint32> > release_syncpoint_vectors(mailbox_buffers); |
| + std::vector<uint32> release_syncpoint_vectors(mailbox_buffers); |
|
no sievers
2014/07/10 18:52:29
nit: |release_syncpoints_|?
|
| +#if defined(OS_ANDROID) |
| + GLHelper* gl_helper = |
| + ImageTransportFactoryAndroid::GetInstance()->GetGLHelper(); |
| +#else |
| + GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); |
| +#endif |
| for (int i = 0; i < mailbox_buffers; ++i) { |
| buffer = device_->ReserveOutputBuffer(media::VideoFrame::NATIVE_TEXTURE, |
| gfx::Size(0, 0)); |
| ASSERT_TRUE(buffer); |
| - mailbox_syncpoints[i] = i; |
| + mailbox_syncpoints[i] = gl_helper->InsertSyncPoint(); |
| device_->OnIncomingCapturedVideoFrame( |
| buffer, |
| media::VideoCaptureFormat(capture_resolution, |
| @@ -515,9 +534,11 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) { |
| .Times(mailbox_buffers); |
| base::RunLoop().RunUntilIdle(); |
| for (size_t i = 0; i < mailbox_syncpoints.size(); ++i) { |
| - // See: MockVideoCaptureControllerEventHandler::OnMailboxBufferReady() |
| - ASSERT_EQ(1u, release_syncpoint_vectors[i].size()); |
| - ASSERT_EQ(mailbox_syncpoints[i], ~release_syncpoint_vectors[i][0]); |
| + // A new release sync point must be inserted when the video frame is |
| + // returned to the Browser process. |
| + // See: MockVideoCaptureControllerEventHandler::OnMailboxBufferReady() and |
| + // VideoCaptureController::ReturnBuffer() |
| + ASSERT_NE(mailbox_syncpoints[i], release_syncpoint_vectors[i]); |
|
no sievers
2014/07/10 18:52:29
At what point are those equal though? Can we ASSER
dshwang
2014/07/10 19:23:11
Unfortunately, we cannot know what is release_sync
|
| } |
| Mock::VerifyAndClearExpectations(client_b_.get()); |
| } |