Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: third_party/pkg/angular/test/animate/css_animate_spec.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 library css_animate_spec;
2
3 import 'dart:async';
4
5 import '../_specs.dart';
6
7 main() {
8 describe('CssAnimate', () {
9 TestBed _;
10 Animate animate;
11 MockAnimationLoop runner;
12
13 beforeEach(inject((TestBed tb, Expando expand) {
14 _ = tb;
15 runner = new MockAnimationLoop();
16 animate = new CssAnimate(runner,
17 new CssAnimationMap(), new AnimationOptimizer(expand));
18 }));
19
20 it('should add a css class to an element node', async(() {
21 _.compile('<div></div>');
22 expect(_.rootElement).not.toHaveClass('foo');
23
24 animate.addClass(_.rootElement, 'foo');
25 runner.frame();
26
27 expect(_.rootElement).toHaveClass('foo');
28 }));
29
30 it('should remove a css class from an element node', async(() {
31 _.compile('<div class="baz foo bar"></div>');
32 expect(_.rootElement).toHaveClass('foo');
33
34 animate.removeClass(_.rootElement, 'foo');
35 runner.frame();
36 expect(_.rootElement).not.toHaveClass('foo');
37 }));
38
39 it('should insert nodes', async(() {
40 _.compile('<div></div>');
41 expect(_.rootElement.children.length).toBe(0);
42
43 animate.insert([new Element.div()], _.rootElement);
44 expect(_.rootElement.children.length).toBe(1);
45 }));
46
47 it('should remove nodes', async(() {
48 _.compile('<div><p>Hello World</p><!--comment--></div>');
49 expect(_.rootElement.childNodes.length).toBe(2);
50
51 animate.remove(_.rootElement.childNodes);
52 runner.frame();
53 // This might lead to a flash of unstyled content before
54 // removal. It would be nice if this was un-needed.
55 microLeap();
56 expect(_.rootElement.childNodes.length).toBe(0);
57 }));
58
59 it('should move nodes', async(() {
60 _.compile('<div></div>');
61 List<Node> a = es('<span>A</span>a');
62 List<Node> b = es('<span>B</span>b');
63 a.forEach((n) => _.rootElement.append(n));
64 b.forEach((n) => _.rootElement.append(n));
65 expect(_.rootElement.text).toEqual("AaBb");
66
67 animate.move(b, _.rootElement, insertBefore: a.first);
68 runner.frame();
69 expect(_.rootElement.text).toEqual("BbAa");
70
71 animate.move(a, _.rootElement, insertBefore: b.first);
72 runner.frame();
73 expect(_.rootElement.text).toEqual("AaBb");
74
75 animate.move(a, _.rootElement);
76 runner.frame();
77 expect(_.rootElement.text).toEqual("BbAa");
78 }));
79
80
81 it('should animate multiple elements', async(() {
82 _.compile('<div></div>');
83 List<Node> nodes = es('<span>A</span>a<span>B</span>b');
84
85 animate.insert(nodes, _.rootElement);
86 runner.frame();
87 expect(_.rootElement.text).toEqual("AaBb");
88 }));
89
90 it('should prevent child animations', async(() {
91 _.compile('<div></div>');
92 animate.addClass(_.rootElement, 'test');
93 runner.start();
94 expect(_.rootElement).toHaveClass('test-add');
95 var spans = es('<span>A</span><span>B</span>');
96 animate.insert(spans, _.rootElement);
97 runner.start();
98 expect(spans.first).not.toHaveClass('ng-add');
99 }));
100 });
101 }
102
103 class MockAnimationLoop extends Mock implements AnimationLoop {
104 num time = 0.0;
105
106 Future<AnimationResult> get onCompleted {
107 var cmp = new Completer<AnimationResult>();
108 cmp.complete(AnimationResult.COMPLETED);
109 return cmp.future;
110 }
111
112 List<LoopedAnimation> animations = [];
113
114 void play(LoopedAnimation animation) {
115 animations.add(animation);
116 }
117
118 void frame() {
119 for(var animation in animations) {
120 animation.read(time);
121 }
122
123 for(var animation in animations) {
124 animation.update(time);
125 }
126
127 time += 16.0;
128 }
129
130 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698