OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
Devlin
2012/02/17 06:45:47
Probably a good idea to update the copyright date.
cduvall
2012/02/17 07:01:35
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // bookmarks api test | 5 // bookmarks api test |
6 // browser_tests.exe --gtest_filter=ExtensionApiTest.Bookmarks | 6 // browser_tests.exe --gtest_filter=ExtensionApiTest.Bookmarks |
7 | 7 |
8 // This is global state that is maintained across tests as a reference | 8 // This is global state that is maintained across tests as a reference |
9 // to compare against what's fetched from the browser (using compareTrees). | 9 // to compare against what's fetched from the browser (using compareTrees). |
10 // TODO(erikkay) It would be better if each test was self-contained and | 10 // TODO(erikkay) It would be better if each test was self-contained and |
11 // didn't depend on global state. | 11 // didn't depend on global state. |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 }); | 161 }); |
162 chrome.bookmarks.create(node, pass(function(results) { | 162 chrome.bookmarks.create(node, pass(function(results) { |
163 node.id = results.id; // since we couldn't know this going in | 163 node.id = results.id; // since we couldn't know this going in |
164 node.index = 0; | 164 node.index = 0; |
165 chrome.test.assertTrue(compareNode(node, results), | 165 chrome.test.assertTrue(compareNode(node, results), |
166 "created node != source"); | 166 "created node != source"); |
167 expected[0].children[0].children.push(node); | 167 expected[0].children[0].children.push(node); |
168 })); | 168 })); |
169 }, | 169 }, |
170 | 170 |
171 function createNoParentId() { | |
172 var node = {title:"google", url:"http://www.google.com/"}; | |
173 chrome.test.listenOnce(chrome.bookmarks.onCreated, function(id, created) { | |
174 node.id = created.id; | |
175 node.index = 0; | |
176 chrome.test.assertEq(id, node.id); | |
177 // Make sure parentId defaults to Other Bookmarks | |
Devlin
2012/02/17 06:45:47
nit: comments should be grammatically correct (inc
cduvall
2012/02/17 07:01:35
Done.
| |
178 chrome.test.assertEq(expected[0].children[1].id, created.parentId); | |
179 chrome.test.assertTrue(compareNode(node, created)); | |
180 }); | |
181 chrome.bookmarks.create(node, pass(function(results) { | |
182 node.id = results.id; // since we couldn't know this going in | |
183 node.index = 0; | |
184 chrome.test.assertTrue(compareNode(node, results), | |
185 "created node != source"); | |
186 expected[0].children[0].children.push(node); | |
Devlin
2012/02/17 06:45:47
This seems like a lot of duplicate code....Is ther
cduvall
2012/02/17 07:01:35
The other tests (createInRoot(), create()) share a
| |
187 })); | |
188 }, | |
189 | |
171 function createInRoot() { | 190 function createInRoot() { |
172 const error = "Can't modify the root bookmark folders."; | 191 const error = "Can't modify the root bookmark folders."; |
173 var node = {parentId:"0", title:"g404", url:"http://www.google.com/404"}; | 192 var node = {parentId:"0", title:"g404", url:"http://www.google.com/404"}; |
174 chrome.bookmarks.create(node, fail(error)); | 193 chrome.bookmarks.create(node, fail(error)); |
175 }, | 194 }, |
176 | 195 |
177 function createFolder() { | 196 function createFolder() { |
178 var node = {parentId:"1", title:"foo bar"}; // folder | 197 var node = {parentId:"1", title:"foo bar"}; // folder |
179 chrome.test.listenOnce(chrome.bookmarks.onCreated, function(id, created) { | 198 chrome.test.listenOnce(chrome.bookmarks.onCreated, function(id, created) { |
180 node.id = created.id; | 199 node.id = created.id; |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 "Should only get the last 2 bookmarks"); | 485 "Should only get the last 2 bookmarks"); |
467 | 486 |
468 chrome.test.assertTrue(compareNode(node3, results[0])); | 487 chrome.test.assertTrue(compareNode(node3, results[0])); |
469 chrome.test.assertTrue(compareNode(node2, results[1])); | 488 chrome.test.assertTrue(compareNode(node2, results[1])); |
470 })); | 489 })); |
471 } | 490 } |
472 ]); | 491 ]); |
473 } | 492 } |
474 | 493 |
475 run(); | 494 run(); |
OLD | NEW |