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

Side by Side Diff: chrome/test/data/extensions/api_test/bookmarks/test.js

Issue 769153007: Managed bookmarks for supervised users (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build (Android & unit_tests) Created 5 years, 10 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
« no previous file with comments | « chrome/common/extensions/api/bookmarks.json ('k') | components/bookmark_bar_strings.grdp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 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.
12 var expected = [ 12 var expected = [
13 {"children": [ 13 {"children": [
14 {children:[], id:"1", parentId:"0", index:0, title:"Bookmarks bar"}, 14 {children:[], id:"1", parentId:"0", index:0, title:"Bookmarks bar"},
15 {children:[], id:"2", parentId:"0", index:1, title:"Other bookmarks"}, 15 {children:[], id:"2", parentId:"0", index:1, title:"Other bookmarks"},
16 {id:"4", parentId:"0", index:3, title:"Managed bookmarks", 16 {id:"4", parentId:"0", index:3, title:"Managed bookmarks",
17 unmodifiable:"managed", children:[ 17 unmodifiable:"managed", children:[
18 {id:"5", parentId:"4", index:0, title:"Managed Bookmark", 18 {id:"6", parentId:"4", index:0, title:"Managed Bookmark",
19 url:"http://www.chromium.org/", unmodifiable:"managed"}, 19 url:"http://www.chromium.org/", unmodifiable:"managed"},
20 {id:"6", parentId:"4", index:1, title:"Managed Folder", 20 {id:"7", parentId:"4", index:1, title:"Managed Folder",
21 children:[], unmodifiable:"managed"}
22 ]
23 },
24 {id:"5", parentId:"0", index:4, title:"Parent suggestions",
25 unmodifiable:"managed", children:[
26 {id:"8", parentId:"4", index:0, title:"Supervised Bookmark",
27 url:"http://www.pbskids.org/", unmodifiable:"managed"},
28 {id:"9", parentId:"4", index:1, title:"Supervised Folder",
21 children:[], unmodifiable:"managed"} 29 children:[], unmodifiable:"managed"}
22 ] 30 ]
23 } 31 }
24 ], 32 ],
25 id:"0", title:"" 33 id:"0", title:""
26 } 34 }
27 ]; 35 ];
28 36
29 function bookmarksBar() { return expected[0].children[0]; } 37 function bookmarksBar() { return expected[0].children[0]; }
30 function otherBookmarks() { return expected[0].children[1]; } 38 function otherBookmarks() { return expected[0].children[1]; }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 function run() { 137 function run() {
130 chrome.test.runTests([ 138 chrome.test.runTests([
131 function getTree() { 139 function getTree() {
132 verifyTreeIsExpected(pass()); 140 verifyTreeIsExpected(pass());
133 }, 141 },
134 142
135 function get() { 143 function get() {
136 chrome.bookmarks.get("1", pass(function(results) { 144 chrome.bookmarks.get("1", pass(function(results) {
137 chrome.test.assertTrue(compareNode(results[0], expected[0].children[0])); 145 chrome.test.assertTrue(compareNode(results[0], expected[0].children[0]));
138 })); 146 }));
139 chrome.bookmarks.get("5", pass(function(results) { 147 chrome.bookmarks.get("6", pass(function(results) {
140 chrome.test.assertTrue(compareNode( 148 chrome.test.assertTrue(compareNode(
141 results[0], expected[0].children[2].children[0])); 149 results[0], expected[0].children[2].children[0]));
142 })); 150 }));
143 chrome.bookmarks.get("42", fail("Can't find bookmark for id.")); 151 chrome.bookmarks.get("42", fail("Can't find bookmark for id."));
144 }, 152 },
145 153
146 function getArray() { 154 function getArray() {
147 chrome.bookmarks.get(["1", "2"], pass(function(results) { 155 chrome.bookmarks.get(["1", "2"], pass(function(results) {
148 chrome.test.assertTrue(compareNode(results[0], expected[0].children[0]), 156 chrome.test.assertTrue(compareNode(results[0], expected[0].children[0]),
149 "get() result != expected"); 157 "get() result != expected");
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 function getRecent() { 508 function getRecent() {
501 var failed = false; 509 var failed = false;
502 try { 510 try {
503 chrome.bookmarks.getRecent(0, function() {}); 511 chrome.bookmarks.getRecent(0, function() {});
504 } catch (ex) { 512 } catch (ex) {
505 failed = true; 513 failed = true;
506 } 514 }
507 chrome.test.assertTrue(failed, "Calling with 0 should fail"); 515 chrome.test.assertTrue(failed, "Calling with 0 should fail");
508 516
509 chrome.bookmarks.getRecent(10000, pass(function(results) { 517 chrome.bookmarks.getRecent(10000, pass(function(results) {
510 // Should include the "Managed Bookmark". 518 // Should include the "Managed Bookmark" and "Supervised Bookmark".
511 chrome.test.assertEq(4, results.length, 519 chrome.test.assertEq(5, results.length,
512 "Should have gotten all recent bookmarks"); 520 "Should have gotten all recent bookmarks");
513 })); 521 }));
514 522
515 chrome.bookmarks.getRecent(2, pass(function(results) { 523 chrome.bookmarks.getRecent(2, pass(function(results) {
516 chrome.test.assertEq(2, results.length, 524 chrome.test.assertEq(2, results.length,
517 "Should only get the last 2 bookmarks"); 525 "Should only get the last 2 bookmarks");
518 526
519 chrome.test.assertTrue(compareNode(node3, results[0])); 527 chrome.test.assertTrue(compareNode(node3, results[0]));
520 chrome.test.assertTrue(compareNode(node2, results[1])); 528 chrome.test.assertTrue(compareNode(node2, results[1]));
521 })); 529 }));
(...skipping 13 matching lines...) Expand all
535 function(result) { 543 function(result) {
536 chrome.test.assertEq(newTitle, result.title); 544 chrome.test.assertEq(newTitle, result.title);
537 chrome.test.assertFalse('url' in result) 545 chrome.test.assertFalse('url' in result)
538 })); 546 }));
539 }); 547 });
540 } 548 }
541 ]); 549 ]);
542 } 550 }
543 551
544 run(); 552 run();
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/bookmarks.json ('k') | components/bookmark_bar_strings.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698