| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library interactive_test; | 5 library interactive_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import '../../pkg/unittest/lib/unittest.dart'; | 9 import '../../pkg/unittest/lib/unittest.dart'; |
| 10 import '../../pkg/unittest/lib/html_individual_config.dart'; | 10 import '../../pkg/unittest/lib/html_individual_config.dart'; |
| 11 import 'utils.dart'; | 11 import 'utils.dart'; |
| 12 | 12 |
| 13 | 13 |
| 14 main() { | 14 main() { |
| 15 useHtmlIndividualConfiguration(); | 15 useHtmlIndividualConfiguration(); |
| 16 | 16 |
| 17 group('Geolocation', () { | 17 group('Geolocation', () { |
| 18 futureTest('getCurrentPosition', () { | 18 test('getCurrentPosition', () { |
| 19 return window.navigator.geolocation.getCurrentPosition().then( | 19 return window.navigator.geolocation.getCurrentPosition().then( |
| 20 (position) { | 20 (position) { |
| 21 expect(position.coords.latitude, isNotNull); | 21 expect(position.coords.latitude, isNotNull); |
| 22 expect(position.coords.longitude, isNotNull); | 22 expect(position.coords.longitude, isNotNull); |
| 23 expect(position.coords.accuracy, isNotNull); | 23 expect(position.coords.accuracy, isNotNull); |
| 24 }); | 24 }); |
| 25 }); | 25 }); |
| 26 | 26 |
| 27 futureTest('watchPosition', () { | 27 test('watchPosition', () { |
| 28 return window.navigator.geolocation.watchPosition().first.then( | 28 return window.navigator.geolocation.watchPosition().first.then( |
| 29 (position) { | 29 (position) { |
| 30 expect(position.coords.latitude, isNotNull); | 30 expect(position.coords.latitude, isNotNull); |
| 31 expect(position.coords.longitude, isNotNull); | 31 expect(position.coords.longitude, isNotNull); |
| 32 expect(position.coords.accuracy, isNotNull); | 32 expect(position.coords.accuracy, isNotNull); |
| 33 }); | 33 }); |
| 34 }); | 34 }); |
| 35 }); | 35 }); |
| 36 | 36 |
| 37 group('MediaStream', () { | 37 group('MediaStream', () { |
| 38 if (MediaStream.supported) { | 38 if (MediaStream.supported) { |
| 39 futureTest('getUserMedia', () { | 39 test('getUserMedia', () { |
| 40 return window.navigator.getUserMedia(video: true).then((stream) { | 40 return window.navigator.getUserMedia(video: true).then((stream) { |
| 41 expect(stream, isNotNull); | 41 expect(stream, isNotNull); |
| 42 | 42 |
| 43 var url = Url.createObjectUrl(stream); | 43 var url = Url.createObjectUrl(stream); |
| 44 expect(url, isNotNull); | 44 expect(url, isNotNull); |
| 45 | 45 |
| 46 var video = new VideoElement() | 46 var video = new VideoElement() |
| 47 ..autoplay = true; | 47 ..autoplay = true; |
| 48 | 48 |
| 49 var completer = new Completer(); | 49 var completer = new Completer(); |
| 50 video.onError.listen((e) { | 50 video.onError.listen((e) { |
| 51 completer.completeError(e); | 51 completer.completeError(e); |
| 52 }); | 52 }); |
| 53 video.onPlaying.first.then((e) { | 53 video.onPlaying.first.then((e) { |
| 54 completer.complete(video); | 54 completer.complete(video); |
| 55 }); | 55 }); |
| 56 | 56 |
| 57 document.body.append(video); | 57 document.body.append(video); |
| 58 video.src = url; | 58 video.src = url; |
| 59 | 59 |
| 60 return completer.future; | 60 return completer.future; |
| 61 }); | 61 }); |
| 62 }); | 62 }); |
| 63 |
| 64 test('getUserMediaComplexConstructor', () { |
| 65 return window.navigator.getUserMedia( |
| 66 video: {'mandatory': |
| 67 { 'minAspectRatio': 1.333, 'maxAspectRatio': 1.334 }, |
| 68 'optional': |
| 69 [{ 'minFrameRate': 60 }, |
| 70 { 'maxWidth': 640 }] |
| 71 }).then((stream) { |
| 72 expect(stream, isNotNull); |
| 73 |
| 74 var url = Url.createObjectUrl(stream); |
| 75 expect(url, isNotNull); |
| 76 |
| 77 var video = new VideoElement() |
| 78 ..autoplay = true; |
| 79 |
| 80 var completer = new Completer(); |
| 81 video.onError.listen((e) { |
| 82 completer.completeError(e); |
| 83 }); |
| 84 video.onPlaying.first.then((e) { |
| 85 completer.complete(video); |
| 86 }); |
| 87 |
| 88 document.body.append(video); |
| 89 video.src = url; |
| 90 |
| 91 return completer.future; |
| 92 }); |
| 93 }); |
| 63 } | 94 } |
| 64 }); | 95 }); |
| 65 } | 96 } |
| OLD | NEW |