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

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

Issue 2643853006: Revert of Fix unused lambda captures in //device and //services/media_capture. (Closed)
Patch Set: Created 3 years, 11 months 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
« no previous file with comments | « device/generic_sensor/platform_sensor_and_provider_unittest_linux.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/public/cpp/capture_settings.h" 9 #include "services/video_capture/public/cpp/capture_settings.h"
10 #include "services/video_capture/public/interfaces/device_factory.mojom.h" 10 #include "services/video_capture/public/interfaces/device_factory.mojom.h"
(...skipping 14 matching lines...) Expand all
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, DISABLED_FrameCallbacksArrive) { 33 TEST_F(FakeDeviceTest, DISABLED_FrameCallbacksArrive) {
34 base::RunLoop wait_loop; 34 base::RunLoop wait_loop;
35 constexpr int kNumFramesToWaitFor = 3; 35 const int kNumFramesToWaitFor = 3;
36 int num_frames_arrived = 0; 36 int num_frames_arrived = 0;
37 mojom::ReceiverPtr receiver_proxy; 37 mojom::ReceiverPtr receiver_proxy;
38 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy)); 38 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy));
39 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) 39 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_))
40 .WillRepeatedly(InvokeWithoutArgs( 40 .WillRepeatedly(InvokeWithoutArgs(
41 [&wait_loop, &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_, std::move(receiver_proxy)); 48 fake_device_proxy_->Start(requestable_settings_, std::move(receiver_proxy));
49 wait_loop.Run(); 49 wait_loop.Run();
50 } 50 }
51 51
52 // Tests that frames received from a fake capture device match the requested 52 // Tests that frames received from a fake capture device match the requested
53 // format and have increasing timestamps. 53 // format and have increasing timestamps.
54 TEST_F(FakeDeviceTest, DISABLED_ReceiveFramesFromFakeCaptureDevice) { 54 TEST_F(FakeDeviceTest, DISABLED_ReceiveFramesFromFakeCaptureDevice) {
55 base::RunLoop wait_loop; 55 base::RunLoop wait_loop;
56 mojom::ReceiverPtr receiver_proxy; 56 mojom::ReceiverPtr receiver_proxy;
57 constexpr int num_frames_to_receive = 2; 57 constexpr int num_frames_to_receive = 2;
58 FrameInfo received_frame_infos[num_frames_to_receive]; 58 FrameInfo received_frame_infos[num_frames_to_receive];
59 int received_frame_count = 0; 59 int received_frame_count = 0;
60 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy)); 60 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy));
61 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) 61 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_))
62 .WillRepeatedly(Invoke( 62 .WillRepeatedly(Invoke(
63 [&received_frame_infos, &received_frame_count, &wait_loop] 63 [&received_frame_infos, &received_frame_count, &num_frames_to_receive,
64 (const media::mojom::VideoFramePtr* frame) { 64 &wait_loop](const media::mojom::VideoFramePtr* frame) {
65 if (received_frame_count >= num_frames_to_receive) 65 if (received_frame_count >= num_frames_to_receive)
66 return; 66 return;
67 auto video_frame = frame->To<scoped_refptr<media::VideoFrame>>(); 67 auto video_frame = frame->To<scoped_refptr<media::VideoFrame>>();
68 auto& frame_info = received_frame_infos[received_frame_count]; 68 auto& frame_info = received_frame_infos[received_frame_count];
69 frame_info.pixel_format = video_frame->format(); 69 frame_info.pixel_format = video_frame->format();
70 frame_info.storage_type = video_frame->storage_type(); 70 frame_info.storage_type = video_frame->storage_type();
71 frame_info.is_mappable = video_frame->IsMappable(); 71 frame_info.is_mappable = video_frame->IsMappable();
72 frame_info.size = video_frame->natural_size(); 72 frame_info.size = video_frame->natural_size();
73 frame_info.timestamp = video_frame->timestamp(); 73 frame_info.timestamp = video_frame->timestamp();
74 received_frame_count += 1; 74 received_frame_count += 1;
(...skipping 16 matching lines...) Expand all
91 EXPECT_TRUE(frame_info.is_mappable); 91 EXPECT_TRUE(frame_info.is_mappable);
92 EXPECT_EQ(requestable_settings_.format.frame_size, frame_info.size); 92 EXPECT_EQ(requestable_settings_.format.frame_size, frame_info.size);
93 // Timestamps are expected to increase 93 // Timestamps are expected to increase
94 if (i > 0) 94 if (i > 0)
95 EXPECT_GT(frame_info.timestamp, previous_timestamp); 95 EXPECT_GT(frame_info.timestamp, previous_timestamp);
96 previous_timestamp = frame_info.timestamp; 96 previous_timestamp = frame_info.timestamp;
97 } 97 }
98 } 98 }
99 99
100 } // namespace video_capture 100 } // namespace video_capture
OLDNEW
« no previous file with comments | « device/generic_sensor/platform_sensor_and_provider_unittest_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698