OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 touchTests; | 5 library touchTests; |
6 | 6 |
7 import 'dart:html'; // TODO(rnystrom): Only needed to tell architecture.py | 7 import 'dart:html'; // TODO(rnystrom): Only needed to tell architecture.py |
8 // that this is a web test. Come up with cleaner solution. | 8 // that this is a web test. Come up with cleaner solution. |
9 import 'package:unittest/html_config.dart'; | 9 import 'package:unittest/html_config.dart'; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
11 import '../../../swarm_ui_lib/touch/touch.dart'; | 11 import '../../../swarm_ui_lib/touch/touch.dart'; |
12 | 12 |
13 main() { | 13 main() { |
14 useHtmlConfiguration(); | 14 useHtmlConfiguration(); |
15 test('Solver', () { | 15 test('Solver', () { |
16 expect(Solver.solve((x) => x * x, 81, 10), closeTo(9, 0.1)); | 16 expect(Solver.solve((x) => x * x, 81, 10), closeTo(9, 0.1)); |
17 expect(Solver.solve((x) => x * x, 0, 10), closeTo(0, 0.1)); | 17 expect(Solver.solve((x) => x * x, 0, 10), closeTo(0, 0.1)); |
18 expect(Solver.solve((x) => x * x, 1.5625, 10), closeTo(1.25, 0.1)); | 18 expect(Solver.solve((x) => x * x, 1.5625, 10), closeTo(1.25, 0.1)); |
(...skipping 13 matching lines...) Expand all Loading... |
32 final momentum = new TimeoutMomentum(null); | 32 final momentum = new TimeoutMomentum(null); |
33 }); | 33 }); |
34 }); | 34 }); |
35 } | 35 } |
36 | 36 |
37 class TestMomentumDelegate { | 37 class TestMomentumDelegate { |
38 Function onDecelerateCallback; | 38 Function onDecelerateCallback; |
39 Function onDecelerationEndCallback; | 39 Function onDecelerationEndCallback; |
40 | 40 |
41 void onDecelerate(num x, num y, | 41 void onDecelerate(num x, num y, |
42 [num duration = 0, String timingFunction = null]) { | 42 [num duration = 0, String timingFunction = null]) { |
43 onDecelerateCallback(x, y, duration, timingFunction); | 43 onDecelerateCallback(x, y, duration, timingFunction); |
44 } | 44 } |
45 | 45 |
46 /** | 46 /** |
47 * Callback for end of deceleration. | 47 * Callback for end of deceleration. |
48 */ | 48 */ |
49 void onDecelerationEnd() { | 49 void onDecelerationEnd() { |
50 onDecelerationEndCallback(); | 50 onDecelerationEndCallback(); |
51 } | 51 } |
52 } | 52 } |
OLD | NEW |