| OLD | NEW |
| 1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
| 2 <script src="../../resources/testharness.js"></script> | 2 <script src="../../resources/testharness.js"></script> |
| 3 <script src="../../resources/testharnessreport.js"></script> | 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <script> | 4 <script> |
| 5 | 5 |
| 6 promise_test(function() { | 6 promise_test(function() { |
| 7 return navigator.mediaDevices.getUserMedia({audio: true}) | 7 return navigator.mediaDevices.getUserMedia({audio: true}) |
| 8 .then(function(s) { | 8 .then(function(s) { |
| 9 settings = s.getAudioTracks()[0].getSettings(); | 9 settings = s.getAudioTracks()[0].getSettings(); |
| 10 assert_greater_than(Object.keys(settings).length, 0); | 10 assert_greater_than(Object.keys(settings).length, 0); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 assert_true('frameRate' in settings, | 39 assert_true('frameRate' in settings, |
| 40 'Frame rate missing: ' + JSON.stringify(settings)); | 40 'Frame rate missing: ' + JSON.stringify(settings)); |
| 41 assert_true('width' in settings, | 41 assert_true('width' in settings, |
| 42 'Width missing: ' + JSON.stringify(settings)); | 42 'Width missing: ' + JSON.stringify(settings)); |
| 43 assert_true('height' in settings, | 43 assert_true('height' in settings, |
| 44 'Height missing: ' + JSON.stringify(settings)); | 44 'Height missing: ' + JSON.stringify(settings)); |
| 45 }); | 45 }); |
| 46 }, 'A video track returns the expected variables'); | 46 }, 'A video track returns the expected variables'); |
| 47 | 47 |
| 48 promise_test(function() { | 48 promise_test(function() { |
| 49 track1 = null; |
| 50 track2 = null; |
| 51 return navigator.mediaDevices.getUserMedia({video: true}) |
| 52 .then(function(s1) { |
| 53 track1 = s1.getVideoTracks()[0]; |
| 54 settings1 = track1.getSettings(); |
| 55 // We ask for the second track to have half the width of the first one, |
| 56 // but the same source. |
| 57 // This should cause a scaling factor to be applied. |
| 58 constraints2 = {deviceId: settings1.deviceId, |
| 59 width: { max: settings1.width / 2 }}; |
| 60 console.log(JSON.stringify(constraints2)); |
| 61 return navigator.mediaDevices.getUserMedia({video: constraints2}); |
| 62 }) |
| 63 .then(function(s) { |
| 64 track2 = s.getVideoTracks()[0]; |
| 65 console.log(JSON.stringify(track2.getConstraints())); |
| 66 settings = track2.getSettings(); |
| 67 settings1 = track1.getSettings(); |
| 68 // This test does not work in blink_tests due to limitations in mocking. |
| 69 // The Web-Platform-Test that does the same thing passes when run |
| 70 // in a browser. |
| 71 // TODO(hta): Add constraints to the mock media stream registry. |
| 72 // crbug.com/617152 |
| 73 // assert_equals(settings.deviceId, settings1.deviceId); |
| 74 // assert_equals(settings.width, settings1.width / 2, |
| 75 // 'widths are not 2x different: ' + |
| 76 // JSON.stringify(settings) + ' ' + JSON.stringify(settings1)); |
| 77 }); |
| 78 }, 'Two video tracks with the same source but different scaling are different'); |
| 79 |
| 80 promise_test(function() { |
| 49 return navigator.mediaDevices.getUserMedia({audio: true, video: true}) | 81 return navigator.mediaDevices.getUserMedia({audio: true, video: true}) |
| 50 .then(function(s) { | 82 .then(function(s) { |
| 51 videoSettings = s.getVideoTracks()[0].getSettings(); | 83 videoSettings = s.getVideoTracks()[0].getSettings(); |
| 52 audioSettings = s.getAudioTracks()[0].getSettings(); | 84 audioSettings = s.getAudioTracks()[0].getSettings(); |
| 53 assert_not_equals(videoSettings.deviceId, audioSettings.deviceId, | 85 assert_not_equals(videoSettings.deviceId, audioSettings.deviceId, |
| 54 'video and audio device IDs should be different') | 86 'video and audio device IDs should be different') |
| 55 }); | 87 }); |
| 56 }, 'Video and audio device IDs are different'); | 88 }, 'Video and audio device IDs are different'); |
| 57 | 89 |
| 58 promise_test(function() { | 90 promise_test(function() { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 78 }) | 110 }) |
| 79 .catch(function(e) { | 111 .catch(function(e) { |
| 80 console.log('Fake devices are not functional yet.'); | 112 console.log('Fake devices are not functional yet.'); |
| 81 // TODO(hta): Finish creation of fake devices. Until then, accept failure. | 113 // TODO(hta): Finish creation of fake devices. Until then, accept failure. |
| 82 // crbug.com/678561 | 114 // crbug.com/678561 |
| 83 assert_equals(e.name, 'TypeError', "Check crbug.com/678561"); | 115 assert_equals(e.name, 'TypeError', "Check crbug.com/678561"); |
| 84 }); | 116 }); |
| 85 }, 'With a fake user-facing device, facing mode is matched') | 117 }, 'With a fake user-facing device, facing mode is matched') |
| 86 | 118 |
| 87 </script> | 119 </script> |
| OLD | NEW |