| 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..7db3476a311a3b1cb9900f58741d14b583e97974 100644
|
| --- a/content/browser/renderer_host/media/video_capture_controller_unittest.cc
|
| +++ b/content/browser/renderer_host/media/video_capture_controller_unittest.cc
|
| @@ -12,10 +12,12 @@
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/run_loop.h"
|
| +#include "content/browser/compositor/image_transport_factory.h"
|
| #include "content/browser/renderer_host/media/media_stream_provider.h"
|
| #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"
|
| @@ -23,6 +25,7 @@
|
| #include "media/video/capture/video_capture_types.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| +#include "ui/compositor/test/in_process_context_factory.h"
|
|
|
| using ::testing::InSequence;
|
| using ::testing::Mock;
|
| @@ -70,7 +73,7 @@ class MockVideoCaptureControllerEventHandler
|
| id,
|
| this,
|
| buffer_id,
|
| - std::vector<uint32>()));
|
| + 0));
|
| }
|
| virtual void OnMailboxBufferReady(const VideoCaptureControllerID& id,
|
| int buffer_id,
|
| @@ -78,9 +81,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 +88,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 +263,19 @@ 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.
|
| + ImageTransportFactory::InitializeForUnitTests(
|
| + scoped_ptr<ui::ContextFactory>(new ui::InProcessContextFactory));
|
| +
|
| media::VideoCaptureParams session_100;
|
| session_100.requested_format = media::VideoCaptureFormat(
|
| gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420);
|
| @@ -484,12 +486,13 @@ 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);
|
| + GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
|
| 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 +518,10 @@ TEST_F(VideoCaptureControllerTest, NormalCaptureMultipleClients) {
|
| .Times(mailbox_buffers);
|
| base::RunLoop().RunUntilIdle();
|
| for (size_t i = 0; i < mailbox_syncpoints.size(); ++i) {
|
| + // The release sync point must be created later than the sync point inserted
|
| + // into the mailbox.
|
| // See: MockVideoCaptureControllerEventHandler::OnMailboxBufferReady()
|
| - ASSERT_EQ(1u, release_syncpoint_vectors[i].size());
|
| - ASSERT_EQ(mailbox_syncpoints[i], ~release_syncpoint_vectors[i][0]);
|
| + ASSERT_GT(release_syncpoint_vectors[i], mailbox_syncpoints[i]);
|
| }
|
| Mock::VerifyAndClearExpectations(client_b_.get());
|
| }
|
|
|