| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 element_animate_test; | 5 library element_animate_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'package:unittest/html_individual_config.dart'; | 9 import 'package:unittest/html_individual_config.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 11 | 11 |
| 12 main() { | 12 main() { |
| 13 useHtmlIndividualConfiguration(); | 13 useHtmlIndividualConfiguration(); |
| 14 | 14 |
| 15 group('animate_supported', () { | 15 group('animate_supported', () { |
| 16 test('supported', () { | 16 test('supported', () { |
| 17 expect(Notification.supported, true); | 17 expect(Notification.supported, true); |
| 18 }); | 18 }); |
| 19 }); |
| 19 | 20 |
| 21 group('simple_timing', () { |
| 20 test('simple timing', () { | 22 test('simple timing', () { |
| 21 var body = document.body; | 23 var body = document.body; |
| 22 var opacity = num.parse(body.getComputedStyle().opacity); | 24 var opacity = num.parse(body.getComputedStyle().opacity); |
| 23 body.animate([{"opacity": 100}, {"opacity": 0}], 100); | 25 body.animate([{"opacity": 100}, {"opacity": 0}], 100); |
| 24 var newOpacity = num.parse(body.getComputedStyle().opacity); | 26 var newOpacity = num.parse(body.getComputedStyle().opacity); |
| 25 expect(newOpacity < opacity, isTrue); | 27 expect(newOpacity < opacity, isTrue); |
| 26 }); | 28 }); |
| 29 }); |
| 27 | 30 |
| 31 group('timing_dict', () { |
| 28 test('timing dict', () { | 32 test('timing dict', () { |
| 29 var body = document.body; | 33 var body = document.body; |
| 30 // Animate different characteristics so the tests can run concurrently. | 34 // Animate different characteristics so the tests can run concurrently. |
| 31 var fontSize = body.getComputedStyle().fontSize; | 35 var fontSize = body.getComputedStyle().fontSize; |
| 32 var player = body.animate( | 36 var player = body.animate( |
| 33 [{"font-size": "500px"}, {"font-size": fontSize}], | 37 [{"font-size": "500px"}, {"font-size": fontSize}], {"duration": 100}); |
| 34 {"duration": 100}); | |
| 35 var newFontSize = body.getComputedStyle().fontSize; | 38 var newFontSize = body.getComputedStyle().fontSize; |
| 36 // Don't bother to parse to numbers, as long as it's changed that | 39 // Don't bother to parse to numbers, as long as it's changed that |
| 37 // indicates something is happening. | 40 // indicates something is happening. |
| 38 expect(newFontSize == fontSize, isFalse); | 41 expect(newFontSize == fontSize, isFalse); |
| 39 player.on['finish'].listen(expectAsync((_) => 'done')); | 42 player.on['finish'].listen(expectAsync((_) => 'done')); |
| 40 }); | 43 }); |
| 44 }); |
| 41 | 45 |
| 46 group('omit_timing', () { |
| 42 test('omit timing', () { | 47 test('omit timing', () { |
| 43 var body = document.body; | 48 var body = document.body; |
| 44 var player = body.animate([ | 49 var player = body.animate([ |
| 45 {"transform": "translate(100px, -100%)"}, | 50 {"transform": "translate(100px, -100%)"}, |
| 46 {"transform": "translate(400px, 500px)"} | 51 {"transform": "translate(400px, 500px)"} |
| 47 ]); | 52 ]); |
| 48 player.on['finish'].listen(expectAsync((_) => 'done')); | 53 player.on['finish'].listen(expectAsync((_) => 'done')); |
| 49 }); | 54 }); |
| 50 }); | 55 }); |
| 51 } | 56 } |
| OLD | NEW |