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")
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
));
38 function getManagedProperties() {
39 chrome
.networkingPrivate
.getManagedProperties(
40 kGuid
, callbackPass(callbackResult
));
43 chrome
.networkingPrivate
.getState(
44 kGuid
, callbackPass(callbackResult
));
46 function setProperties() {
47 chrome
.networkingPrivate
.setProperties(
48 kGuid
, { 'GUID': kGuid
}, callbackPass(callbackResult
));
50 function createNetwork() {
51 chrome
.networkingPrivate
.createNetwork(
52 false, { 'GUID': kGuid
}, callbackPass(callbackResult
));
54 function forgetNetwork() {
55 chrome
.networkingPrivate
.forgetNetwork(
56 kGuid
, callbackPass(callbackResult
));
58 function getNetworks() {
59 chrome
.networkingPrivate
.getNetworks(
60 { networkType
: 'Ethernet' }, callbackPass(callbackResult
));
62 function getVisibleNetworks() {
63 chrome
.networkingPrivate
.getVisibleNetworks(
64 'Ethernet', callbackPass(callbackResult
));
66 function getEnabledNetworkTypes() {
67 chrome
.networkingPrivate
.getEnabledNetworkTypes(
68 callbackPass(callbackResult
));
70 function getDeviceStates() {
71 chrome
.networkingPrivate
.getDeviceStates(callbackPass(callbackResult
));
73 function enableNetworkType() {
74 chrome
.networkingPrivate
.enableNetworkType('Ethernet');
75 chrome
.test
.succeed();
77 function disableNetworkType() {
78 chrome
.networkingPrivate
.disableNetworkType('Ethernet');
79 chrome
.test
.succeed();
81 function requestNetworkScan() {
82 chrome
.networkingPrivate
.requestNetworkScan();
83 chrome
.test
.succeed();
85 function startConnect() {
86 chrome
.networkingPrivate
.startConnect(
87 kGuid
, callbackPass(callbackResult
));
89 function startDisconnect() {
90 chrome
.networkingPrivate
.startDisconnect(
91 kGuid
, callbackPass(callbackResult
));
93 function startActivate() {
94 chrome
.networkingPrivate
.startActivate(
95 kGuid
, '' /* carrier */, callbackPass(callbackResult
));
97 function verifyDestination() {
98 chrome
.networkingPrivate
.verifyDestination(
99 verificationProperties
, callbackPass(callbackResult
));
101 function verifyAndEncryptCredentials() {
102 chrome
.networkingPrivate
.verifyAndEncryptCredentials(
103 verificationProperties
, kGuid
, callbackPass(callbackResult
));
105 function verifyAndEncryptData() {
106 chrome
.networkingPrivate
.verifyAndEncryptData(
107 verificationProperties
, 'data', callbackPass(callbackResult
));
109 function setWifiTDLSEnabledState() {
110 chrome
.networkingPrivate
.setWifiTDLSEnabledState(
111 '', true, callbackPass(callbackResult
));
113 function getWifiTDLSStatus() {
114 chrome
.networkingPrivate
.getWifiTDLSStatus(
115 '', callbackPass(callbackResult
));
117 function getCaptivePortalStatus() {
118 chrome
.networkingPrivate
.getWifiTDLSStatus(
119 kGuid
, callbackPass(callbackResult
));
121 function unlockCellularSim() {
122 chrome
.networkingPrivate
.unlockCellularSim(
123 kGuid
, '1111', callbackPass(callbackResult
));
125 function setCellularSimState() {
126 var simState
= { requirePin
: true, currentPin
: '1111', newPin
: '1234' };
127 chrome
.networkingPrivate
.setCellularSimState(
128 kGuid
, simState
, callbackPass(callbackResult
));
132 var testToRun
= window
.location
.search
.substring(1);
133 chrome
.test
.runTests(availableTests
.filter(function(op
) {
134 return op
.name
== testToRun
;