Tighten failure and success of test.
TBR=sra@google.com
Change-Id: Id56baa1f1079ad3433d2402f0eb5749fdcf08c06
Reviewed-on: https://dart-review.googlesource.com/56289
Reviewed-by: Terry Lucas <terry@google.com>
Commit-Queue: Terry Lucas <terry@google.com>
diff --git a/tests/lib_2/html/interactive_media_test.dart b/tests/lib_2/html/interactive_media_test.dart
index 25d43d4..d7060ac 100644
--- a/tests/lib_2/html/interactive_media_test.dart
+++ b/tests/lib_2/html/interactive_media_test.dart
@@ -18,71 +18,86 @@
if (MediaStream.supported) {
test('getUserMedia audio', () async {
- var mediaStream = await window.navigator.getUserMedia(audio: true);
- expect(mediaStream, isNotNull);
- expect(mediaStream is MediaStream, true);
- var devices = window.navigator.mediaDevices;
- var enumDevices = await devices.enumerateDevices();
- expect(enumDevices.length > 1, true);
- for (var device in enumDevices) {
- var goodDevLabel = device.label.endsWith('Built-in Output') ||
- device.label.endsWith('Built-in Microphone');
- expect(goodDevLabel, true);
+ try {
+ var mediaStream = await window.navigator.getUserMedia(audio: true);
+ expect(mediaStream, isNotNull);
+ expect(mediaStream is MediaStream, true);
+ var devices = window.navigator.mediaDevices;
+ var enumDevices = await devices.enumerateDevices();
+ expect(enumDevices.length > 1, true);
+ for (var device in enumDevices) {
+ var goodDevLabel = device.label.endsWith('Built-in Output') ||
+ device.label.endsWith('Built-in Microphone');
+ expect(goodDevLabel, true);
+ }
+ } catch (e) {
+ // Could fail if bot machine doesn't support audio or video.
+ expect(e.name, DomException.NOT_FOUND);
}
});
test('getUserMedia', () {
- return window.navigator.getUserMedia(video: true).then((stream) {
- expect(stream, isNotNull);
+ try {
+ return window.navigator.getUserMedia(video: true).then((stream) {
+ expect(stream, isNotNull);
- var url = Url.createObjectUrlFromStream(stream);
- expect(url, isNotNull);
+ var url = Url.createObjectUrlFromStream(stream);
+ expect(url, isNotNull);
- var video = new VideoElement()..autoplay = true;
+ var video = new VideoElement()..autoplay = true;
- var completer = new Completer();
- video.onError.listen((e) {
- completer.completeError(e);
+ var completer = new Completer();
+ video.onError.listen((e) {
+ completer.completeError(e);
+ });
+ video.onPlaying.first.then((e) {
+ completer.complete(video);
+ });
+
+ document.body.append(video);
+ video.src = url;
+
+ return completer.future;
});
- video.onPlaying.first.then((e) {
- completer.complete(video);
- });
-
- document.body.append(video);
- video.src = url;
-
- return completer.future;
- });
+ } catch (e) {
+ // Could fail if bot machine doesn't support audio or video.
+ expect(e.name, DomException.NOT_FOUND);
+ }
});
test('getUserMediaComplexConstructor', () {
- return window.navigator.getUserMedia(video: {
- 'mandatory': {'minAspectRatio': 1.333, 'maxAspectRatio': 1.334},
- 'optional': [
- {'minFrameRate': 60},
- {'maxWidth': 640}
- ]
- }).then((stream) {
- expect(stream, isNotNull);
+ try {
+ return window.navigator.getUserMedia(video: {
+ 'mandatory': {'minAspectRatio': 1.333, 'maxAspectRatio': 1.334},
+ 'optional': [
+ {'minFrameRate': 60},
+ {'maxWidth': 640}
+ ]
+ }).then((stream) {
+ expect(stream, isNotNull);
- var url = Url.createObjectUrlFromStream(stream);
- expect(url, isNotNull);
+ var url = Url.createObjectUrlFromStream(stream);
+ expect(url, isNotNull);
- var video = new VideoElement()..autoplay = true;
+ var video = new VideoElement()..autoplay = true;
- var completer = new Completer();
- video.onError.listen((e) {
- completer.completeError(e);
+ var completer = new Completer();
+ video.onError.listen((e) {
+ completer.completeError(e);
+ });
+ video.onPlaying.first.then((e) {
+ completer.complete(video);
+ });
+
+ document.body.append(video);
+ video.src = url;
+
+ return completer.future;
});
- video.onPlaying.first.then((e) {
- completer.complete(video);
- });
-
- document.body.append(video);
- video.src = url;
-
- return completer.future;
- });
+ } catch (e) {
+ // Could fail if bot machine doesn't support audio or video.
+ expect(e.name, DomException.NOT_FOUND);
+ }
});
}
}
diff --git a/tests/lib_2/lib_2_dart2js.status b/tests/lib_2/lib_2_dart2js.status
index e49ac50..72d9070 100644
--- a/tests/lib_2/lib_2_dart2js.status
+++ b/tests/lib_2/lib_2_dart2js.status
@@ -468,6 +468,9 @@
[ $compiler == dart2js && $system == linux ]
html/interactive_geolocation_test: Skip # Requires allowing geo location.
+[ $compiler == dart2js && $system != macos && ($runtime != chrome || $runtime != safari) ]
+html/interactive_media_test: RuntimeError # # See NOTE in test on how to run.
+
[ $compiler == dart2js && $system == windows ]
html/xhr_test: RuntimeError
@@ -790,9 +793,6 @@
convert/streamed_conversion_json_utf8_encode_test: SkipSlow # Times out. Issue 22050
convert/streamed_conversion_utf8_decode_test: SkipSlow # Times out. Issue 22050
-[ $compiler == dart2js && ($runtime != chrome || $system != macos) ]
-html/interactive_media_test: RuntimeError # # See NOTE in test on how to run.
-
[ $compiler == dart2js && ($runtime == ff || $runtime == safari || $ie) ]
html/custom/attribute_changed_callback_test/unsupported_on_polyfill: Fail # Polyfill does not support
html/custom/entered_left_view_test/viewless_document: Fail # Polyfill does not handle this