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
3 // found in the LICENSE file.
5 // This just tests the interface. It does not test for specific results, only
6 // that callbacks are correctly invoked, expected parameters are correct,
7 // and failures are detected.
9 function callbackResult(result) {
10 if (chrome.runtime.lastError)
11 chrome.test.fail(chrome.runtime.lastError.message);
12 else if (result == false)
13 chrome.test.fail('Failed: ' + result);
16 var kEmail1 = 'asdf@gmail.com';
17 var kEmail2 = 'asdf2@gmail.com';
19 var availableTests = [
21 chrome.usersPrivate.addWhitelistedUser(
24 callbackResult(result);
26 chrome.usersPrivate.getWhitelistedUsers(function(users) {
27 var foundUser = false;
28 users.forEach(function(user) {
29 if (user.email == kEmail1) {
33 chrome.test.assertTrue(foundUser);
34 chrome.test.succeed();
39 function addAndRemoveUsers() {
40 chrome.usersPrivate.addWhitelistedUser(
43 callbackResult(result1);
45 chrome.usersPrivate.addWhitelistedUser(
48 callbackResult(result2);
50 chrome.usersPrivate.removeWhitelistedUser(
54 chrome.usersPrivate.getWhitelistedUsers(
56 chrome.test.assertTrue(users.length == 1);
58 kEmail2, users[0].email);
59 chrome.test.succeed();
69 chrome.usersPrivate.isCurrentUserOwner(function(isOwner) {
70 // Since we are testing with --stub-cros-settings this should be true.
71 chrome.test.assertTrue(isOwner);
72 chrome.test.succeed();
77 var testToRun = window.location.search.substring(1);
78 chrome.test.runTests(availableTests.filter(function(op) {
79 return op.name == testToRun;