Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/networking/test.js |
| diff --git a/chrome/test/data/extensions/api_test/networking/test.js b/chrome/test/data/extensions/api_test/networking/test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..565d89744bea8cce7e4ae531bf08ab91c6b499ac |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/networking/test.js |
| @@ -0,0 +1,97 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +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.
|
| +var FILE_CONTENTS = 'hello from test extension.'; |
| + |
| +chrome.test.runTests([ |
| + function getVisibleNetworks() { |
| + chrome.networkingPrivate.getVisibleNetworks( |
| + "All", |
| + 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.
|
| + chrome.test.assertTrue(!!result); |
| + chrome.test.assertTrue(!chrome.runtime.lastError); |
| + 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.
|
| + 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
|
| + chrome.test.assertEq("eth0", result[0].Name); |
| + chrome.test.assertEq("wifi1", result[1].Name); |
| + chrome.test.assertEq("wifi2_PSK", result[2].Name); |
| + chrome.test.assertEq("cellular1", result[3].Name); |
| + chrome.test.assertEq("stub_ethernet", result[0].GUID); |
| + chrome.test.assertEq("stub_wifi1", result[1].GUID); |
| + chrome.test.assertEq("stub_wifi2", result[2].GUID); |
| + chrome.test.assertEq("stub_cellular1", result[3].GUID); |
| + chrome.test.assertEq("Connected", result[0].ConnectionState); |
| + chrome.test.assertEq("Connected", result[1].ConnectionState); |
| + chrome.test.assertEq("NotConnected", result[2].ConnectionState); |
| + chrome.test.assertEq("NotConnected", result[3].ConnectionState); |
| + chrome.test.assertEq("Ethernet", result[0].Type); |
| + chrome.test.assertEq("WiFi", result[1].Type); |
| + chrome.test.assertEq("WiFi", result[2].Type); |
| + chrome.test.assertEq("Cellular", result[3].Type); |
| + chrome.test.succeed(); |
| + }); |
| + }, |
| + function getVisibleNetworksWifi() { |
| + chrome.networkingPrivate.getVisibleNetworks( |
| + "WiFi", |
| + function(result) { |
| + chrome.test.assertTrue(!!result); |
| + chrome.test.assertTrue(!chrome.runtime.lastError); |
| + console.log("Visible Networks WiFi: " + JSON.stringify(result)); |
| + chrome.test.assertEq(2, result.length); |
| + chrome.test.assertEq("wifi1", result[0].Name); |
| + chrome.test.assertEq("wifi2_PSK", result[1].Name); |
| + chrome.test.assertEq("stub_wifi1", result[0].GUID); |
| + chrome.test.assertEq("stub_wifi2", result[1].GUID); |
| + chrome.test.assertEq("Connected", result[0].ConnectionState); |
| + chrome.test.assertEq("NotConnected", result[1].ConnectionState); |
| + chrome.test.assertEq("WiFi", result[0].Type); |
| + chrome.test.assertEq("WiFi", result[1].Type); |
| + chrome.test.succeed(); |
| + }); |
| + }, |
| + function getProperties() { |
| + chrome.networkingPrivate.getProperties( |
| + "stub_wifi2", |
| + function(result) { |
| + chrome.test.assertTrue(!!result); |
| + chrome.test.assertTrue(!chrome.runtime.lastError); |
| + console.log("GetProperties: " + JSON.stringify(result)); |
| + chrome.test.assertEq("wifi2_PSK", result.Name); |
| + chrome.test.assertEq("NotConnected", result.ConnectionState); |
| + chrome.test.assertEq("WiFi", result.Type); |
| + chrome.test.succeed(); |
| + }); |
| + }, |
| + function requestConnect() { |
| + chrome.networkingPrivate.requestConnect( |
| + "stub_wifi2", |
| + function() { |
| + chrome.test.assertTrue(!chrome.runtime.lastError); |
| + chrome.test.succeed(); |
| + }); |
| + }, |
| + function requestDisconnect() { |
| + chrome.networkingPrivate.requestDisconnect( |
| + "stub_wifi2", |
| + function() { |
| + chrome.test.assertTrue(!chrome.runtime.lastError); |
| + chrome.test.succeed(); |
| + }); |
| + }, |
| + function requestConnectNonexistent() { |
| + chrome.networkingPrivate.requestConnect( |
| + "nonexistent_path", |
| + function() { |
| + // Make sure we get an error when we try to connect to a nonexistent |
| + // network. |
| + chrome.test.assertTrue(!!chrome.runtime.lastError); |
| + chrome.test.assertTrue(!!chrome.runtime.lastError.message); |
| + chrome.test.assertEq("Error.InvalidService", |
| + 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.
|
| + chrome.test.succeed(); |
| + }); |
| + } |
| +]); |