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

Side by Side Diff: content/renderer/media/media_stream_constraints_util_video_device_unittest.cc

Issue 2711783008: Support the googNoiseReduction constraint in SelectSettings for video-device capture. (Closed)
Patch Set: remove redundant braces Created 3 years, 9 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/renderer/media/media_stream_constraints_util_video_device.h" 5 #include "content/renderer/media/media_stream_constraints_util_video_device.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/optional.h" 10 #include "base/optional.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 device->formats = {media::VideoCaptureFormat(gfx::Size(640, 480), 30.0f, 93 device->formats = {media::VideoCaptureFormat(gfx::Size(640, 480), 30.0f,
94 media::PIXEL_FORMAT_Y16)}; 94 media::PIXEL_FORMAT_Y16)};
95 capabilities_.device_capabilities.push_back(std::move(device)); 95 capabilities_.device_capabilities.push_back(std::move(device));
96 96
97 capabilities_.power_line_capabilities = { 97 capabilities_.power_line_capabilities = {
98 media::PowerLineFrequency::FREQUENCY_DEFAULT, 98 media::PowerLineFrequency::FREQUENCY_DEFAULT,
99 media::PowerLineFrequency::FREQUENCY_50HZ, 99 media::PowerLineFrequency::FREQUENCY_50HZ,
100 media::PowerLineFrequency::FREQUENCY_60HZ, 100 media::PowerLineFrequency::FREQUENCY_60HZ,
101 }; 101 };
102 102
103 capabilities_.noise_reduction_capabilities = {
104 rtc::Optional<bool>(), rtc::Optional<bool>(true),
105 rtc::Optional<bool>(false),
106 };
107
103 default_device_ = capabilities_.device_capabilities[0].get(); 108 default_device_ = capabilities_.device_capabilities[0].get();
104 low_res_device_ = capabilities_.device_capabilities[1].get(); 109 low_res_device_ = capabilities_.device_capabilities[1].get();
105 high_res_device_ = capabilities_.device_capabilities[2].get(); 110 high_res_device_ = capabilities_.device_capabilities[2].get();
106 default_closest_format_ = &default_device_->formats[1]; 111 default_closest_format_ = &default_device_->formats[1];
107 low_res_closest_format_ = &low_res_device_->formats[2]; 112 low_res_closest_format_ = &low_res_device_->formats[2];
108 high_res_closest_format_ = &high_res_device_->formats[2]; 113 high_res_closest_format_ = &high_res_device_->formats[2];
109 high_res_highest_format_ = &high_res_device_->formats[5]; 114 high_res_highest_format_ = &high_res_device_->formats[5];
110 } 115 }
111 116
112 protected: 117 protected:
(...skipping 18 matching lines...) Expand all
131 136
132 // The Unconstrained test checks the default selection criteria. 137 // The Unconstrained test checks the default selection criteria.
133 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, Unconstrained) { 138 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, Unconstrained) {
134 constraint_factory_.Reset(); 139 constraint_factory_.Reset();
135 auto result = SelectSettings(); 140 auto result = SelectSettings();
136 EXPECT_TRUE(result.HasValue()); 141 EXPECT_TRUE(result.HasValue());
137 // Should select the default device with closest-to-default settings. 142 // Should select the default device with closest-to-default settings.
138 EXPECT_EQ(default_device_->device_id, result.device_id); 143 EXPECT_EQ(default_device_->device_id, result.device_id);
139 EXPECT_EQ(default_device_->facing_mode, result.facing_mode); 144 EXPECT_EQ(default_device_->facing_mode, result.facing_mode);
140 EXPECT_EQ(*default_closest_format_, result.Format()); 145 EXPECT_EQ(*default_closest_format_, result.Format());
146 // Should select default settings for other constraints.
147 EXPECT_EQ(media::PowerLineFrequency::FREQUENCY_DEFAULT,
148 result.PowerLineFrequency());
149 EXPECT_EQ(rtc::Optional<bool>(), result.noise_reduction);
141 } 150 }
142 151
143 // The "Overconstrained" tests verify that failure of any single required 152 // The "Overconstrained" tests verify that failure of any single required
144 // constraint results in failure to select a candidate. 153 // constraint results in failure to select a candidate.
145 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, OverconstrainedOnDeviceID) { 154 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, OverconstrainedOnDeviceID) {
146 constraint_factory_.Reset(); 155 constraint_factory_.Reset();
147 constraint_factory_.basic().deviceId.setExact( 156 constraint_factory_.basic().deviceId.setExact(
148 blink::WebString::fromASCII("NONEXISTING")); 157 blink::WebString::fromASCII("NONEXISTING"));
149 auto result = SelectSettings(); 158 auto result = SelectSettings();
150 EXPECT_FALSE(result.HasValue()); 159 EXPECT_FALSE(result.HasValue());
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 result.failed_constraint_name); 295 result.failed_constraint_name);
287 296
288 constraint_factory_.Reset(); 297 constraint_factory_.Reset();
289 constraint_factory_.basic().googPowerLineFrequency.setMax(-1); 298 constraint_factory_.basic().googPowerLineFrequency.setMax(-1);
290 result = SelectSettings(); 299 result = SelectSettings();
291 EXPECT_FALSE(result.HasValue()); 300 EXPECT_FALSE(result.HasValue());
292 EXPECT_EQ(constraint_factory_.basic().googPowerLineFrequency.name(), 301 EXPECT_EQ(constraint_factory_.basic().googPowerLineFrequency.name(),
293 result.failed_constraint_name); 302 result.failed_constraint_name);
294 } 303 }
295 304
305 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
306 OverconstrainedOnNoiseReduction) {
307 // Simulate a system that does not support noise reduction.
308 // Manually adding device capabilities because VideoDeviceCaptureCapabilities
309 // is move only.
310 VideoDeviceCaptureCapabilities capabilities;
311 ::mojom::VideoInputDeviceCapabilitiesPtr device =
312 ::mojom::VideoInputDeviceCapabilities::New();
313 device->device_id = kDeviceID1;
314 device->facing_mode = ::mojom::FacingMode::NONE;
315 device->formats = {
316 media::VideoCaptureFormat(gfx::Size(200, 200), 40.0f,
317 media::PIXEL_FORMAT_I420),
318 };
319 capabilities.device_capabilities.push_back(std::move(device));
320 capabilities.power_line_capabilities = capabilities_.power_line_capabilities;
321 capabilities.noise_reduction_capabilities = {rtc::Optional<bool>(false)};
322
323 constraint_factory_.Reset();
324 constraint_factory_.basic().googNoiseReduction.setExact(true);
325 auto constraints = constraint_factory_.CreateWebMediaConstraints();
326 auto result =
327 SelectVideoDeviceCaptureSourceSettings(capabilities, constraints);
328 EXPECT_FALSE(result.HasValue());
329 EXPECT_EQ(constraint_factory_.basic().googNoiseReduction.name(),
330 result.failed_constraint_name);
331 }
332
296 // The "Mandatory" and "Ideal" tests check that various selection criteria work 333 // The "Mandatory" and "Ideal" tests check that various selection criteria work
297 // for each individual constraint in the basic constraint set. 334 // for each individual constraint in the basic constraint set.
298 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryDeviceID) { 335 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryDeviceID) {
299 constraint_factory_.Reset(); 336 constraint_factory_.Reset();
300 constraint_factory_.basic().deviceId.setExact( 337 constraint_factory_.basic().deviceId.setExact(
301 blink::WebString::fromASCII(default_device_->device_id)); 338 blink::WebString::fromASCII(default_device_->device_id));
302 auto result = SelectSettings(); 339 auto result = SelectSettings();
303 EXPECT_TRUE(result.HasValue()); 340 EXPECT_TRUE(result.HasValue());
304 EXPECT_EQ(default_device_->device_id, result.device_id); 341 EXPECT_EQ(default_device_->device_id, result.device_id);
305 EXPECT_EQ(*default_closest_format_, result.Format()); 342 EXPECT_EQ(*default_closest_format_, result.Format());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 EXPECT_TRUE(result.HasValue()); 415 EXPECT_TRUE(result.HasValue());
379 EXPECT_EQ(power_line_frequency, result.PowerLineFrequency()); 416 EXPECT_EQ(power_line_frequency, result.PowerLineFrequency());
380 // The default device and settings closest to the default should be 417 // The default device and settings closest to the default should be
381 // selected. 418 // selected.
382 EXPECT_EQ(default_device_->device_id, result.device_id); 419 EXPECT_EQ(default_device_->device_id, result.device_id);
383 EXPECT_EQ(default_device_->facing_mode, result.facing_mode); 420 EXPECT_EQ(default_device_->facing_mode, result.facing_mode);
384 EXPECT_EQ(*default_closest_format_, result.Format()); 421 EXPECT_EQ(*default_closest_format_, result.Format());
385 } 422 }
386 } 423 }
387 424
425 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryNoiseReduction) {
426 constraint_factory_.Reset();
427 const bool kNoiseReductionValues[] = {true, false};
428 for (auto noise_reduction : kNoiseReductionValues) {
429 constraint_factory_.basic().googNoiseReduction.setExact(noise_reduction);
430 auto result = SelectSettings();
431 EXPECT_TRUE(result.HasValue());
432 EXPECT_EQ(noise_reduction, result.noise_reduction);
433 // The default device and settings closest to the default should be
434 // selected.
435 EXPECT_EQ(default_device_->device_id, result.device_id);
436 EXPECT_EQ(default_device_->facing_mode, result.facing_mode);
437 EXPECT_EQ(*default_closest_format_, result.Format());
438 }
439 }
440
388 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryExactHeight) { 441 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryExactHeight) {
389 constraint_factory_.Reset(); 442 constraint_factory_.Reset();
390 const int kHeight = MediaStreamVideoSource::kDefaultHeight; 443 const int kHeight = MediaStreamVideoSource::kDefaultHeight;
391 constraint_factory_.basic().height.setExact(kHeight); 444 constraint_factory_.basic().height.setExact(kHeight);
392 auto result = SelectSettings(); 445 auto result = SelectSettings();
393 EXPECT_TRUE(result.HasValue()); 446 EXPECT_TRUE(result.HasValue());
394 // All devices in |capabilities_| support the requested height. The algorithm 447 // All devices in |capabilities_| support the requested height. The algorithm
395 // should prefer the first device that supports the requested height natively, 448 // should prefer the first device that supports the requested height natively,
396 // which is the low-res device. 449 // which is the low-res device.
397 EXPECT_EQ(low_res_device_->device_id, result.device_id); 450 EXPECT_EQ(low_res_device_->device_id, result.device_id);
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 // the lest expensive way to achieve it. 1238 // the lest expensive way to achieve it.
1186 EXPECT_EQ(high_res_device_->device_id, result.device_id); 1239 EXPECT_EQ(high_res_device_->device_id, result.device_id);
1187 EXPECT_EQ(1280, result.Width()); 1240 EXPECT_EQ(1280, result.Width());
1188 EXPECT_EQ(720, result.Height()); 1241 EXPECT_EQ(720, result.Height());
1189 } 1242 }
1190 } 1243 }
1191 1244
1192 // The "Advanced" tests check selection criteria involving advanced constraint 1245 // The "Advanced" tests check selection criteria involving advanced constraint
1193 // sets. 1246 // sets.
1194 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, AdvancedExactResolution) { 1247 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, AdvancedExactResolution) {
1248 constraint_factory_.Reset();
1249 blink::WebMediaTrackConstraintSet& advanced1 =
1250 constraint_factory_.AddAdvanced();
1251 advanced1.width.setExact(4000);
1252 advanced1.height.setExact(4000);
1253 blink::WebMediaTrackConstraintSet& advanced2 =
1254 constraint_factory_.AddAdvanced();
1255 advanced2.width.setExact(3000);
1256 advanced2.height.setExact(3000);
1257 auto result = SelectSettings();
1258 // No device supports the advanced constraint sets.
1259 // Tie-breaker rule that applies is closeness to default settings.
1260 EXPECT_EQ(default_device_->device_id, result.device_id);
1261 EXPECT_EQ(*default_closest_format_, result.Format());
1262
1263 blink::WebMediaTrackConstraintSet& advanced3 =
1264 constraint_factory_.AddAdvanced();
1265 advanced3.width.setExact(1920);
1266 advanced3.height.setExact(1080);
1267 result = SelectSettings();
1268 EXPECT_TRUE(result.HasValue());
1269 // The high-res device natively supports the third advanced constraint set
1270 // and should be selected.
1271 // First tie-breaker rule that applies is support for advanced constraints
1272 // that appear first. Second tie-breaker rule is custom distance to advanced
1273 // constraint sets that appear first.
1274 EXPECT_EQ(high_res_device_->device_id, result.device_id);
1275 EXPECT_EQ(1920, result.Width());
1276 EXPECT_EQ(1080, result.Height());
1277
1278 blink::WebMediaTrackConstraintSet& advanced4 =
1279 constraint_factory_.AddAdvanced();
1280 advanced4.width.setExact(640);
1281 advanced4.height.setExact(480);
1282 result = SelectSettings();
1283 EXPECT_TRUE(result.HasValue());
1284 // First tie-breaker rule that applies is support for advanced constraints
1285 // that appear first, which leaves out configurations that only support the
1286 // fourth advanced constraint set in favor of configurations that support
1287 // the third set.
1288 // Second tie-breaker rule is custom distance to advanced constraint sets
1289 // that appear first.
1290 EXPECT_EQ(high_res_device_->device_id, result.device_id);
1291 EXPECT_EQ(1920, result.Width());
1292 EXPECT_EQ(1080, result.Height());
1293
1294 constraint_factory_.basic().width.setIdeal(800);
1295 constraint_factory_.basic().height.setIdeal(600);
1296 result = SelectSettings();
1297 EXPECT_TRUE(result.HasValue());
1298 // The ideal value is supported by the same configuration, so nothing
1299 // changes.
1300 EXPECT_EQ(high_res_device_->device_id, result.device_id);
1301 EXPECT_EQ(1920, result.Width());
1302 EXPECT_EQ(1080, result.Height());
1303
1304 constraint_factory_.basic().width.setIdeal(2000);
1305 constraint_factory_.basic().height.setIdeal(1500);
1306 result = SelectSettings();
1307 EXPECT_TRUE(result.HasValue());
1308 // The closest configuration to the ideal resolution is the high-res device
1309 // at the highest resolution.
1310 EXPECT_EQ(high_res_device_->device_id, result.device_id);
1311 EXPECT_EQ(*high_res_highest_format_, result.Format());
1312 }
1313
1314 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
1315 AdvancedResolutionAndFrameRate) {
1316 constraint_factory_.Reset();
1317 blink::WebMediaTrackConstraintSet& advanced1 =
1318 constraint_factory_.AddAdvanced();
1319 advanced1.width.setExact(1920);
1320 advanced1.height.setExact(1080);
1321 blink::WebMediaTrackConstraintSet& advanced2 =
1322 constraint_factory_.AddAdvanced();
1323 advanced2.frameRate.setExact(60.0);
1324 blink::WebMediaTrackConstraintSet& advanced3 =
1325 constraint_factory_.AddAdvanced();
1326 advanced3.width.setExact(2304);
1327 advanced3.height.setExact(1536);
1328 auto result = SelectSettings();
1329 EXPECT_TRUE(result.HasValue());
1330 // The high-res device is the only one that satisfies the first advanced
1331 // set. 2304x1536x10.0 satisfies sets 1 and 3, while 1920x1080x60.0
1332 // satisfies sets 1, and 2. The latter must be selected, regardless of
1333 // any other criteria.
1334 EXPECT_EQ(high_res_device_->device_id, result.device_id);
1335 EXPECT_EQ(1920, result.Width());
1336 EXPECT_EQ(1080, result.Height());
1337 EXPECT_EQ(60.0, result.FrameRate());
1338 }
1339
1340 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, AdvancedNoiseReduction) {
1341 constraint_factory_.Reset();
1342 blink::WebMediaTrackConstraintSet& advanced1 =
1343 constraint_factory_.AddAdvanced();
1344 advanced1.width.setExact(640);
1345 advanced1.height.setExact(480);
1346 blink::WebMediaTrackConstraintSet& advanced2 =
1347 constraint_factory_.AddAdvanced();
1348 advanced2.width.setExact(1920);
1349 advanced2.height.setExact(1080);
1350 advanced2.googNoiseReduction.setExact(false);
1351 auto result = SelectSettings();
1352 EXPECT_TRUE(result.HasValue());
1353 EXPECT_EQ(high_res_device_->device_id, result.device_id);
1354 EXPECT_EQ(1920, result.Width());
1355 EXPECT_EQ(1080, result.Height());
1356 EXPECT_TRUE(result.noise_reduction && !*result.noise_reduction);
1357 }
1358
1359 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
1360 AdvancedContradictoryNoiseReduction) {
1195 { 1361 {
1196 constraint_factory_.Reset(); 1362 constraint_factory_.Reset();
1197 blink::WebMediaTrackConstraintSet& advanced1 = 1363 blink::WebMediaTrackConstraintSet& advanced1 =
1198 constraint_factory_.AddAdvanced(); 1364 constraint_factory_.AddAdvanced();
1199 advanced1.width.setExact(4000); 1365 advanced1.width.setMin(640);
1200 advanced1.height.setExact(4000); 1366 advanced1.height.setMin(480);
1367 advanced1.googNoiseReduction.setExact(true);
1201 blink::WebMediaTrackConstraintSet& advanced2 = 1368 blink::WebMediaTrackConstraintSet& advanced2 =
1202 constraint_factory_.AddAdvanced(); 1369 constraint_factory_.AddAdvanced();
1203 advanced2.width.setExact(3000); 1370 advanced2.width.setMin(1920);
1204 advanced2.height.setExact(3000); 1371 advanced2.height.setMin(1080);
1372 advanced2.googNoiseReduction.setExact(false);
1205 auto result = SelectSettings(); 1373 auto result = SelectSettings();
1206 // No device supports the advanced constraint sets. 1374 EXPECT_TRUE(result.HasValue());
1207 // Tie-breaker rule that applies is closeness to default settings. 1375 // The second advanced set cannot be satisfied because it contradicts the
1376 // first set. The default device supports the first set and should be
1377 // selected.
1208 EXPECT_EQ(default_device_->device_id, result.device_id); 1378 EXPECT_EQ(default_device_->device_id, result.device_id);
1209 EXPECT_EQ(*default_closest_format_, result.Format()); 1379 EXPECT_LE(640, result.Width());
1380 EXPECT_LE(480, result.Height());
1381 EXPECT_TRUE(result.noise_reduction && *result.noise_reduction);
1382 }
1210 1383
1211 blink::WebMediaTrackConstraintSet& advanced3 = 1384 // Same test without noise reduction
1212 constraint_factory_.AddAdvanced();
1213 advanced3.width.setExact(1920);
1214 advanced3.height.setExact(1080);
1215 result = SelectSettings();
1216 EXPECT_TRUE(result.HasValue());
1217 // The high-res device natively supports the third advanced constraint set
1218 // and should be selected.
1219 // First tie-breaker rule that applies is support for advanced constraints
1220 // that appear first. Second tie-breaker rule is custom distance to advanced
1221 // constraint sets that appear first.
1222 EXPECT_EQ(high_res_device_->device_id, result.device_id);
1223 EXPECT_EQ(1920, result.Width());
1224 EXPECT_EQ(1080, result.Height());
1225
1226 blink::WebMediaTrackConstraintSet& advanced4 =
1227 constraint_factory_.AddAdvanced();
1228 advanced4.width.setExact(640);
1229 advanced4.height.setExact(480);
1230 result = SelectSettings();
1231 EXPECT_TRUE(result.HasValue());
1232 // First tie-breaker rule that applies is support for advanced constraints
1233 // that appear first, which leaves out configurations that only support the
1234 // fourth advanced constraint set in favor of configurations that support
1235 // the third set.
1236 // Second tie-breaker rule is custom distance to advanced constraint sets
1237 // that appear first.
1238 EXPECT_EQ(high_res_device_->device_id, result.device_id);
1239 EXPECT_EQ(1920, result.Width());
1240 EXPECT_EQ(1080, result.Height());
1241
1242 constraint_factory_.basic().width.setIdeal(800);
1243 constraint_factory_.basic().height.setIdeal(600);
1244 result = SelectSettings();
1245 EXPECT_TRUE(result.HasValue());
1246 // The ideal value is supported by the same configuration, so nothing
1247 // changes.
1248 EXPECT_EQ(high_res_device_->device_id, result.device_id);
1249 EXPECT_EQ(1920, result.Width());
1250 EXPECT_EQ(1080, result.Height());
1251
1252 constraint_factory_.basic().width.setIdeal(2000);
1253 constraint_factory_.basic().height.setIdeal(1500);
1254 result = SelectSettings();
1255 EXPECT_TRUE(result.HasValue());
1256 // The closest configuration to the ideal resolution is the high-res device
1257 // at the highest resolution.
1258 EXPECT_EQ(high_res_device_->device_id, result.device_id);
1259 EXPECT_EQ(*high_res_highest_format_, result.Format());
1260 }
1261 }
1262
1263 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
1264 AdvancedResolutionAndFrameRate) {
1265 { 1385 {
1266 constraint_factory_.Reset(); 1386 constraint_factory_.Reset();
1267 blink::WebMediaTrackConstraintSet& advanced1 = 1387 blink::WebMediaTrackConstraintSet& advanced1 =
1268 constraint_factory_.AddAdvanced(); 1388 constraint_factory_.AddAdvanced();
1269 advanced1.width.setExact(1920); 1389 advanced1.width.setMin(640);
1270 advanced1.height.setExact(1080); 1390 advanced1.height.setMin(480);
1271 blink::WebMediaTrackConstraintSet& advanced2 = 1391 blink::WebMediaTrackConstraintSet& advanced2 =
1272 constraint_factory_.AddAdvanced(); 1392 constraint_factory_.AddAdvanced();
1273 advanced2.frameRate.setExact(60.0); 1393 advanced2.width.setMin(1920);
1274 blink::WebMediaTrackConstraintSet& advanced3 = 1394 advanced2.height.setMin(1080);
1275 constraint_factory_.AddAdvanced();
1276 advanced3.width.setExact(2304);
1277 advanced3.height.setExact(1536);
1278 auto result = SelectSettings(); 1395 auto result = SelectSettings();
1279 EXPECT_TRUE(result.HasValue()); 1396 EXPECT_TRUE(result.HasValue());
1280 // The high-res device is the only one that satisfies the first advanced 1397 // Only the high-res device can satisfy the second advanced set.
1281 // set. 2304x1536x10.0 satisfies sets 1 and 3, while 1920x1080x60.0
1282 // satisfies sets 1, and 2. The latter must be selected, regardless of
1283 // any other criteria.
1284 EXPECT_EQ(high_res_device_->device_id, result.device_id); 1398 EXPECT_EQ(high_res_device_->device_id, result.device_id);
1285 EXPECT_EQ(1920, result.Width()); 1399 EXPECT_LE(1920, result.Width());
1286 EXPECT_EQ(1080, result.Height()); 1400 EXPECT_LE(1080, result.Height());
1287 EXPECT_EQ(60.0, result.FrameRate()); 1401 // Should select default noise reduction setting.
1402 EXPECT_TRUE(!result.noise_reduction);
1288 } 1403 }
1289 } 1404 }
1290 1405
1291 // The "NoDevices" tests verify that the algorithm returns the expected result 1406 // The "NoDevices" tests verify that the algorithm returns the expected result
1292 // when there are no candidates to choose from. 1407 // when there are no candidates to choose from.
1293 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, NoDevicesNoConstraints) { 1408 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, NoDevicesNoConstraints) {
1294 constraint_factory_.Reset(); 1409 constraint_factory_.Reset();
1295 VideoDeviceCaptureCapabilities capabilities; 1410 VideoDeviceCaptureCapabilities capabilities;
1296 auto result = SelectVideoDeviceCaptureSourceSettings( 1411 auto result = SelectVideoDeviceCaptureSourceSettings(
1297 capabilities, constraint_factory_.CreateWebMediaConstraints()); 1412 capabilities, constraint_factory_.CreateWebMediaConstraints());
1298 EXPECT_FALSE(result.HasValue()); 1413 EXPECT_FALSE(result.HasValue());
1299 EXPECT_TRUE(std::string(result.failed_constraint_name).empty()); 1414 EXPECT_TRUE(std::string(result.failed_constraint_name).empty());
1300 } 1415 }
1301 1416
1302 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, NoDevicesWithConstraints) { 1417 TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, NoDevicesWithConstraints) {
1303 constraint_factory_.Reset(); 1418 constraint_factory_.Reset();
1304 constraint_factory_.basic().height.setExact(100); 1419 constraint_factory_.basic().height.setExact(100);
1305 VideoDeviceCaptureCapabilities capabilities; 1420 VideoDeviceCaptureCapabilities capabilities;
1306 auto result = SelectVideoDeviceCaptureSourceSettings( 1421 auto result = SelectVideoDeviceCaptureSourceSettings(
1307 capabilities, constraint_factory_.CreateWebMediaConstraints()); 1422 capabilities, constraint_factory_.CreateWebMediaConstraints());
1308 EXPECT_FALSE(result.HasValue()); 1423 EXPECT_FALSE(result.HasValue());
1309 EXPECT_TRUE(std::string(result.failed_constraint_name).empty()); 1424 EXPECT_TRUE(std::string(result.failed_constraint_name).empty());
1310 } 1425 }
1311 1426
1312 } // namespace content 1427 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_constraints_util_video_device.cc ('k') | content/renderer/media/user_media_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698