OLD | NEW |
(Empty) | |
| 1 library GeolocationTest; |
| 2 |
| 3 import 'package:expect/expect.dart'; |
| 4 import 'package:unittest/html_config.dart'; |
| 5 import 'package:unittest/unittest.dart'; |
| 6 import 'dart:async'; |
| 7 import 'dart:html'; |
| 8 |
| 9 main() { |
| 10 useHtmlConfiguration(true); |
| 11 |
| 12 errorCallback(error) => |
| 13 Expect.fail('${error.error.code}: ${error.error.message}'); |
| 14 |
| 15 // TODO(14150): This delay should not be necessary. |
| 16 setUp(() => new Future.delayed(Duration.ZERO)); |
| 17 |
| 18 test('geolocation.getCurrentPosition', () { |
| 19 final geolocation = window.navigator.geolocation; |
| 20 |
| 21 geolocation.getCurrentPosition().then(expectAsync((posA) { |
| 22 Timer.run(expectAsync(() { |
| 23 geolocation.getCurrentPosition().then(expectAsync((posB) { |
| 24 Expect.equals(posA.coords.longitude, posB.coords.longitude); |
| 25 })).catchError(errorCallback); |
| 26 })); |
| 27 })).catchError(errorCallback); |
| 28 }); |
| 29 |
| 30 test('geolocation.watchPosition', () { |
| 31 final geolocation = window.navigator.geolocation; |
| 32 |
| 33 var posA; |
| 34 return geolocation.getCurrentPosition().then((position) { |
| 35 posA = position; |
| 36 // TODO(14150): This delay should not be necessary. |
| 37 return new Future.delayed(Duration.ZERO); |
| 38 }).then((_) { |
| 39 return geolocation.watchPosition().first; |
| 40 }).then((posB) { |
| 41 Expect.equals(posA.coords.longitude, posB.coords.longitude); |
| 42 }); |
| 43 }); |
| 44 } |
OLD | NEW |