Index: third_party/WebKit/LayoutTests/media/audio_output_devices/audio_output_devices-setsinkid.html |
diff --git a/third_party/WebKit/LayoutTests/media/audio_output_devices/audio_output_devices-setsinkid.html b/third_party/WebKit/LayoutTests/media/audio_output_devices/audio_output_devices-setsinkid.html |
index 204ff8f7ec920364a0030471f7b6bf36d6e571df..93ebf1bb97771a0fdb49d69d7f92a6fb0bec0555 100644 |
--- a/third_party/WebKit/LayoutTests/media/audio_output_devices/audio_output_devices-setsinkid.html |
+++ b/third_party/WebKit/LayoutTests/media/audio_output_devices/audio_output_devices-setsinkid.html |
@@ -6,32 +6,72 @@ |
<script src="../../resources/testharnessreport.js"></script> |
</head> |
<body> |
- <audio id="testAudio"></audio> |
<script> |
- // Tests that the setSinkId() Promise rejects with a NotSupportedError, |
- // because the functionality has not been implemented yet. |
- promise_test(function() { |
- var audio = document.getElementById('testAudio'); |
+ // TODO(guidou): Add more tests with nonempty src once a MockWebMediaPlayer |
+ // is available int the test runner. See crbug.com/546566. |
+ |
+ // Tests that the API is available. |
+ test(function() { |
+ var audio = document.createElement('audio'); |
assert_not_equals(audio, null); |
- |
assert_idl_attribute(audio, 'setSinkId'); |
assert_equals(typeof audio.setSinkId, 'function'); |
assert_idl_attribute(audio, 'sinkId'); |
assert_equals(audio.sinkId, ''); |
+ }, 'Basic API test'); |
+ |
+ // Tests that setting the sink to the default device succeeds. |
+ promise_test(function() { |
+ var audio = document.createElement('audio'); |
+ return audio.setSinkId('') |
+ }, 'setSinkId("")'); |
+ |
+ // Tests that setting the sink to a valid device succeeds. |
+ // Note: 'valid' is the name of a valid device in the test runner. |
+ promise_test(function() { |
+ var audio = document.createElement('audio'); |
+ var p = audio.setSinkId('valid') |
+ .then(function() { |
+ assert_equals(audio.sinkId, 'valid'); |
+ }); |
+ assert_equals(audio.sinkId, ''); // sinkId not updated yet |
+ return p; |
+ }, 'setSinkId("valid")'); |
+ |
+ // Test that changing the src on an element and calling setSinkId() works |
+ promise_test(function() { |
+ var audio = document.createElement('audio'); |
+ audio.src = '../content/test.oga'; |
+ return audio.setSinkId(''); |
+ |
+ }, 'change src, then setSinkId("")'); |
+ |
+ // Tests that setting the sink to an unauthorized device fails. |
+ // Note: 'unauthorized' is the name of an unauthorized device in the test runner. |
+ promise_test(function() { |
+ var audio = document.createElement('audio'); |
+ return promise_rejects(this, 'SecurityError', audio.setSinkId('unauthorized')); |
+ }, 'setSinkId("unauthorized")' ); |
+ |
+ // Test that setting the sink to a nonexistent device fails |
+ promise_test(function() { |
+ var audio = document.createElement('audio'); |
+ return promise_rejects(this, 'NotFoundError', audio.setSinkId('nonexistent')); |
+ }, 'setSinkId("nonexistent")'); |
+ |
+ // Tests that changing the sink twice succeeds |
+ promise_test(function() { |
+ var audio = document.createElement('audio'); |
+ return audio.setSinkId('valid') |
+ .then(function() { |
+ assert_equals(audio.sinkId, 'valid'); |
+ return audio.setSinkId('') |
+ .then(function() { |
+ assert_equals(audio.sinkId, ''); |
+ }); |
+ }); |
+ }, 'setSinkId("valid") followed by setSinkId("").'); |
- return audio.setSinkId('').then(function() { |
- assert_equals(audio.sinkId, ''); |
- return audio.setSinkId('xxx'); |
- }, function(error) { |
- assert_unreached('setSinkId() should have succeeded!'); |
- }). then(function() { |
- assert_unreached('setSinkId() should have failed!'); |
- }, function(error) { |
- assert_equals(audio.sinkId, ''); |
- return Promise.resolve(); |
- }) |
- }, 'setSinkId() test'); |
</script> |
</body> |
</html> |
- |