Chromium Code Reviews| 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 EXTENSION_ID = 'epcifkihnkjgphfkloaaleeakhpmgdmn'; | |
|
not at google - send to devlin
2013/01/23 22:37:52
There's actually a property chrome.runtime.id that
Greg Spencer (Chromium)
2013/02/01 23:35:55
Done.
| |
| 6 var FILE_CONTENTS = 'hello from test extension.'; | |
| 7 | |
| 8 chrome.test.runTests([ | |
| 9 function getVisibleNetworks() { | |
| 10 chrome.networkingPrivate.getVisibleNetworks( | |
| 11 "All", | |
| 12 function(result) { | |
|
not at google - send to devlin
2013/01/23 22:37:52
For asynchronous callbacks you need to wrap them i
Greg Spencer (Chromium)
2013/02/01 23:35:55
Done.
| |
| 13 chrome.test.assertTrue(!!result); | |
| 14 chrome.test.assertTrue(!chrome.runtime.lastError); | |
| 15 console.log("Visible Networks: " + JSON.stringify(result)); | |
|
not at google - send to devlin
2013/01/23 22:37:52
Remove logging before submitting
Greg Spencer (Chromium)
2013/02/01 23:35:55
Done.
| |
| 16 chrome.test.assertEq(4, result.length); | |
|
not at google - send to devlin
2013/01/23 22:37:52
assertEq works with objects, so
chrome.test.asser
Greg Spencer (Chromium)
2013/02/01 23:35:55
Done. The only bad thing about doing it this way
not at google - send to devlin
2013/02/02 00:11:32
If this becomes a problem it's something we can fi
| |
| 17 chrome.test.assertEq("eth0", result[0].Name); | |
| 18 chrome.test.assertEq("wifi1", result[1].Name); | |
| 19 chrome.test.assertEq("wifi2_PSK", result[2].Name); | |
| 20 chrome.test.assertEq("cellular1", result[3].Name); | |
| 21 chrome.test.assertEq("stub_ethernet", result[0].GUID); | |
| 22 chrome.test.assertEq("stub_wifi1", result[1].GUID); | |
| 23 chrome.test.assertEq("stub_wifi2", result[2].GUID); | |
| 24 chrome.test.assertEq("stub_cellular1", result[3].GUID); | |
| 25 chrome.test.assertEq("Connected", result[0].ConnectionState); | |
| 26 chrome.test.assertEq("Connected", result[1].ConnectionState); | |
| 27 chrome.test.assertEq("NotConnected", result[2].ConnectionState); | |
| 28 chrome.test.assertEq("NotConnected", result[3].ConnectionState); | |
| 29 chrome.test.assertEq("Ethernet", result[0].Type); | |
| 30 chrome.test.assertEq("WiFi", result[1].Type); | |
| 31 chrome.test.assertEq("WiFi", result[2].Type); | |
| 32 chrome.test.assertEq("Cellular", result[3].Type); | |
| 33 chrome.test.succeed(); | |
| 34 }); | |
| 35 }, | |
| 36 function getVisibleNetworksWifi() { | |
| 37 chrome.networkingPrivate.getVisibleNetworks( | |
| 38 "WiFi", | |
| 39 function(result) { | |
| 40 chrome.test.assertTrue(!!result); | |
| 41 chrome.test.assertTrue(!chrome.runtime.lastError); | |
| 42 console.log("Visible Networks WiFi: " + JSON.stringify(result)); | |
| 43 chrome.test.assertEq(2, result.length); | |
| 44 chrome.test.assertEq("wifi1", result[0].Name); | |
| 45 chrome.test.assertEq("wifi2_PSK", result[1].Name); | |
| 46 chrome.test.assertEq("stub_wifi1", result[0].GUID); | |
| 47 chrome.test.assertEq("stub_wifi2", result[1].GUID); | |
| 48 chrome.test.assertEq("Connected", result[0].ConnectionState); | |
| 49 chrome.test.assertEq("NotConnected", result[1].ConnectionState); | |
| 50 chrome.test.assertEq("WiFi", result[0].Type); | |
| 51 chrome.test.assertEq("WiFi", result[1].Type); | |
| 52 chrome.test.succeed(); | |
| 53 }); | |
| 54 }, | |
| 55 function getProperties() { | |
| 56 chrome.networkingPrivate.getProperties( | |
| 57 "stub_wifi2", | |
| 58 function(result) { | |
| 59 chrome.test.assertTrue(!!result); | |
| 60 chrome.test.assertTrue(!chrome.runtime.lastError); | |
| 61 console.log("GetProperties: " + JSON.stringify(result)); | |
| 62 chrome.test.assertEq("wifi2_PSK", result.Name); | |
| 63 chrome.test.assertEq("NotConnected", result.ConnectionState); | |
| 64 chrome.test.assertEq("WiFi", result.Type); | |
| 65 chrome.test.succeed(); | |
| 66 }); | |
| 67 }, | |
| 68 function requestConnect() { | |
| 69 chrome.networkingPrivate.requestConnect( | |
| 70 "stub_wifi2", | |
| 71 function() { | |
| 72 chrome.test.assertTrue(!chrome.runtime.lastError); | |
| 73 chrome.test.succeed(); | |
| 74 }); | |
| 75 }, | |
| 76 function requestDisconnect() { | |
| 77 chrome.networkingPrivate.requestDisconnect( | |
| 78 "stub_wifi2", | |
| 79 function() { | |
| 80 chrome.test.assertTrue(!chrome.runtime.lastError); | |
| 81 chrome.test.succeed(); | |
| 82 }); | |
| 83 }, | |
| 84 function requestConnectNonexistent() { | |
| 85 chrome.networkingPrivate.requestConnect( | |
| 86 "nonexistent_path", | |
| 87 function() { | |
| 88 // Make sure we get an error when we try to connect to a nonexistent | |
| 89 // network. | |
| 90 chrome.test.assertTrue(!!chrome.runtime.lastError); | |
| 91 chrome.test.assertTrue(!!chrome.runtime.lastError.message); | |
| 92 chrome.test.assertEq("Error.InvalidService", | |
| 93 chrome.runtime.lastError.message); | |
|
not at google - send to devlin
2013/01/23 22:37:52
For these, use callbackFail - it's the same as cal
Greg Spencer (Chromium)
2013/02/01 23:35:55
Done.
| |
| 94 chrome.test.succeed(); | |
| 95 }); | |
| 96 } | |
| 97 ]); | |
| OLD | NEW |