OLD | NEW |
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 "media/base/video_frame.h" | 7 #include "media/base/video_frame.h" |
8 #include "media/mojo/common/media_type_converters.h" | 8 #include "media/mojo/common/media_type_converters.h" |
9 #include "services/video_capture/fake_device_test.h" | 9 #include "services/video_capture/fake_device_test.h" |
10 #include "services/video_capture/mock_video_frame_receiver.h" | 10 #include "services/video_capture/mock_video_frame_receiver.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 media::VideoFrame::StorageType storage_type; | 24 media::VideoFrame::StorageType storage_type; |
25 bool is_mappable; | 25 bool is_mappable; |
26 base::TimeDelta timestamp; | 26 base::TimeDelta timestamp; |
27 }; | 27 }; |
28 | 28 |
29 } // anonymous namespace | 29 } // anonymous namespace |
30 | 30 |
31 namespace video_capture { | 31 namespace video_capture { |
32 | 32 |
33 TEST_F(FakeDeviceTest, FrameCallbacksArrive) { | 33 TEST_F(FakeDeviceTest, FrameCallbacksArrive) { |
34 VideoCaptureSettings arbitrary_requested_settings; | |
35 arbitrary_requested_settings.format.frame_size.SetSize(640, 480); | |
36 arbitrary_requested_settings.format.frame_rate = 15; | |
37 arbitrary_requested_settings.resolution_change_policy = | |
38 media::RESOLUTION_POLICY_FIXED_RESOLUTION; | |
39 arbitrary_requested_settings.power_line_frequency = | |
40 media::PowerLineFrequency::FREQUENCY_DEFAULT; | |
41 | |
42 base::RunLoop wait_loop; | 34 base::RunLoop wait_loop; |
43 const int kNumFramesToWaitFor = 3; | 35 const int kNumFramesToWaitFor = 3; |
44 int num_frames_arrived = 0; | 36 int num_frames_arrived = 0; |
45 mojom::VideoFrameReceiverPtr receiver_proxy; | 37 mojom::VideoFrameReceiverPtr receiver_proxy; |
46 MockVideoFrameReceiver receiver(mojo::GetProxy(&receiver_proxy)); | 38 MockVideoFrameReceiver receiver(mojo::GetProxy(&receiver_proxy)); |
47 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) | 39 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) |
48 .WillRepeatedly(InvokeWithoutArgs( | 40 .WillRepeatedly(InvokeWithoutArgs( |
49 [&wait_loop, &kNumFramesToWaitFor, &num_frames_arrived]() { | 41 [&wait_loop, &kNumFramesToWaitFor, &num_frames_arrived]() { |
50 num_frames_arrived += 1; | 42 num_frames_arrived += 1; |
51 if (num_frames_arrived >= kNumFramesToWaitFor) { | 43 if (num_frames_arrived >= kNumFramesToWaitFor) { |
52 wait_loop.Quit(); | 44 wait_loop.Quit(); |
53 } | 45 } |
54 })); | 46 })); |
55 | 47 |
56 fake_device_proxy_->Start(arbitrary_requested_settings, | 48 fake_device_proxy_->Start(requestable_settings_, |
57 std::move(receiver_proxy)); | 49 std::move(receiver_proxy)); |
58 wait_loop.Run(); | 50 wait_loop.Run(); |
59 } | 51 } |
60 | 52 |
61 // Tests that frames received from a fake capture device match the requested | 53 // Tests that frames received from a fake capture device match the requested |
62 // format and have increasing timestamps. | 54 // format and have increasing timestamps. |
63 TEST_F(FakeDeviceTest, ReceiveFramesFromFakeCaptureDevice) { | 55 TEST_F(FakeDeviceTest, ReceiveFramesFromFakeCaptureDevice) { |
64 base::RunLoop wait_loop; | 56 base::RunLoop wait_loop; |
65 mojom::VideoFrameReceiverPtr receiver_proxy; | 57 mojom::VideoFrameReceiverPtr receiver_proxy; |
66 constexpr int num_frames_to_receive = 2; | 58 constexpr int num_frames_to_receive = 2; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 EXPECT_EQ(requestable_settings_.format.frame_size, | 95 EXPECT_EQ(requestable_settings_.format.frame_size, |
104 frame_info.size); | 96 frame_info.size); |
105 // Timestamps are expected to increase | 97 // Timestamps are expected to increase |
106 if (i > 0) | 98 if (i > 0) |
107 EXPECT_GT(frame_info.timestamp, previous_timestamp); | 99 EXPECT_GT(frame_info.timestamp, previous_timestamp); |
108 previous_timestamp = frame_info.timestamp; | 100 previous_timestamp = frame_info.timestamp; |
109 } | 101 } |
110 } | 102 } |
111 | 103 |
112 } // namespace video_capture | 104 } // namespace video_capture |
OLD | NEW |