OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/memory/ref_counted.h" |
| 6 #include "base/run_loop.h" |
| 7 #include "services/video_capture/fake_device_video_capture_service_test.h" |
| 8 #include "services/video_capture/mock_video_capture_device_client.h" |
| 9 #include "services/video_capture/public/interfaces/video_capture_device_factory.
mojom.h" |
| 10 #include "services/video_capture/video_capture_service_test.h" |
| 11 |
| 12 using testing::_; |
| 13 using testing::InvokeWithoutArgs; |
| 14 |
| 15 namespace video_capture { |
| 16 |
| 17 TEST_F(FakeDeviceVideoCaptureServiceTest, FrameCallbacksArrive) { |
| 18 auto arbitrary_requested_format = mojom::VideoCaptureFormat::New(); |
| 19 arbitrary_requested_format->frame_size.SetSize(640, 480); |
| 20 arbitrary_requested_format->frame_rate = 15; |
| 21 arbitrary_requested_format->pixel_format = media::mojom::VideoFormat::I420; |
| 22 arbitrary_requested_format->pixel_storage = mojom::VideoPixelStorage::CPU; |
| 23 |
| 24 base::RunLoop wait_loop; |
| 25 const int kNumFramesToWaitFor = 3; |
| 26 int num_frames_arrived = 0; |
| 27 mojom::VideoCaptureDeviceClientPtr client_proxy; |
| 28 MockVideoCaptureDeviceClient client(mojo::GetProxy(&client_proxy)); |
| 29 EXPECT_CALL(client, OnFrameAvailablePtr(_)) |
| 30 .WillRepeatedly(InvokeWithoutArgs( |
| 31 [&wait_loop, &kNumFramesToWaitFor, &num_frames_arrived]() { |
| 32 num_frames_arrived += 1; |
| 33 if (num_frames_arrived >= kNumFramesToWaitFor) { |
| 34 wait_loop.Quit(); |
| 35 } |
| 36 })); |
| 37 |
| 38 fake_device_proxy_->Start(std::move(arbitrary_requested_format), |
| 39 mojom::ResolutionChangePolicy::FIXED_RESOLUTION, |
| 40 mojom::PowerLineFrequency::DEFAULT, |
| 41 std::move(client_proxy)); |
| 42 wait_loop.Run(); |
| 43 } |
| 44 |
| 45 } // namespace video_capture |
OLD | NEW |