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 getNetworks() {
55 chrome.networkingPrivate.getNetworks(
56 { networkType: 'Ethernet' }, callbackPass(callbackResult));
58 function getVisibleNetworks() {
59 chrome.networkingPrivate.getVisibleNetworks(
60 'Ethernet', callbackPass(callbackResult));
62 function getEnabledNetworkTypes() {
63 chrome.networkingPrivate.getEnabledNetworkTypes(
64 callbackPass(callbackResult));
66 function enableNetworkType() {
67 chrome.networkingPrivate.enableNetworkType('Ethernet');
68 chrome.test.succeed();
70 function disableNetworkType() {
71 chrome.networkingPrivate.disableNetworkType('Ethernet');
72 chrome.test.succeed();
74 function requestNetworkScan() {
75 chrome.networkingPrivate.requestNetworkScan();
76 chrome.test.succeed();
78 function startConnect() {
79 chrome.networkingPrivate.startConnect(
80 kGuid, callbackPass(callbackResult));
82 function startDisconnect() {
83 chrome.networkingPrivate.startDisconnect(
84 kGuid, callbackPass(callbackResult));
86 function verifyDestination() {
87 chrome.networkingPrivate.verifyDestination(
88 verificationProperties, callbackPass(callbackResult));
90 function verifyAndEncryptCredentials() {
91 chrome.networkingPrivate.verifyAndEncryptCredentials(
92 verificationProperties, kGuid, callbackPass(callbackResult));
94 function verifyAndEncryptData() {
95 chrome.networkingPrivate.verifyAndEncryptData(
96 verificationProperties, 'data', callbackPass(callbackResult));
98 function setWifiTDLSEnabledState() {
99 chrome.networkingPrivate.setWifiTDLSEnabledState(
100 '', true, callbackPass(callbackResult));
102 function getWifiTDLSStatus() {
103 chrome.networkingPrivate.getWifiTDLSStatus(
104 '', callbackPass(callbackResult));
106 function getCaptivePortalStatus() {
107 chrome.networkingPrivate.getWifiTDLSStatus(
108 kGuid, callbackPass(callbackResult));
112 var testToRun = window.location.search.substring(1);
113 chrome.test.runTests(availableTests.filter(function(op) {
114 return op.name == testToRun;