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

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

Issue 2660743002: Merge video_capture tests into service_unittests (Closed)
Patch Set: . Created 3 years, 10 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
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"
11 #include "services/video_capture/test/fake_device_test.h" 11 #include "services/video_capture/test/fake_device_test.h"
12 #include "services/video_capture/test/mock_receiver.h" 12 #include "services/video_capture/test/mock_receiver.h"
13 #include "services/video_capture/test/service_test.h"
14 13
15 using testing::_; 14 using testing::_;
16 using testing::Invoke; 15 using testing::Invoke;
17 using testing::InvokeWithoutArgs; 16 using testing::InvokeWithoutArgs;
18 17
19 namespace { 18 namespace {
20 19
21 struct FrameInfo { 20 struct FrameInfo {
22 gfx::Size size; 21 gfx::Size size;
23 media::VideoPixelFormat pixel_format; 22 media::VideoPixelFormat pixel_format;
24 media::VideoFrame::StorageType storage_type; 23 media::VideoFrame::StorageType storage_type;
25 bool is_mappable; 24 bool is_mappable;
26 base::TimeDelta timestamp; 25 base::TimeDelta timestamp;
27 }; 26 };
28 27
29 } // anonymous namespace 28 } // anonymous namespace
30 29
31 namespace video_capture { 30 namespace video_capture {
32 31
33 TEST_F(FakeDeviceTest, DISABLED_FrameCallbacksArrive) { 32 // This alias ensures test output is easily attributed to this service's tests.
33 // TODO(rockot/chfremer): Consider just renaming the type.
34 using FakeVideoCaptureDeviceTest = FakeDeviceTest;
35
36 TEST_F(FakeVideoCaptureDeviceTest, DISABLED_FrameCallbacksArrive) {
34 base::RunLoop wait_loop; 37 base::RunLoop wait_loop;
35 // These two constants must be static as a workaround 38 // These two constants must be static as a workaround
36 // for a MSVC++ bug about lambda captures, see the discussion at 39 // for a MSVC++ bug about lambda captures, see the discussion at
37 // https://social.msdn.microsoft.com/Forums/SqlServer/4abf18bd-4ae4-4c72-ba3e- 3b13e7909d5f 40 // https://social.msdn.microsoft.com/Forums/SqlServer/4abf18bd-4ae4-4c72-ba3e- 3b13e7909d5f
38 static const int kNumFramesToWaitFor = 3; 41 static const int kNumFramesToWaitFor = 3;
39 int num_frames_arrived = 0; 42 int num_frames_arrived = 0;
40 mojom::ReceiverPtr receiver_proxy; 43 mojom::ReceiverPtr receiver_proxy;
41 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy)); 44 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy));
42 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) 45 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_))
43 .WillRepeatedly(InvokeWithoutArgs( 46 .WillRepeatedly(InvokeWithoutArgs(
44 [&wait_loop, &num_frames_arrived]() { 47 [&wait_loop, &num_frames_arrived]() {
45 num_frames_arrived += 1; 48 num_frames_arrived += 1;
46 if (num_frames_arrived >= kNumFramesToWaitFor) { 49 if (num_frames_arrived >= kNumFramesToWaitFor) {
47 wait_loop.Quit(); 50 wait_loop.Quit();
48 } 51 }
49 })); 52 }));
50 53
51 fake_device_proxy_->Start(requestable_settings_, std::move(receiver_proxy)); 54 fake_device_proxy_->Start(requestable_settings_, std::move(receiver_proxy));
52 wait_loop.Run(); 55 wait_loop.Run();
53 } 56 }
54 57
55 // Tests that frames received from a fake capture device match the requested 58 // Tests that frames received from a fake capture device match the requested
56 // format and have increasing timestamps. 59 // format and have increasing timestamps.
57 TEST_F(FakeDeviceTest, DISABLED_ReceiveFramesFromFakeCaptureDevice) { 60 TEST_F(FakeVideoCaptureDeviceTest,
61 DISABLED_ReceiveFramesFromFakeCaptureDevice) {
58 base::RunLoop wait_loop; 62 base::RunLoop wait_loop;
59 mojom::ReceiverPtr receiver_proxy; 63 mojom::ReceiverPtr receiver_proxy;
60 // These two constants must be static as a workaround 64 // These two constants must be static as a workaround
61 // for a MSVC++ bug about lambda captures, see the discussion at 65 // for a MSVC++ bug about lambda captures, see the discussion at
62 // https://social.msdn.microsoft.com/Forums/SqlServer/4abf18bd-4ae4-4c72-ba3e- 3b13e7909d5f 66 // https://social.msdn.microsoft.com/Forums/SqlServer/4abf18bd-4ae4-4c72-ba3e- 3b13e7909d5f
63 static const int num_frames_to_receive = 2; 67 static const int num_frames_to_receive = 2;
64 FrameInfo received_frame_infos[num_frames_to_receive]; 68 FrameInfo received_frame_infos[num_frames_to_receive];
65 int received_frame_count = 0; 69 int received_frame_count = 0;
66 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy)); 70 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy));
67 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) 71 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_))
(...skipping 29 matching lines...) Expand all
97 EXPECT_TRUE(frame_info.is_mappable); 101 EXPECT_TRUE(frame_info.is_mappable);
98 EXPECT_EQ(requestable_settings_.format.frame_size, frame_info.size); 102 EXPECT_EQ(requestable_settings_.format.frame_size, frame_info.size);
99 // Timestamps are expected to increase 103 // Timestamps are expected to increase
100 if (i > 0) 104 if (i > 0)
101 EXPECT_GT(frame_info.timestamp, previous_timestamp); 105 EXPECT_GT(frame_info.timestamp, previous_timestamp);
102 previous_timestamp = frame_info.timestamp; 106 previous_timestamp = frame_info.timestamp;
103 } 107 }
104 } 108 }
105 109
106 } // namespace video_capture 110 } // namespace video_capture
OLDNEW
« no previous file with comments | « services/video_capture/test/fake_device_descriptor_unittest.cc ('k') | services/video_capture/test/mock_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698