OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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. |
| 4 |
| 5 var callbackPass = chrome.test.callbackPass; |
| 6 var callbackFail = chrome.test.callbackFail; |
| 7 var assertTrue = chrome.test.assertTrue; |
| 8 var assertEq = chrome.test.assertEq; |
| 9 |
| 10 chrome.test.runTests([ |
| 11 function getVisibleNetworks() { |
| 12 chrome.networkingPrivate.getVisibleNetworks( |
| 13 "All", |
| 14 callbackPass(function(result) { |
| 15 assertTrue(!!result); |
| 16 assertEq(4, result.length); |
| 17 assertEq([{ "Name": "eth0", |
| 18 "GUID": "stub_ethernet", |
| 19 "ConnectionState": "Connected", |
| 20 "Type": "Ethernet" |
| 21 }, |
| 22 { "Name": "wifi1", |
| 23 "GUID": "stub_wifi1", |
| 24 "ConnectionState": "Connected", |
| 25 "Type": "WiFi", |
| 26 "WiFi": { |
| 27 "SSID": "stub_wifi1", |
| 28 "Type": "WiFi" |
| 29 } |
| 30 }, |
| 31 { "Name": "wifi2_PSK", |
| 32 "GUID": "stub_wifi2", |
| 33 "ConnectionState": "NotConnected", |
| 34 "Type": "WiFi", |
| 35 "WiFi": { |
| 36 "SSID": "stub_wifi2", |
| 37 "Type": "WiFi" |
| 38 } |
| 39 }, |
| 40 { "Name": "cellular1", |
| 41 "GUID": "stub_cellular1", |
| 42 "ConnectionState": "NotConnected", |
| 43 "Type": "Cellular" |
| 44 }], result); |
| 45 })); |
| 46 }, |
| 47 function getVisibleNetworksWifi() { |
| 48 chrome.networkingPrivate.getVisibleNetworks( |
| 49 "WiFi", |
| 50 callbackPass(function(result) { |
| 51 assertTrue(!!result); |
| 52 assertEq(2, result.length); |
| 53 assertEq([{ "Name": "wifi1", |
| 54 "GUID": "stub_wifi1", |
| 55 "ConnectionState": "Connected", |
| 56 "Type": "WiFi", |
| 57 "WiFi": { |
| 58 "SSID": "stub_wifi1", |
| 59 "Type":"WiFi" |
| 60 } |
| 61 }, |
| 62 { "Name": "wifi2_PSK", |
| 63 "GUID": "stub_wifi2", |
| 64 "ConnectionState": "NotConnected", |
| 65 "Type": "WiFi", |
| 66 "WiFi": { |
| 67 "SSID": "stub_wifi2", |
| 68 "Type": "WiFi" |
| 69 } |
| 70 }], result); |
| 71 })); |
| 72 }, |
| 73 function getProperties() { |
| 74 chrome.networkingPrivate.getProperties( |
| 75 "stub_wifi2", |
| 76 callbackPass(function(result) { |
| 77 assertTrue(!!result); |
| 78 assertEq("wifi2_PSK", result.Name); |
| 79 assertEq("NotConnected", result.ConnectionState); |
| 80 assertEq("WiFi", result.Type); |
| 81 })); |
| 82 }, |
| 83 function startConnect() { |
| 84 chrome.networkingPrivate.startConnect("stub_wifi2", |
| 85 callbackPass(function() {})); |
| 86 }, |
| 87 function startDisconnect() { |
| 88 chrome.networkingPrivate.startDisconnect("stub_wifi2", |
| 89 callbackPass(function() {})); |
| 90 }, |
| 91 function startConnectNonexistent() { |
| 92 // Make sure we get an error when we try to connect to a nonexistent |
| 93 // network. |
| 94 chrome.networkingPrivate.startConnect( |
| 95 "nonexistent_path", |
| 96 callbackFail("Error.InvalidService", function() {})); |
| 97 } |
| 98 ]); |
OLD | NEW |