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

Side by Side Diff: chrome/browser/resources/bookmark_manager/js/bmm/tree_iterator_test.html

Issue 6801017: Changes 'Open all' bookmarks to not recurse through nested folders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: i++ Created 9 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 <!DOCTYPE html>
2 <html>
3 <head>
4 <!-- TODO(arv): Check in Closue unit tests and make this run as part of the
5 tests -->
6 <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.j s"></script>
7 <script src="../cr.js"></script>
8 <script src="treeiterator.js"></script>
9 <script>
10
11 goog.require('goog.testing.jsunit');
12
13 </script>
14 </head>
15 <body>
16 <script>
17
18 const TreeIterator = bmm.TreeIterator;
19
20 var tree = {
21 id: 0,
22 children: [
23 {
24 id: 1,
25 children: [
26 {id: 2},
27 {id: 3, children: []}
28 ]
29 },
30 {id: 4},
31 {id: 5}
32 ]
33 };
34
35 function testIteration() {
36 var it = new TreeIterator(tree);
37 var expextedIds = [0, 1, 2, 3, 4, 5];
38 var i = 0;
39 while (it.moveNext()) {
40 var node = it.current;
41 assertEquals(expextedIds[i], node.id);
42 i++;
43 }
44 }
45
46 function testIteration2() {
47 var it = new TreeIterator(tree.children[0]);
48 var expextedIds = [1, 2, 3];
49 var i = 0;
50 while (it.moveNext()) {
51 var node = it.current;
52 assertEquals(expextedIds[i], node.id);
53 i++;
54 }
55 }
56
57 function testIteration3() {
58 var it = new TreeIterator(tree.children[1]);
59 var expextedIds = [4];
60 var i = 0;
61 while (it.moveNext()) {
62 var node = it.current;
63 assertEquals(expextedIds[i], node.id);
64 i++;
65 }
66 }
67
68 function testThrowsAfterEnd() {
69 // Same as testIteration3
70 var it = new TreeIterator(tree.children[1]);
71 var expextedIds = [4];
72 var i = 0;
73 while (it.moveNext()) {
74 var node = it.current;
75 assertEquals(expextedIds[i], node.id);
76 i++;
77 }
78
79 assertThrows(function() {
80 it.current;
81 });
82 }
83
84 function testThrowsBeforeMoveNext() {
85 // Same as testIteration3
86 var it = new TreeIterator(tree);
87 assertThrows(function() {
88 it.current;
89 });
90 }
91
92 </script>
93 </body>
94 </html>
OLDNEW
« no previous file with comments | « chrome/browser/resources/bookmark_manager/js/bmm/tree_iterator.js ('k') | chrome/browser/resources/bookmark_manager/main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698