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 "publicKey": "cHVibGljX2tleQ==", // Base64("public_key")
19 "signedData": "c2lnbmVkX2RhdGE=", // Base64("signed_data")
20 "deviceSerial": "device_serial",
21 "deviceSsid": "Device 0123",
22 "deviceBssid": "00:01:02:03:04:05"
25 function callbackResult(result) {
26 if (chrome.runtime.lastError)
27 chrome.test.fail(chrome.runtime.lastError.message);
28 else if (result == false || result == kFailure)
29 chrome.test.fail('Failed: ' + result);
32 var availableTests = [
33 function getProperties() {
34 chrome.networkingPrivate.getProperties(
35 kGuid, callbackPass(callbackResult));
37 function getManagedProperties() {
38 chrome.networkingPrivate.getManagedProperties(
39 kGuid, callbackPass(callbackResult));
42 chrome.networkingPrivate.getState(
43 kGuid, callbackPass(callbackResult));
45 function setProperties() {
46 chrome.networkingPrivate.setProperties(
47 kGuid, { 'GUID': kGuid }, callbackPass(callbackResult));
49 function createNetwork() {
50 chrome.networkingPrivate.createNetwork(
51 false, { 'GUID': kGuid }, callbackPass(callbackResult));
53 function getNetworks() {
54 chrome.networkingPrivate.getNetworks(
55 { networkType: 'Ethernet' }, callbackPass(callbackResult));
57 function getVisibleNetworks() {
58 chrome.networkingPrivate.getVisibleNetworks(
59 'Ethernet', callbackPass(callbackResult));
61 function getEnabledNetworkTypes() {
62 chrome.networkingPrivate.getEnabledNetworkTypes(
63 callbackPass(callbackResult));
65 function enableNetworkType() {
66 chrome.networkingPrivate.enableNetworkType('Ethernet');
67 chrome.test.succeed();
69 function disableNetworkType() {
70 chrome.networkingPrivate.disableNetworkType('Ethernet');
71 chrome.test.succeed();
73 function requestNetworkScan() {
74 chrome.networkingPrivate.requestNetworkScan();
75 chrome.test.succeed();
77 function startConnect() {
78 chrome.networkingPrivate.startConnect(
79 kGuid, callbackPass(callbackResult));
81 function startDisconnect() {
82 chrome.networkingPrivate.startDisconnect(
83 kGuid, callbackPass(callbackResult));
85 function verifyDestination() {
86 chrome.networkingPrivate.verifyDestination(
87 verificationProperties, callbackPass(callbackResult));
89 function verifyAndEncryptCredentials() {
90 chrome.networkingPrivate.verifyAndEncryptCredentials(
91 verificationProperties, kGuid, callbackPass(callbackResult));
93 function verifyAndEncryptData() {
94 chrome.networkingPrivate.verifyAndEncryptData(
95 verificationProperties, 'data', callbackPass(callbackResult));
97 function setWifiTDLSEnabledState() {
98 chrome.networkingPrivate.setWifiTDLSEnabledState(
99 '', true, callbackPass(callbackResult));
101 function getWifiTDLSStatus() {
102 chrome.networkingPrivate.getWifiTDLSStatus(
103 '', callbackPass(callbackResult));
105 function getCaptivePortalStatus() {
106 chrome.networkingPrivate.getWifiTDLSStatus(
107 kGuid, callbackPass(callbackResult));
111 var testToRun = window.location.search.substring(1);
112 chrome.test.runTests(availableTests.filter(function(op) {
113 return op.name == testToRun;