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

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

Issue 2813343002: [Mojo Video Capture] Switch to using Mojo structs in media/capture/mojo (Closed)
Patch Set: Removed extraneous AtLeast Created 3 years, 8 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/device_media_to_mojo_adapter.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 13
14 using testing::_; 14 using testing::_;
15 using testing::Invoke; 15 using testing::Invoke;
16 using testing::InvokeWithoutArgs; 16 using testing::InvokeWithoutArgs;
17 17
18 namespace { 18 namespace {
19 19
20 struct FrameInfo { 20 struct FrameInfo {
21 gfx::Size size; 21 gfx::Size size;
22 media::VideoPixelFormat pixel_format; 22 media::VideoPixelFormat pixel_format;
23 media::VideoFrame::StorageType storage_type; 23 media::VideoFrame::StorageType storage_type;
24 bool is_mappable;
25 base::TimeDelta timestamp; 24 base::TimeDelta timestamp;
26 }; 25 };
27 26
28 } // anonymous namespace 27 } // anonymous namespace
29 28
30 namespace video_capture { 29 namespace video_capture {
31 30
32 // This alias ensures test output is easily attributed to this service's tests. 31 // This alias ensures test output is easily attributed to this service's tests.
33 // TODO(rockot/chfremer): Consider just renaming the type. 32 // TODO(rockot/chfremer): Consider just renaming the type.
34 using FakeVideoCaptureDeviceTest = FakeDeviceTest; 33 using FakeVideoCaptureDeviceTest = FakeDeviceTest;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) 70 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_))
72 .WillRepeatedly(Invoke( 71 .WillRepeatedly(Invoke(
73 [&received_frame_infos, &received_frame_count, &wait_loop] 72 [&received_frame_infos, &received_frame_count, &wait_loop]
74 (const media::mojom::VideoFramePtr* frame) { 73 (const media::mojom::VideoFramePtr* frame) {
75 if (received_frame_count >= num_frames_to_receive) 74 if (received_frame_count >= num_frames_to_receive)
76 return; 75 return;
77 auto video_frame = frame->To<scoped_refptr<media::VideoFrame>>(); 76 auto video_frame = frame->To<scoped_refptr<media::VideoFrame>>();
78 auto& frame_info = received_frame_infos[received_frame_count]; 77 auto& frame_info = received_frame_infos[received_frame_count];
79 frame_info.pixel_format = video_frame->format(); 78 frame_info.pixel_format = video_frame->format();
80 frame_info.storage_type = video_frame->storage_type(); 79 frame_info.storage_type = video_frame->storage_type();
81 frame_info.is_mappable = video_frame->IsMappable();
82 frame_info.size = video_frame->natural_size(); 80 frame_info.size = video_frame->natural_size();
83 frame_info.timestamp = video_frame->timestamp(); 81 frame_info.timestamp = video_frame->timestamp();
84 received_frame_count += 1; 82 received_frame_count += 1;
85 if (received_frame_count == num_frames_to_receive) 83 if (received_frame_count == num_frames_to_receive)
86 wait_loop.Quit(); 84 wait_loop.Quit();
87 })); 85 }));
88 86
89 fake_device_proxy_->Start(requestable_settings_, std::move(receiver_proxy)); 87 fake_device_proxy_->Start(requestable_settings_, std::move(receiver_proxy));
90 88
91 wait_loop.Run(); 89 wait_loop.Run();
92 90
93 base::TimeDelta previous_timestamp; 91 base::TimeDelta previous_timestamp;
94 for (int i = 0; i < num_frames_to_receive; i++) { 92 for (int i = 0; i < num_frames_to_receive; i++) {
95 auto& frame_info = received_frame_infos[i]; 93 auto& frame_info = received_frame_infos[i];
96 // Service is expected to always output I420 94 // Service is expected to always output I420
97 EXPECT_EQ(media::PIXEL_FORMAT_I420, frame_info.pixel_format); 95 EXPECT_EQ(media::PIXEL_FORMAT_I420, frame_info.pixel_format);
98 // Service is expected to always use STORAGE_MOJO_SHARED_BUFFER 96 // Service is expected to always use STORAGE_MOJO_SHARED_BUFFER
99 EXPECT_EQ(media::VideoFrame::STORAGE_MOJO_SHARED_BUFFER, 97 EXPECT_EQ(media::VideoFrame::STORAGE_MOJO_SHARED_BUFFER,
100 frame_info.storage_type); 98 frame_info.storage_type);
101 EXPECT_TRUE(frame_info.is_mappable);
102 EXPECT_EQ(requestable_settings_.format.frame_size, frame_info.size);
103 // Timestamps are expected to increase 99 // Timestamps are expected to increase
104 if (i > 0) 100 if (i > 0)
105 EXPECT_GT(frame_info.timestamp, previous_timestamp); 101 EXPECT_GT(frame_info.timestamp, previous_timestamp);
106 previous_timestamp = frame_info.timestamp; 102 previous_timestamp = frame_info.timestamp;
107 } 103 }
108 } 104 }
109 105
110 } // namespace video_capture 106 } // namespace video_capture
OLDNEW
« no previous file with comments | « services/video_capture/test/fake_device_test.cc ('k') | services/video_capture/test/mock_device_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698