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

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

Issue 2639883006: Fix unused lambda captures in //device and //services/media_capture. (Closed)
Patch Set: constexpr -> static const 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 const int kNumFramesToWaitFor = 3; 35 // These two constants must be static as a workaround
36 // for a MSVC++ bug about lambda captures, see the discussion at
37 // https://social.msdn.microsoft.com/Forums/SqlServer/4abf18bd-4ae4-4c72-ba3e- 3b13e7909d5f
38 static const int kNumFramesToWaitFor = 3;
36 int num_frames_arrived = 0; 39 int num_frames_arrived = 0;
37 mojom::ReceiverPtr receiver_proxy; 40 mojom::ReceiverPtr receiver_proxy;
38 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy)); 41 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy));
39 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) 42 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_))
40 .WillRepeatedly(InvokeWithoutArgs( 43 .WillRepeatedly(InvokeWithoutArgs(
41 [&wait_loop, &kNumFramesToWaitFor, &num_frames_arrived]() { 44 [&wait_loop, &num_frames_arrived]() {
42 num_frames_arrived += 1; 45 num_frames_arrived += 1;
43 if (num_frames_arrived >= kNumFramesToWaitFor) { 46 if (num_frames_arrived >= kNumFramesToWaitFor) {
44 wait_loop.Quit(); 47 wait_loop.Quit();
45 } 48 }
46 })); 49 }));
47 50
48 fake_device_proxy_->Start(requestable_settings_, std::move(receiver_proxy)); 51 fake_device_proxy_->Start(requestable_settings_, std::move(receiver_proxy));
49 wait_loop.Run(); 52 wait_loop.Run();
50 } 53 }
51 54
52 // Tests that frames received from a fake capture device match the requested 55 // Tests that frames received from a fake capture device match the requested
53 // format and have increasing timestamps. 56 // format and have increasing timestamps.
54 TEST_F(FakeDeviceTest, DISABLED_ReceiveFramesFromFakeCaptureDevice) { 57 TEST_F(FakeDeviceTest, DISABLED_ReceiveFramesFromFakeCaptureDevice) {
55 base::RunLoop wait_loop; 58 base::RunLoop wait_loop;
56 mojom::ReceiverPtr receiver_proxy; 59 mojom::ReceiverPtr receiver_proxy;
57 constexpr int num_frames_to_receive = 2; 60 // These two constants must be static as a workaround
61 // for a MSVC++ bug about lambda captures, see the discussion at
62 // https://social.msdn.microsoft.com/Forums/SqlServer/4abf18bd-4ae4-4c72-ba3e- 3b13e7909d5f
63 static const int num_frames_to_receive = 2;
58 FrameInfo received_frame_infos[num_frames_to_receive]; 64 FrameInfo received_frame_infos[num_frames_to_receive];
59 int received_frame_count = 0; 65 int received_frame_count = 0;
60 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy)); 66 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy));
61 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) 67 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_))
62 .WillRepeatedly(Invoke( 68 .WillRepeatedly(Invoke(
63 [&received_frame_infos, &received_frame_count, &num_frames_to_receive, 69 [&received_frame_infos, &received_frame_count, &wait_loop]
64 &wait_loop](const media::mojom::VideoFramePtr* frame) { 70 (const media::mojom::VideoFramePtr* frame) {
65 if (received_frame_count >= num_frames_to_receive) 71 if (received_frame_count >= num_frames_to_receive)
66 return; 72 return;
67 auto video_frame = frame->To<scoped_refptr<media::VideoFrame>>(); 73 auto video_frame = frame->To<scoped_refptr<media::VideoFrame>>();
68 auto& frame_info = received_frame_infos[received_frame_count]; 74 auto& frame_info = received_frame_infos[received_frame_count];
69 frame_info.pixel_format = video_frame->format(); 75 frame_info.pixel_format = video_frame->format();
70 frame_info.storage_type = video_frame->storage_type(); 76 frame_info.storage_type = video_frame->storage_type();
71 frame_info.is_mappable = video_frame->IsMappable(); 77 frame_info.is_mappable = video_frame->IsMappable();
72 frame_info.size = video_frame->natural_size(); 78 frame_info.size = video_frame->natural_size();
73 frame_info.timestamp = video_frame->timestamp(); 79 frame_info.timestamp = video_frame->timestamp();
74 received_frame_count += 1; 80 received_frame_count += 1;
(...skipping 16 matching lines...) Expand all
91 EXPECT_TRUE(frame_info.is_mappable); 97 EXPECT_TRUE(frame_info.is_mappable);
92 EXPECT_EQ(requestable_settings_.format.frame_size, frame_info.size); 98 EXPECT_EQ(requestable_settings_.format.frame_size, frame_info.size);
93 // Timestamps are expected to increase 99 // Timestamps are expected to increase
94 if (i > 0) 100 if (i > 0)
95 EXPECT_GT(frame_info.timestamp, previous_timestamp); 101 EXPECT_GT(frame_info.timestamp, previous_timestamp);
96 previous_timestamp = frame_info.timestamp; 102 previous_timestamp = frame_info.timestamp;
97 } 103 }
98 } 104 }
99 105
100 } // namespace video_capture 106 } // 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