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

Side by Side Diff: client/tests/client/samples/swarm/swarm_tests.dart

Issue 8363040: Implement measurement using futures (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Respond to all code review comments Created 9 years, 1 month 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
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('swarm_tests'); 5 #library('swarm_tests');
6 6
7 #import('../../../../base/base.dart'); 7 #import('../../../../base/base.dart');
8 #import('../../../../html/html.dart'); 8 #import('../../../../html/html.dart');
9 #import('../../../../samples/swarm/swarmlib.dart'); 9 #import('../../../../samples/swarm/swarmlib.dart');
10 #import('../../../../testing/unittest/unittest.dart'); 10 #import('../../../../testing/unittest/unittest.dart');
11 #import('../../../../view/view.dart'); 11 #import('../../../../view/view.dart');
12 #import('../../../../util/utilslib.dart'); 12 #import('../../../../util/utilslib.dart');
13 13
14 // TODO(jmesserly): these would probably be easier to debug if they were written 14 // TODO(jmesserly): these would probably be easier to debug if they were written
15 // in the WebKit layout test style, so we could easy compare that the DOM is 15 // in the WebKit layout test style, so we could easy compare that the DOM is
16 // what we expect it to be after performing some simulated user actions. 16 // what we expect it to be after performing some simulated user actions.
17 17
18 void main() { 18 void main() {
19 Swarm swarm = new Swarm(); 19 Swarm swarm = new Swarm();
20 UIStateProxy state = new UIStateProxy(swarm.sections); 20 UIStateProxy state = new UIStateProxy(swarm.sections);
21 swarm.state = state; 21 swarm.state = state;
22 swarm.run(); 22 swarm.run();
23
24 // TODO(jmesserly): should be adding the full stylesheet here 23 // TODO(jmesserly): should be adding the full stylesheet here
25 Dom.addStyle(''' 24 Dom.addStyle('''
26 .story-content { 25 .story-content {
27 -webkit-column-width: 300px; 26 -webkit-column-width: 300px;
28 -webkit-column-gap: 26px; /* 2em */ 27 -webkit-column-gap: 26px; /* 2em */
29 }'''); 28 }''');
30 29
31 getStoryNode() => swarm.frontView.storyView.node; 30 getStoryNode() => swarm.frontView.storyView.node;
32 31
33 getView(Section section) { 32 getView(Section section) {
34 return CollectionUtils.find(swarm.frontView.sections.childViews, 33 return CollectionUtils.find(swarm.frontView.sections.childViews,
35 (view) => view.section == section); 34 (view) => view.section == section);
36 } 35 }
37 36
38 getHistory(Article article) { 37 getHistory(Article article) {
39 final feed = article.dataSource; 38 final feed = article.dataSource;
40 return { 39 return {
41 'section': CollectionUtils.find(swarm.sections, 40 'section': CollectionUtils.find(swarm.sections,
42 (s) => s.feeds.indexOf(feed, 0) >= 0).id, 41 (s) => s.feeds.indexOf(feed, 0) >= 0).id,
43 'feed': feed.id, 42 'feed': feed.id,
44 'article': article.id 43 'article': article.id
45 }; 44 };
46 } 45 }
47 46
48 test('BackButton', () { 47 asyncTest('BackButton', 1, () {
49 Expect.equals(null, swarm.frontView.storyView); // verify initial state 48 serialInvokeAsync([() {
49 Expect.equals(null, swarm.frontView.storyView); // verify initial state
50 50
51 // Make sure we've transitioned to the section 51 // Make sure we've transitioned to the section
52 // In the real app, this isn't needed because ConveyorView fires the 52 // In the real app, this isn't needed because ConveyorView fires the
53 // transition end event before we can click a story. 53 // transition end event before we can click a story.
54 SectionView section = getView(swarm.sections[0]); 54 SectionView section = getView(swarm.sections[0]);
55 section.showSources(); 55 section.showSources();
56 },
57 () {
58 final item = swarm.sections[0].feeds[2].articles[1];
59 state.loadFromHistory(getHistory(item));
56 60
57 final item = swarm.sections[0].feeds[2].articles[1]; 61 Expect.equals(item, state.currentArticle.value);
58 state.loadFromHistory(getHistory(item));
59 62
60 Expect.equals(item, state.currentArticle.value); 63 Expect.isFalse(getStoryNode().classes.contains(CSS.HIDDEN_STORY));
61 64
62 Expect.isFalse(getStoryNode().classes.contains(CSS.HIDDEN_STORY)); 65 state.loadFromHistory({});
63 66
64 state.loadFromHistory({}); 67 Expect.equals(null, state.currentArticle.value);
65 68 Expect.isTrue(getStoryNode().classes.contains(CSS.HIDDEN_STORY));
66 Expect.equals(null, state.currentArticle.value); 69 callbackDone();
67 Expect.isTrue(getStoryNode().classes.contains(CSS.HIDDEN_STORY)); 70 }]);
68 }); 71 });
69 72
70 test('StoryView', () { 73 test('StoryView', () {
71 state.clearHistory(); 74 state.clearHistory();
72 75
73 Expect.isTrue(getStoryNode().classes.contains(CSS.HIDDEN_STORY)); 76 Expect.isTrue(getStoryNode().classes.contains(CSS.HIDDEN_STORY));
74 77
75 final dataSourceView = 78 final dataSourceView =
76 swarm.frontView.currentSection.dataSourceView.getSubview(0); 79 swarm.frontView.currentSection.dataSourceView.getSubview(0);
77 final itemView = dataSourceView.itemsView.getSubview(0); 80 final itemView = dataSourceView.itemsView.getSubview(0);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 void expectHistory(List<Map<String, String>> entries) { 130 void expectHistory(List<Map<String, String>> entries) {
128 Expect.equals(entries.length, history.length); 131 Expect.equals(entries.length, history.length);
129 for (int i = 0; i < entries.length; i++) { 132 for (int i = 0; i < entries.length; i++) {
130 Map e = entries[i]; 133 Map e = entries[i];
131 Map h = history[i]; 134 Map h = history[i];
132 Expect.equals(e['article'], h['article']); 135 Expect.equals(e['article'], h['article']);
133 } 136 }
134 clearHistory(); 137 clearHistory();
135 } 138 }
136 } 139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698