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

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

Issue 681303005: Make bookmark manager load tests work again. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: asdf Created 6 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
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/login/screen_context_test.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <!-- TODO(arv): Check in Closure unit tests and make this run as part of the 4 <!-- TODO(arv): Check in Closure unit tests and make this run as part of the
5 tests --> 5 tests -->
6 <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.j s"></script> 6 <script src="https://cdn.rawgit.com/google/closure-library/master/closure/goog/b ase.js"></script>
7 <script src="cr.js"></script> 7 <script src="../../../../../ui/webui/resources/js/cr.js"></script>
8 <script src="bmm/treeiterator.js"></script>
9 <script src="bmm.js"></script> 8 <script src="bmm.js"></script>
9 <title>Bookmark Manager Loading Test</title>
10 <script> 10 <script>
11 11
12 goog.require('goog.testing.jsunit'); 12 goog.require('goog.testing.jsunit');
13 goog.require('goog.testing.AsyncTestCase');
13 14
14 </script> 15 </script>
15 </head> 16 </head>
16 <body> 17 <body>
17 <script> 18 <script>
18 19
20 var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall(document.title);
21
19 var tree = { 22 var tree = {
20 id: 0, 23 id: 0,
21 children: [ 24 children: [
22 { 25 {
23 id: 1, 26 id: 1,
24 children: [ 27 children: [
25 {id: 2}, 28 {id: 2},
26 {id: 3, children: []} 29 {id: 3, children: []}
27 ] 30 ]
28 }, 31 },
(...skipping 17 matching lines...) Expand all
46 chrome.bookmarkManagerPrivate.getSubtree.load = function(node) { 49 chrome.bookmarkManagerPrivate.getSubtree.load = function(node) {
47 // getSubtree gets the root tree when id is ''. 50 // getSubtree gets the root tree when id is ''.
48 var id = node.id; 51 var id = node.id;
49 if (id == tree.id) 52 if (id == tree.id)
50 id = ''; 53 id = '';
51 for (var i = 0; i < callbacks[id].length; i++) { 54 for (var i = 0; i < callbacks[id].length; i++) {
52 callbacks[id][i].call(null, [node]); 55 callbacks[id][i].call(null, [node]);
53 } 56 }
54 }; 57 };
55 58
56 function setUp() { 59 function continueTesting() {
57 callbacks = {} 60 asyncTestCase.continueTesting();
Dan Beam 2014/10/30 03:10:29 sharing a global context no longer worked when the
58 } 61 }
59 62
60 function testLoadSingle() { 63 function testLoad() {
61 var calls = 0;
62 function f(node) {
63 calls++;
64 assertEquals(tree, node);
65 }
66 var p = bmm.loadTree();
67 p.then(f);
68
69 chrome.bookmarkManagerPrivate.getSubtree.load(tree);
70
71 assertEquals(1, calls);
72 assertEquals(1, callbacks[''].$calls);
73 }
74
75 function testLoadMultiple() {
76 var calls1 = 0; 64 var calls1 = 0;
77 var calls2 = 0; 65 var calls2 = 0;
78 function f1(node) { 66 function f1(node) {
79 calls1++; 67 calls1++;
80 assertEquals(tree, node); 68 assertEquals(tree, node);
81 } 69 }
82 function f2(node) { 70 function f2(node) {
83 calls2++; 71 calls2++;
84 assertEquals(tree, node); 72 assertEquals(tree, node);
85 } 73 }
86 74
87 var p = bmm.loadTree(); 75 var p = bmm.loadTree();
88 var p2 = bmm.loadTree(); 76 var p2 = bmm.loadTree();
89 p.then(f1); 77 var r = [
90 p2.then(f2); 78 p.then(f1),
79 p2.then(f2),
80 ];
91 81
92 chrome.bookmarkManagerPrivate.getSubtree.load(tree); 82 chrome.bookmarkManagerPrivate.getSubtree.load(tree);
93 83
94 assertEquals(1, calls1); 84 var root = Promise.all(r).then(function() {
95 assertEquals(1, calls2); 85 assertEquals(1, calls1);
96 assertEquals(1, callbacks[''].$calls); 86 assertEquals(1, calls2);
97 } 87 assertEquals(1, callbacks[''].$calls);
88 });
98 89
99 function testLoadSubtree() { 90
100 var calls = 0; 91 var calls3 = 0;
101 function f(node) { 92 function f3(node) {
102 calls++; 93 calls3++;
103 assertEquals(tree.children[0], node); 94 assertEquals(tree.children[0], node);
104 } 95 }
105 var p = bmm.loadSubtree(1); 96
106 p.then(f); 97 var p3 = bmm.loadSubtree(1);
98 var s = p3.then(f3);
107 99
108 chrome.bookmarkManagerPrivate.getSubtree.load(tree.children[0]); 100 chrome.bookmarkManagerPrivate.getSubtree.load(tree.children[0]);
109 101
110 assertEquals(1, calls); 102 var subtree = s.then(function() {
111 assertEquals(1, callbacks[1].$calls); 103 assertEquals(1, calls3);
104 assertEquals(1, callbacks[1].$calls);
105 });
106
107 Promise.all([root, subtree]).then(continueTesting);
112 } 108 }
113 109
114 </script> 110 </script>
115 </body> 111 </body>
116 </html> 112 </html>
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/login/screen_context_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698