Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / networking_private / test.js
blob336018d66f6775d8713faee15ebd61df40cf9ba3
1 // Copyright 2014 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 var callbackPass = chrome.test.callbackPass;
11 var kFailure = 'Failure';
12 var kGuid = 'SOME_GUID';
14 // Test properties for the verification API.
15 var verificationProperties = {
16   "certificate": "certificate",
17   "intermediateCertificates": ["ica1", "ica2", "ica3"],
18   "publicKey": "cHVibGljX2tleQ==",  // Base64("public_key")
19   "nonce": "nonce",
20   "signedData": "c2lnbmVkX2RhdGE=",  // Base64("signed_data")
21   "deviceSerial": "device_serial",
22   "deviceSsid": "Device 0123",
23   "deviceBssid": "00:01:02:03:04:05"
26 function callbackResult(result) {
27   if (chrome.runtime.lastError)
28     chrome.test.fail(chrome.runtime.lastError.message);
29   else if (result == false || result == kFailure)
30     chrome.test.fail('Failed: ' + result);
33 var availableTests = [
34   function getProperties() {
35     chrome.networkingPrivate.getProperties(
36         kGuid, callbackPass(callbackResult));
37   },
38   function getManagedProperties() {
39     chrome.networkingPrivate.getManagedProperties(
40         kGuid, callbackPass(callbackResult));
41   },
42   function getState() {
43     chrome.networkingPrivate.getState(
44         kGuid, callbackPass(callbackResult));
45   },
46   function setProperties() {
47     chrome.networkingPrivate.setProperties(
48         kGuid, { 'GUID': kGuid }, callbackPass(callbackResult));
49   },
50   function createNetwork() {
51     chrome.networkingPrivate.createNetwork(
52         false, { 'GUID': kGuid }, callbackPass(callbackResult));
53   },
54   function getNetworks() {
55     chrome.networkingPrivate.getNetworks(
56         { networkType: 'Ethernet' }, callbackPass(callbackResult));
57   },
58   function getVisibleNetworks() {
59     chrome.networkingPrivate.getVisibleNetworks(
60         'Ethernet', callbackPass(callbackResult));
61   },
62   function getEnabledNetworkTypes() {
63     chrome.networkingPrivate.getEnabledNetworkTypes(
64         callbackPass(callbackResult));
65   },
66   function enableNetworkType() {
67     chrome.networkingPrivate.enableNetworkType('Ethernet');
68     chrome.test.succeed();
69   },
70   function disableNetworkType() {
71     chrome.networkingPrivate.disableNetworkType('Ethernet');
72     chrome.test.succeed();
73   },
74   function requestNetworkScan() {
75     chrome.networkingPrivate.requestNetworkScan();
76     chrome.test.succeed();
77   },
78   function startConnect() {
79     chrome.networkingPrivate.startConnect(
80         kGuid, callbackPass(callbackResult));
81   },
82   function startDisconnect() {
83     chrome.networkingPrivate.startDisconnect(
84         kGuid, callbackPass(callbackResult));
85   },
86   function verifyDestination() {
87     chrome.networkingPrivate.verifyDestination(
88         verificationProperties, callbackPass(callbackResult));
89   },
90   function verifyAndEncryptCredentials() {
91     chrome.networkingPrivate.verifyAndEncryptCredentials(
92         verificationProperties, kGuid, callbackPass(callbackResult));
93   },
94   function verifyAndEncryptData() {
95     chrome.networkingPrivate.verifyAndEncryptData(
96         verificationProperties, 'data', callbackPass(callbackResult));
97   },
98   function setWifiTDLSEnabledState() {
99     chrome.networkingPrivate.setWifiTDLSEnabledState(
100         '', true, callbackPass(callbackResult));
101   },
102   function getWifiTDLSStatus() {
103     chrome.networkingPrivate.getWifiTDLSStatus(
104         '', callbackPass(callbackResult));
105   },
106   function getCaptivePortalStatus() {
107     chrome.networkingPrivate.getWifiTDLSStatus(
108         kGuid, callbackPass(callbackResult));
109   },
112 var testToRun = window.location.search.substring(1);
113 chrome.test.runTests(availableTests.filter(function(op) {
114   return op.name == testToRun;
115 }));