| 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('swarm_tests'); | 5 #library('swarm_tests'); |
| 6 | 6 |
| 7 #import('dart:html'); | 7 #import('dart:html'); |
| 8 #import('../../../../swarm/swarmlib.dart'); | 8 #import('../../../../swarm/swarmlib.dart'); |
| 9 #import('../../../../ui_lib/base/base.dart'); | 9 #import('../../../../ui_lib/base/base.dart'); |
| 10 #import('../../../../ui_lib/view/view.dart'); | 10 #import('../../../../ui_lib/view/view.dart'); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 final feed = article.dataSource; | 38 final feed = article.dataSource; |
| 39 return { | 39 return { |
| 40 'section': CollectionUtils.find(swarm.sections, | 40 'section': CollectionUtils.find(swarm.sections, |
| 41 (s) => s.feeds.indexOf(feed, 0) >= 0).id, | 41 (s) => s.feeds.indexOf(feed, 0) >= 0).id, |
| 42 'feed': feed.id, | 42 'feed': feed.id, |
| 43 'article': article.id | 43 'article': article.id |
| 44 }; | 44 }; |
| 45 } | 45 } |
| 46 | 46 |
| 47 asyncTest('BackButton', 1, () { | 47 asyncTest('BackButton', 1, () { |
| 48 serialInvokeAsync([() { | 48 _serialInvokeAsync([() { |
| 49 Expect.equals(null, swarm.frontView.storyView); // verify initial state | 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 }, | 56 }, |
| 57 () { | 57 () { |
| 58 final item = swarm.sections[0].feeds[2].articles[1]; | 58 final item = swarm.sections[0].feeds[2].articles[1]; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 void expectHistory(List<Map<String, String>> entries) { | 130 void expectHistory(List<Map<String, String>> entries) { |
| 131 Expect.equals(entries.length, history.length); | 131 Expect.equals(entries.length, history.length); |
| 132 for (int i = 0; i < entries.length; i++) { | 132 for (int i = 0; i < entries.length; i++) { |
| 133 Map e = entries[i]; | 133 Map e = entries[i]; |
| 134 Map h = history[i]; | 134 Map h = history[i]; |
| 135 Expect.equals(e['article'], h['article']); | 135 Expect.equals(e['article'], h['article']); |
| 136 } | 136 } |
| 137 clearHistory(); | 137 clearHistory(); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 |
| 141 void _serialInvokeAsync(List closures) { |
| 142 final length = closures.length; |
| 143 if (length > 0) { |
| 144 int i = 0; |
| 145 void invokeNext() { |
| 146 closures[i](); |
| 147 i++; |
| 148 if (i < length) { |
| 149 window.setTimeout(invokeNext, 0); |
| 150 } |
| 151 } |
| 152 window.setTimeout(invokeNext, 0); |
| 153 } |
| 154 } |
| OLD | NEW |