OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
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 the parentId defaults to the Other Bookmarks folder. |
| 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 })); |
| 187 }, |
| 188 |
171 function createInRoot() { | 189 function createInRoot() { |
172 const error = "Can't modify the root bookmark folders."; | 190 const error = "Can't modify the root bookmark folders."; |
173 var node = {parentId:"0", title:"g404", url:"http://www.google.com/404"}; | 191 var node = {parentId:"0", title:"g404", url:"http://www.google.com/404"}; |
174 chrome.bookmarks.create(node, fail(error)); | 192 chrome.bookmarks.create(node, fail(error)); |
175 }, | 193 }, |
176 | 194 |
177 function createFolder() { | 195 function createFolder() { |
178 var node = {parentId:"1", title:"foo bar"}; // folder | 196 var node = {parentId:"1", title:"foo bar"}; // folder |
179 chrome.test.listenOnce(chrome.bookmarks.onCreated, function(id, created) { | 197 chrome.test.listenOnce(chrome.bookmarks.onCreated, function(id, created) { |
180 node.id = created.id; | 198 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"); | 484 "Should only get the last 2 bookmarks"); |
467 | 485 |
468 chrome.test.assertTrue(compareNode(node3, results[0])); | 486 chrome.test.assertTrue(compareNode(node3, results[0])); |
469 chrome.test.assertTrue(compareNode(node2, results[1])); | 487 chrome.test.assertTrue(compareNode(node2, results[1])); |
470 })); | 488 })); |
471 } | 489 } |
472 ]); | 490 ]); |
473 } | 491 } |
474 | 492 |
475 run(); | 493 run(); |
OLD | NEW |