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

Side by Side Diff: content/browser/media/media_internals_unittest.cc

Issue 2169013002: Change class VideoCaptureDevice::Name to struct VideoCaptureDeviceDescriptor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build errors Created 4 years, 4 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/media/media_internals.h" 5 #include "content/browser/media/media_internals.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 106
107 ~MediaInternalsVideoCaptureDeviceTest() override { 107 ~MediaInternalsVideoCaptureDeviceTest() override {
108 media_internals_->RemoveUpdateCallback(update_cb_); 108 media_internals_->RemoveUpdateCallback(update_cb_);
109 } 109 }
110 110
111 protected: 111 protected:
112 MediaInternals::UpdateCallback update_cb_; 112 MediaInternals::UpdateCallback update_cb_;
113 }; 113 };
114 114
115 // TODO(chfremer): Consider removing this. This test seem be
116 // a duplicate implementation of the functionality under test.
117 // https://crbug.com/630694
115 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \ 118 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \
116 defined(OS_ANDROID) 119 defined(OS_ANDROID)
117 TEST_F(MediaInternalsVideoCaptureDeviceTest, 120 TEST_F(MediaInternalsVideoCaptureDeviceTest,
118 AllCaptureApiTypesHaveProperStringRepresentation) { 121 AllCaptureApiTypesHaveProperStringRepresentation) {
119 typedef media::VideoCaptureDevice::Name VideoCaptureDeviceName; 122 using VideoCaptureApi = media::VideoCaptureApi;
120 typedef std::map<VideoCaptureDeviceName::CaptureApiType, std::string> 123 std::map<VideoCaptureApi, std::string> api_to_string_map;
121 CaptureApiTypeStringMap; 124 api_to_string_map[VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE] = "V4L2 SPLANE";
122 CaptureApiTypeStringMap m; 125 api_to_string_map[VideoCaptureApi::WIN_MEDIA_FOUNDATION] = "Media Foundation";
123 #if defined(OS_LINUX) 126 api_to_string_map[VideoCaptureApi::WIN_DIRECT_SHOW] = "Direct Show";
124 m[VideoCaptureDeviceName::V4L2_SINGLE_PLANE] = "V4L2 SPLANE"; 127 api_to_string_map[VideoCaptureApi::MACOSX_AVFOUNDATION] = "AV Foundation";
125 #elif defined(OS_WIN) 128 api_to_string_map[VideoCaptureApi::MACOSX_DECKLINK] = "DeckLink";
126 m[VideoCaptureDeviceName::MEDIA_FOUNDATION] = "Media Foundation"; 129 api_to_string_map[VideoCaptureApi::ANDROID_API1] = "Camera API1";
127 m[VideoCaptureDeviceName::DIRECT_SHOW] = "Direct Show"; 130 api_to_string_map[VideoCaptureApi::ANDROID_API2_LEGACY] =
128 #elif defined(OS_MACOSX) 131 "Camera API2 Legacy";
129 m[VideoCaptureDeviceName::AVFOUNDATION] = "AV Foundation"; 132 api_to_string_map[VideoCaptureApi::ANDROID_API2_FULL] = "Camera API2 Full";
130 m[VideoCaptureDeviceName::DECKLINK] = "DeckLink"; 133 api_to_string_map[VideoCaptureApi::ANDROID_API2_LIMITED] =
131 #elif defined(OS_ANDROID) 134 "Camera API2 Limited";
132 m[VideoCaptureDeviceName::API1] = "Camera API1"; 135 api_to_string_map[VideoCaptureApi::ANDROID_TANGO] = "Tango API";
133 m[VideoCaptureDeviceName::API2_LEGACY] = "Camera API2 Legacy"; 136 EXPECT_EQ(static_cast<size_t>(VideoCaptureApi::UNKNOWN),
134 m[VideoCaptureDeviceName::API2_FULL] = "Camera API2 Full"; 137 api_to_string_map.size());
135 m[VideoCaptureDeviceName::API2_LIMITED] = "Camera API2 Limited"; 138 for (const auto& map_entry : api_to_string_map) {
136 m[VideoCaptureDeviceName::TANGO] = "Tango API"; 139 media::VideoCaptureDeviceDescriptor descriptor;
137 #endif 140 descriptor.capture_api = map_entry.first;
138 EXPECT_EQ(media::VideoCaptureDevice::Name::API_TYPE_UNKNOWN, m.size()); 141 EXPECT_EQ(map_entry.second, descriptor.GetCaptureApiTypeString());
139 for (CaptureApiTypeStringMap::iterator it = m.begin(); it != m.end(); ++it) {
140 const VideoCaptureDeviceName device_name("dummy", "dummy", it->first);
141 EXPECT_EQ(it->second, device_name.GetCaptureApiTypeString());
142 } 142 }
143 } 143 }
144 #endif 144 #endif
145 145
146 TEST_F(MediaInternalsVideoCaptureDeviceTest, 146 TEST_F(MediaInternalsVideoCaptureDeviceTest,
147 VideoCaptureFormatStringIsInExpectedFormat) { 147 VideoCaptureFormatStringIsInExpectedFormat) {
148 // Since media internals will send video capture capabilities to JavaScript in 148 // Since media internals will send video capture capabilities to JavaScript in
149 // an expected format and there are no public methods for accessing the 149 // an expected format and there are no public methods for accessing the
150 // resolutions, frame rates or pixel formats, this test checks that the format 150 // resolutions, frame rates or pixel formats, this test checks that the format
151 // has not changed. If the test fails because of the changed format, it should 151 // has not changed. If the test fails because of the changed format, it should
(...skipping 18 matching lines...) Expand all
170 NotifyVideoCaptureDeviceCapabilitiesEnumerated) { 170 NotifyVideoCaptureDeviceCapabilitiesEnumerated) {
171 const int kWidth = 1280; 171 const int kWidth = 1280;
172 const int kHeight = 720; 172 const int kHeight = 720;
173 const float kFrameRate = 30.0f; 173 const float kFrameRate = 30.0f;
174 const media::VideoPixelFormat kPixelFormat = 174 const media::VideoPixelFormat kPixelFormat =
175 media::PIXEL_FORMAT_I420; 175 media::PIXEL_FORMAT_I420;
176 const media::VideoCaptureFormat format_hd({kWidth, kHeight}, 176 const media::VideoCaptureFormat format_hd({kWidth, kHeight},
177 kFrameRate, kPixelFormat); 177 kFrameRate, kPixelFormat);
178 media::VideoCaptureFormats formats{}; 178 media::VideoCaptureFormats formats{};
179 formats.push_back(format_hd); 179 formats.push_back(format_hd);
180 const media::VideoCaptureDeviceInfo device_info( 180 media::VideoCaptureDeviceDescriptor descriptor;
181 descriptor.device_id = "dummy";
182 descriptor.display_name = "dummy";
181 #if defined(OS_MACOSX) 183 #if defined(OS_MACOSX)
182 media::VideoCaptureDevice::Name( 184 descriptor.capture_api = media::VideoCaptureApi::MACOSX_AVFOUNDATION;
183 "dummy", "dummy", media::VideoCaptureDevice::Name::AVFOUNDATION),
184 #elif defined(OS_WIN) 185 #elif defined(OS_WIN)
185 media::VideoCaptureDevice::Name("dummy", "dummy", 186 descriptor.capture_api = media::VideoCaptureApi::WIN_DIRECT_SHOW;
186 media::VideoCaptureDevice::Name::DIRECT_SHOW),
187 #elif defined(OS_LINUX) 187 #elif defined(OS_LINUX)
188 media::VideoCaptureDevice::Name( 188 descriptor.device_id = "/dev/dummy";
189 "dummy", "/dev/dummy", 189 descriptor.capture_api = media::VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE;
190 media::VideoCaptureDevice::Name::V4L2_SINGLE_PLANE),
191 #elif defined(OS_ANDROID) 190 #elif defined(OS_ANDROID)
192 media::VideoCaptureDevice::Name("dummy", "dummy", 191 descriptor.capture_api = media::VideoCaptureApi::ANDROID_API2_LEGACY;
193 media::VideoCaptureDevice::Name::API2_LEGACY),
194 #else
195 media::VideoCaptureDevice::Name("dummy", "dummy"),
196 #endif 192 #endif
197 formats); 193 std::vector<std::tuple<media::VideoCaptureDeviceDescriptor,
198 media::VideoCaptureDeviceInfos device_infos{}; 194 media::VideoCaptureFormats>>
199 device_infos.push_back(device_info); 195 descriptors_and_formats{};
196 descriptors_and_formats.push_back(std::make_tuple(descriptor, formats));
200 197
201 // When updating video capture capabilities, the update will serialize 198 // When updating video capture capabilities, the update will serialize
202 // a JSON array of objects to string. So here, the |UpdateCallbackImpl| will 199 // a JSON array of objects to string. So here, the |UpdateCallbackImpl| will
203 // deserialize the first object in the array. This means we have to have 200 // deserialize the first object in the array. This means we have to have
204 // exactly one device_info in the |device_infos|. 201 // exactly one device_info in the |descriptors_and_formats|.
205 media_internals_->UpdateVideoCaptureDeviceCapabilities(device_infos); 202 media_internals_->UpdateVideoCaptureDeviceCapabilities(
203 descriptors_and_formats);
206 204
207 #if defined(OS_LINUX) 205 #if defined(OS_LINUX)
208 ExpectString("id", "/dev/dummy"); 206 ExpectString("id", "/dev/dummy");
209 #else 207 #else
210 ExpectString("id", "dummy"); 208 ExpectString("id", "dummy");
211 #endif 209 #endif
212 ExpectString("name", "dummy"); 210 ExpectString("name", "dummy");
213 base::ListValue expected_list; 211 base::ListValue expected_list;
214 expected_list.AppendString(media::VideoCaptureFormat::ToString(format_hd)); 212 expected_list.AppendString(media::VideoCaptureFormat::ToString(format_hd));
215 ExpectListOfStrings("formats", expected_list); 213 ExpectListOfStrings("formats", expected_list);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 ExpectStatus("closed"); 304 ExpectStatus("closed");
307 } 305 }
308 306
309 INSTANTIATE_TEST_CASE_P( 307 INSTANTIATE_TEST_CASE_P(
310 MediaInternalsAudioLogTest, MediaInternalsAudioLogTest, testing::Values( 308 MediaInternalsAudioLogTest, MediaInternalsAudioLogTest, testing::Values(
311 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER, 309 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER,
312 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER, 310 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER,
313 media::AudioLogFactory::AUDIO_OUTPUT_STREAM)); 311 media::AudioLogFactory::AUDIO_OUTPUT_STREAM));
314 312
315 } // namespace content 313 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/media_internals.cc ('k') | content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698