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

Side by Side Diff: services/video_capture/fake_device_unittest.cc

Issue 2457003002: [Mojo Video Capture] Simplify API and some cleanups (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "services/video_capture/fake_device_test.h" 7 #include "services/video_capture/fake_device_test.h"
8 #include "services/video_capture/mock_video_frame_receiver.h" 8 #include "services/video_capture/mock_video_frame_receiver.h"
9 #include "services/video_capture/public/cpp/video_capture_settings.h"
9 #include "services/video_capture/public/interfaces/video_capture_device_factory. mojom.h" 10 #include "services/video_capture/public/interfaces/video_capture_device_factory. mojom.h"
10 #include "services/video_capture/video_capture_service_test.h" 11 #include "services/video_capture/video_capture_service_test.h"
11 12
12 using testing::_; 13 using testing::_;
13 using testing::InvokeWithoutArgs; 14 using testing::InvokeWithoutArgs;
14 15
15 namespace video_capture { 16 namespace video_capture {
16 17
17 TEST_F(FakeDeviceTest, FrameCallbacksArrive) { 18 TEST_F(FakeDeviceTest, FrameCallbacksArrive) {
18 media::VideoCaptureFormat arbitrary_requested_format; 19 VideoCaptureSettings arbitrary_requested_settings;
19 arbitrary_requested_format.frame_size.SetSize(640, 480); 20 arbitrary_requested_settings.format.frame_size.SetSize(640, 480);
20 arbitrary_requested_format.frame_rate = 15; 21 arbitrary_requested_settings.format.frame_rate = 15;
21 arbitrary_requested_format.pixel_format = media::PIXEL_FORMAT_I420; 22 arbitrary_requested_settings.resolution_change_policy =
22 arbitrary_requested_format.pixel_storage = media::PIXEL_STORAGE_CPU; 23 media::RESOLUTION_POLICY_FIXED_RESOLUTION;
24 arbitrary_requested_settings.power_line_frequency =
25 media::PowerLineFrequency::FREQUENCY_DEFAULT;
23 26
24 base::RunLoop wait_loop; 27 base::RunLoop wait_loop;
25 const int kNumFramesToWaitFor = 3; 28 const int kNumFramesToWaitFor = 3;
26 int num_frames_arrived = 0; 29 int num_frames_arrived = 0;
27 mojom::VideoFrameReceiverPtr receiver_proxy; 30 mojom::VideoFrameReceiverPtr receiver_proxy;
28 MockVideoFrameReceiver receiver(mojo::GetProxy(&receiver_proxy)); 31 MockVideoFrameReceiver receiver(mojo::GetProxy(&receiver_proxy));
29 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) 32 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_))
30 .WillRepeatedly(InvokeWithoutArgs( 33 .WillRepeatedly(InvokeWithoutArgs(
31 [&wait_loop, &kNumFramesToWaitFor, &num_frames_arrived]() { 34 [&wait_loop, &kNumFramesToWaitFor, &num_frames_arrived]() {
32 num_frames_arrived += 1; 35 num_frames_arrived += 1;
33 if (num_frames_arrived >= kNumFramesToWaitFor) { 36 if (num_frames_arrived >= kNumFramesToWaitFor) {
34 wait_loop.Quit(); 37 wait_loop.Quit();
35 } 38 }
36 })); 39 }));
37 40
38 fake_device_proxy_->Start(arbitrary_requested_format, 41 fake_device_proxy_->Start(arbitrary_requested_settings,
39 media::RESOLUTION_POLICY_FIXED_RESOLUTION,
40 media::PowerLineFrequency::FREQUENCY_DEFAULT,
41 std::move(receiver_proxy)); 42 std::move(receiver_proxy));
42 wait_loop.Run(); 43 wait_loop.Run();
43 } 44 }
44 45
45 } // namespace video_capture 46 } // namespace video_capture
OLDNEW
« no previous file with comments | « services/video_capture/fake_device_descriptor_unittest.cc ('k') | services/video_capture/mock_device_descriptor_receiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698