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

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

Issue 2259943003: Settings People CrOS: Display supervised users' names correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test variables Created 4 years, 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // This just tests the interface. It does not test for specific results, only 5 // This just tests the interface. It does not test for specific results, only
6 // that callbacks are correctly invoked, expected parameters are correct, 6 // that callbacks are correctly invoked, expected parameters are correct,
7 // and failures are detected. 7 // and failures are detected.
8 8
9 function callbackResult(result) { 9 function callbackResult(result) {
10 if (chrome.runtime.lastError) 10 if (chrome.runtime.lastError)
11 chrome.test.fail(chrome.runtime.lastError.message); 11 chrome.test.fail(chrome.runtime.lastError.message);
12 else if (result == false) 12 else if (result == false)
13 chrome.test.fail('Failed: ' + result); 13 chrome.test.fail('Failed: ' + result);
14 } 14 }
15 15
16 var kEmail1 = 'asdf@gmail.com'; 16 var kEmail1 = 'asdf@gmail.com';
17 var kEmail2 = 'asdf2@gmail.com'; 17 var kEmail2 = 'asdf2@gmail.com';
18 var kName1 = kEmail1;
Devlin 2016/08/20 01:23:04 it'd probably be good to make this something diffe
tommycli 2016/08/20 01:35:57 So... they would only be different for locally man
19 var kName2 = kEmail2;
18 20
19 var availableTests = [ 21 var availableTests = [
20 function addUser() { 22 function addUser() {
21 chrome.usersPrivate.addWhitelistedUser( 23 chrome.usersPrivate.addWhitelistedUser(
22 kEmail1, 24 kEmail1,
23 function(result) { 25 function(result) {
24 callbackResult(result); 26 callbackResult(result);
25 27
26 chrome.usersPrivate.getWhitelistedUsers(function(users) { 28 chrome.usersPrivate.getWhitelistedUsers(function(users) {
27 var foundUser = false; 29 var foundUser = false;
28 users.forEach(function(user) { 30 users.forEach(function(user) {
29 if (user.email == kEmail1) { 31 if (user.email == kEmail1 && user.name == kName1) {
30 foundUser = true; 32 foundUser = true;
31 } 33 }
32 }); 34 });
33 chrome.test.assertTrue(foundUser); 35 chrome.test.assertTrue(foundUser);
34 chrome.test.succeed(); 36 chrome.test.succeed();
35 }); 37 });
36 }); 38 });
37 }, 39 },
38 40
39 function addAndRemoveUsers() { 41 function addAndRemoveUsers() {
40 chrome.usersPrivate.addWhitelistedUser( 42 chrome.usersPrivate.addWhitelistedUser(
41 kEmail1, 43 kEmail1,
42 function(result1) { 44 function(result1) {
43 callbackResult(result1); 45 callbackResult(result1);
44 46
45 chrome.usersPrivate.addWhitelistedUser( 47 chrome.usersPrivate.addWhitelistedUser(
46 kEmail2, 48 kEmail2,
47 function(result2) { 49 function(result2) {
48 callbackResult(result2); 50 callbackResult(result2);
49 51
50 chrome.usersPrivate.removeWhitelistedUser( 52 chrome.usersPrivate.removeWhitelistedUser(
51 kEmail1, 53 kEmail1,
52 function(result3) { 54 function(result3) {
53 55
54 chrome.usersPrivate.getWhitelistedUsers( 56 chrome.usersPrivate.getWhitelistedUsers(
55 function(users) { 57 function(users) {
56 chrome.test.assertTrue(users.length == 1); 58 chrome.test.assertTrue(users.length == 1);
57 chrome.test.assertEq( 59 chrome.test.assertEq(kEmail2, users[0].email);
58 kEmail2, users[0].email); 60 chrome.test.assertEq(kName2, users[0].name);
59 chrome.test.succeed(); 61 chrome.test.succeed();
60 }); 62 });
61 63
62 }); 64 });
63 }); 65 });
64 }); 66 });
65 67
66 }, 68 },
67 69
68 function isOwner() { 70 function isOwner() {
69 chrome.usersPrivate.isCurrentUserOwner(function(isOwner) { 71 chrome.usersPrivate.isCurrentUserOwner(function(isOwner) {
70 // Since we are testing with --stub-cros-settings this should be true. 72 // Since we are testing with --stub-cros-settings this should be true.
71 chrome.test.assertTrue(isOwner); 73 chrome.test.assertTrue(isOwner);
72 chrome.test.succeed(); 74 chrome.test.succeed();
73 }); 75 });
74 }, 76 },
75 ]; 77 ];
76 78
77 var testToRun = window.location.search.substring(1); 79 var testToRun = window.location.search.substring(1);
78 chrome.test.runTests(availableTests.filter(function(op) { 80 chrome.test.runTests(availableTests.filter(function(op) {
79 return op.name == testToRun; 81 return op.name == testToRun;
80 })); 82 }));
81
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/users_private.idl ('k') | third_party/closure_compiler/externs/users_private.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698