| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library interactive_test; |
| 6 |
| 7 import 'dart:async'; |
| 8 import 'dart:html'; |
| 9 import '../../pkg/unittest/lib/unittest.dart'; |
| 10 import '../../pkg/unittest/lib/html_individual_config.dart'; |
| 11 import 'utils.dart'; |
| 12 |
| 13 |
| 14 main() { |
| 15 useHtmlIndividualConfiguration(); |
| 16 |
| 17 group('Geolocation', () { |
| 18 futureTest('getCurrentPosition', () { |
| 19 return window.navigator.geolocation.getCurrentPosition().then( |
| 20 (position) { |
| 21 expect(position.coords.latitude, isNotNull); |
| 22 expect(position.coords.longitude, isNotNull); |
| 23 expect(position.coords.accuracy, isNotNull); |
| 24 }); |
| 25 }); |
| 26 |
| 27 futureTest('watchPosition', () { |
| 28 return window.navigator.geolocation.watchPosition().first.then( |
| 29 (position) { |
| 30 expect(position.coords.latitude, isNotNull); |
| 31 expect(position.coords.longitude, isNotNull); |
| 32 expect(position.coords.accuracy, isNotNull); |
| 33 }); |
| 34 }); |
| 35 }); |
| 36 |
| 37 group('MediaStream', () { |
| 38 if (MediaStream.supported) { |
| 39 futureTest('getUserMedia', () { |
| 40 return window.navigator.getUserMedia(video: true).then((stream) { |
| 41 expect(stream, isNotNull); |
| 42 |
| 43 var url = Url.createObjectUrl(stream); |
| 44 expect(url, isNotNull); |
| 45 |
| 46 var video = new VideoElement() |
| 47 ..autoplay = true; |
| 48 |
| 49 var completer = new Completer(); |
| 50 video.onError.listen((e) { |
| 51 completer.completeError(e); |
| 52 }); |
| 53 video.onPlaying.first.then((e) { |
| 54 completer.complete(video); |
| 55 }); |
| 56 |
| 57 document.body.append(video); |
| 58 video.src = url; |
| 59 |
| 60 return completer.future; |
| 61 }); |
| 62 }); |
| 63 } |
| 64 }); |
| 65 } |
| OLD | NEW |