Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / networking_private / test.js
blobde7150b70d4f898e200867ebc015b77457750d94
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 forgetNetwork() {
55     chrome.networkingPrivate.forgetNetwork(
56         kGuid, callbackPass(callbackResult));
57   },
58   function getNetworks() {
59     chrome.networkingPrivate.getNetworks(
60         { networkType: 'Ethernet' }, callbackPass(callbackResult));
61   },
62   function getVisibleNetworks() {
63     chrome.networkingPrivate.getVisibleNetworks(
64         'Ethernet', callbackPass(callbackResult));
65   },
66   function getEnabledNetworkTypes() {
67     chrome.networkingPrivate.getEnabledNetworkTypes(
68         callbackPass(callbackResult));
69   },
70   function getDeviceStates() {
71     chrome.networkingPrivate.getDeviceStates(callbackPass(callbackResult));
72   },
73   function enableNetworkType() {
74     chrome.networkingPrivate.enableNetworkType('Ethernet');
75     chrome.test.succeed();
76   },
77   function disableNetworkType() {
78     chrome.networkingPrivate.disableNetworkType('Ethernet');
79     chrome.test.succeed();
80   },
81   function requestNetworkScan() {
82     chrome.networkingPrivate.requestNetworkScan();
83     chrome.test.succeed();
84   },
85   function startConnect() {
86     chrome.networkingPrivate.startConnect(
87         kGuid, callbackPass(callbackResult));
88   },
89   function startDisconnect() {
90     chrome.networkingPrivate.startDisconnect(
91         kGuid, callbackPass(callbackResult));
92   },
93   function startActivate() {
94     chrome.networkingPrivate.startActivate(
95         kGuid, '' /* carrier */, callbackPass(callbackResult));
96   },
97   function verifyDestination() {
98     chrome.networkingPrivate.verifyDestination(
99         verificationProperties, callbackPass(callbackResult));
100   },
101   function verifyAndEncryptCredentials() {
102     chrome.networkingPrivate.verifyAndEncryptCredentials(
103         verificationProperties, kGuid, callbackPass(callbackResult));
104   },
105   function verifyAndEncryptData() {
106     chrome.networkingPrivate.verifyAndEncryptData(
107         verificationProperties, 'data', callbackPass(callbackResult));
108   },
109   function setWifiTDLSEnabledState() {
110     chrome.networkingPrivate.setWifiTDLSEnabledState(
111         '', true, callbackPass(callbackResult));
112   },
113   function getWifiTDLSStatus() {
114     chrome.networkingPrivate.getWifiTDLSStatus(
115         '', callbackPass(callbackResult));
116   },
117   function getCaptivePortalStatus() {
118     chrome.networkingPrivate.getWifiTDLSStatus(
119         kGuid, callbackPass(callbackResult));
120   },
123 var testToRun = window.location.search.substring(1);
124 chrome.test.runTests(availableTests.filter(function(op) {
125   return op.name == testToRun;
126 }));