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

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: 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::AtLeast;
emircan 2017/04/17 21:02:12 I don't see AtLeast being used here.
15 using testing::Invoke; 16 using testing::Invoke;
16 using testing::InvokeWithoutArgs; 17 using testing::InvokeWithoutArgs;
17 18
18 namespace { 19 namespace {
19 20
20 struct FrameInfo { 21 struct FrameInfo {
21 gfx::Size size; 22 gfx::Size size;
22 media::VideoPixelFormat pixel_format; 23 media::VideoPixelFormat pixel_format;
23 media::VideoFrame::StorageType storage_type; 24 media::VideoFrame::StorageType storage_type;
24 bool is_mappable;
25 base::TimeDelta timestamp; 25 base::TimeDelta timestamp;
26 }; 26 };
27 27
28 } // anonymous namespace 28 } // anonymous namespace
29 29
30 namespace video_capture { 30 namespace video_capture {
31 31
32 // This alias ensures test output is easily attributed to this service's tests. 32 // This alias ensures test output is easily attributed to this service's tests.
33 // TODO(rockot/chfremer): Consider just renaming the type. 33 // TODO(rockot/chfremer): Consider just renaming the type.
34 using FakeVideoCaptureDeviceTest = FakeDeviceTest; 34 using FakeVideoCaptureDeviceTest = FakeDeviceTest;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) 71 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_))
72 .WillRepeatedly(Invoke( 72 .WillRepeatedly(Invoke(
73 [&received_frame_infos, &received_frame_count, &wait_loop] 73 [&received_frame_infos, &received_frame_count, &wait_loop]
74 (const media::mojom::VideoFramePtr* frame) { 74 (const media::mojom::VideoFramePtr* frame) {
75 if (received_frame_count >= num_frames_to_receive) 75 if (received_frame_count >= num_frames_to_receive)
76 return; 76 return;
77 auto video_frame = frame->To<scoped_refptr<media::VideoFrame>>(); 77 auto video_frame = frame->To<scoped_refptr<media::VideoFrame>>();
78 auto& frame_info = received_frame_infos[received_frame_count]; 78 auto& frame_info = received_frame_infos[received_frame_count];
79 frame_info.pixel_format = video_frame->format(); 79 frame_info.pixel_format = video_frame->format();
80 frame_info.storage_type = video_frame->storage_type(); 80 frame_info.storage_type = video_frame->storage_type();
81 frame_info.is_mappable = video_frame->IsMappable();
82 frame_info.size = video_frame->natural_size(); 81 frame_info.size = video_frame->natural_size();
83 frame_info.timestamp = video_frame->timestamp(); 82 frame_info.timestamp = video_frame->timestamp();
84 received_frame_count += 1; 83 received_frame_count += 1;
85 if (received_frame_count == num_frames_to_receive) 84 if (received_frame_count == num_frames_to_receive)
86 wait_loop.Quit(); 85 wait_loop.Quit();
87 })); 86 }));
88 87
89 fake_device_proxy_->Start(requestable_settings_, std::move(receiver_proxy)); 88 fake_device_proxy_->Start(requestable_settings_, std::move(receiver_proxy));
90 89
91 wait_loop.Run(); 90 wait_loop.Run();
92 91
93 base::TimeDelta previous_timestamp; 92 base::TimeDelta previous_timestamp;
94 for (int i = 0; i < num_frames_to_receive; i++) { 93 for (int i = 0; i < num_frames_to_receive; i++) {
95 auto& frame_info = received_frame_infos[i]; 94 auto& frame_info = received_frame_infos[i];
96 // Service is expected to always output I420 95 // Service is expected to always output I420
97 EXPECT_EQ(media::PIXEL_FORMAT_I420, frame_info.pixel_format); 96 EXPECT_EQ(media::PIXEL_FORMAT_I420, frame_info.pixel_format);
98 // Service is expected to always use STORAGE_MOJO_SHARED_BUFFER 97 // Service is expected to always use STORAGE_MOJO_SHARED_BUFFER
99 EXPECT_EQ(media::VideoFrame::STORAGE_MOJO_SHARED_BUFFER, 98 EXPECT_EQ(media::VideoFrame::STORAGE_MOJO_SHARED_BUFFER,
100 frame_info.storage_type); 99 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 100 // Timestamps are expected to increase
104 if (i > 0) 101 if (i > 0)
105 EXPECT_GT(frame_info.timestamp, previous_timestamp); 102 EXPECT_GT(frame_info.timestamp, previous_timestamp);
106 previous_timestamp = frame_info.timestamp; 103 previous_timestamp = frame_info.timestamp;
107 } 104 }
108 } 105 }
109 106
110 } // namespace video_capture 107 } // 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