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

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

Issue 2502483003: [Mojo Video Capture] Cleanup naming of classes/files in services/video_capture (Closed)
Patch Set: Rebase 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 "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_receiver.h"
11 #include "services/video_capture/public/cpp/video_capture_settings.h" 11 #include "services/video_capture/public/cpp/capture_settings.h"
12 #include "services/video_capture/public/interfaces/video_capture_device_factory. mojom.h" 12 #include "services/video_capture/public/interfaces/device_factory.mojom.h"
13 #include "services/video_capture/video_capture_service_test.h" 13 #include "services/video_capture/service_test.h"
14 14
15 using testing::_; 15 using testing::_;
16 using testing::Invoke; 16 using testing::Invoke;
17 using testing::InvokeWithoutArgs; 17 using testing::InvokeWithoutArgs;
18 18
19 namespace { 19 namespace {
20 20
21 struct FrameInfo { 21 struct FrameInfo {
22 gfx::Size size; 22 gfx::Size size;
23 media::VideoPixelFormat pixel_format; 23 media::VideoPixelFormat pixel_format;
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 base::RunLoop wait_loop; 34 base::RunLoop wait_loop;
35 const int kNumFramesToWaitFor = 3; 35 const int kNumFramesToWaitFor = 3;
36 int num_frames_arrived = 0; 36 int num_frames_arrived = 0;
37 mojom::VideoFrameReceiverPtr receiver_proxy; 37 mojom::ReceiverPtr receiver_proxy;
38 MockVideoFrameReceiver receiver(mojo::GetProxy(&receiver_proxy)); 38 MockReceiver receiver(mojo::GetProxy(&receiver_proxy));
39 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) 39 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_))
40 .WillRepeatedly(InvokeWithoutArgs( 40 .WillRepeatedly(InvokeWithoutArgs(
41 [&wait_loop, &kNumFramesToWaitFor, &num_frames_arrived]() { 41 [&wait_loop, &kNumFramesToWaitFor, &num_frames_arrived]() {
42 num_frames_arrived += 1; 42 num_frames_arrived += 1;
43 if (num_frames_arrived >= kNumFramesToWaitFor) { 43 if (num_frames_arrived >= kNumFramesToWaitFor) {
44 wait_loop.Quit(); 44 wait_loop.Quit();
45 } 45 }
46 })); 46 }));
47 47
48 fake_device_proxy_->Start(requestable_settings_, 48 fake_device_proxy_->Start(requestable_settings_,
49 std::move(receiver_proxy)); 49 std::move(receiver_proxy));
50 wait_loop.Run(); 50 wait_loop.Run();
51 } 51 }
52 52
53 // 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
54 // format and have increasing timestamps. 54 // format and have increasing timestamps.
55 TEST_F(FakeDeviceTest, ReceiveFramesFromFakeCaptureDevice) { 55 TEST_F(FakeDeviceTest, ReceiveFramesFromFakeCaptureDevice) {
56 base::RunLoop wait_loop; 56 base::RunLoop wait_loop;
57 mojom::VideoFrameReceiverPtr receiver_proxy; 57 mojom::ReceiverPtr receiver_proxy;
58 constexpr int num_frames_to_receive = 2; 58 constexpr int num_frames_to_receive = 2;
59 FrameInfo received_frame_infos[num_frames_to_receive]; 59 FrameInfo received_frame_infos[num_frames_to_receive];
60 int received_frame_count = 0; 60 int received_frame_count = 0;
61 MockVideoFrameReceiver receiver(mojo::GetProxy(&receiver_proxy)); 61 MockReceiver receiver(mojo::GetProxy(&receiver_proxy));
62 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) 62 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_))
63 .WillRepeatedly( 63 .WillRepeatedly(
64 Invoke([&received_frame_infos, &received_frame_count, 64 Invoke([&received_frame_infos, &received_frame_count,
65 &num_frames_to_receive, &wait_loop]( 65 &num_frames_to_receive, &wait_loop](
66 const media::mojom::VideoFramePtr* frame) { 66 const media::mojom::VideoFramePtr* frame) {
67 if (received_frame_count >= num_frames_to_receive) 67 if (received_frame_count >= num_frames_to_receive)
68 return; 68 return;
69 auto video_frame = frame->To<scoped_refptr<media::VideoFrame>>(); 69 auto video_frame = frame->To<scoped_refptr<media::VideoFrame>>();
70 auto& frame_info = received_frame_infos[received_frame_count]; 70 auto& frame_info = received_frame_infos[received_frame_count];
71 frame_info.pixel_format = video_frame->format(); 71 frame_info.pixel_format = video_frame->format();
(...skipping 23 matching lines...) Expand all
95 EXPECT_EQ(requestable_settings_.format.frame_size, 95 EXPECT_EQ(requestable_settings_.format.frame_size,
96 frame_info.size); 96 frame_info.size);
97 // Timestamps are expected to increase 97 // Timestamps are expected to increase
98 if (i > 0) 98 if (i > 0)
99 EXPECT_GT(frame_info.timestamp, previous_timestamp); 99 EXPECT_GT(frame_info.timestamp, previous_timestamp);
100 previous_timestamp = frame_info.timestamp; 100 previous_timestamp = frame_info.timestamp;
101 } 101 }
102 } 102 }
103 103
104 } // namespace video_capture 104 } // namespace video_capture
OLDNEW
« no previous file with comments | « services/video_capture/fake_device_test.cc ('k') | services/video_capture/mock_device_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698