OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // The expectations in this test for the Chrome OS implementation. See | 5 // The expectations in this test for the Chrome OS implementation. See |
6 // networking_private_chromeos_apitest.cc for more info. | 6 // networking_private_chromeos_apitest.cc for more info. |
7 | 7 |
8 var callbackPass = chrome.test.callbackPass; | 8 var callbackPass = chrome.test.callbackPass; |
9 var callbackFail = chrome.test.callbackFail; | 9 var callbackFail = chrome.test.callbackFail; |
10 var assertTrue = chrome.test.assertTrue; | 10 var assertTrue = chrome.test.assertTrue; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 var self = this; | 74 var self = this; |
75 this.onPortalDetectionCompleted = function(guid, state) { | 75 this.onPortalDetectionCompleted = function(guid, state) { |
76 assertEq(expectedGuid, guid); | 76 assertEq(expectedGuid, guid); |
77 assertEq(expectedState, state); | 77 assertEq(expectedState, state); |
78 chrome.networkingPrivate.onPortalDetectionCompleted.removeListener( | 78 chrome.networkingPrivate.onPortalDetectionCompleted.removeListener( |
79 self.onPortalDetectionCompleted); | 79 self.onPortalDetectionCompleted); |
80 done(); | 80 done(); |
81 }; | 81 }; |
82 chrome.networkingPrivate.onPortalDetectionCompleted.addListener( | 82 chrome.networkingPrivate.onPortalDetectionCompleted.addListener( |
83 self.onPortalDetectionCompleted); | 83 self.onPortalDetectionCompleted); |
| 84 }, |
| 85 verifyTetherNetwork: function( |
| 86 properties, expectedGuid, expectedName, expectedBatteryPercentage, |
| 87 expectedCarrier, expectedSignalStrength) { |
| 88 //assertEq(NetworkType.Tether, properties.Type); |
| 89 assertEq(expectedGuid, properties.GUID); |
| 90 assertEq(expectedName, |
| 91 properties.Name.hasOwnProperty('Active') ? properties.Name.Active |
| 92 : properties.Name); |
| 93 assertEq(expectedBatteryPercentage, properties.Tether.BatteryPercentage); |
| 94 assertEq(expectedCarrier, properties.Tether.Carrier); |
| 95 assertEq(expectedSignalStrength, properties.Tether.SignalStrength); |
84 } | 96 } |
85 }; | 97 }; |
86 | 98 |
87 var kFailure = 'Failure'; | 99 var kFailure = 'Failure'; |
88 | 100 |
89 function networkCallbackPass() { | 101 function networkCallbackPass() { |
90 var callbackCompleted = chrome.test.callbackAdded(); | 102 var callbackCompleted = chrome.test.callbackAdded(); |
91 return function(result) { | 103 return function(result) { |
92 chrome.test.assertNoLastError(); | 104 chrome.test.assertNoLastError(); |
93 if (result === false || result === kFailure) | 105 if (result === false || result === kFailure) |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 }))); | 928 }))); |
917 }, | 929 }, |
918 function getGlobalPolicy() { | 930 function getGlobalPolicy() { |
919 chrome.networkingPrivate.getGlobalPolicy(callbackPass(function(result) { | 931 chrome.networkingPrivate.getGlobalPolicy(callbackPass(function(result) { |
920 assertEq({ | 932 assertEq({ |
921 AllowOnlyPolicyNetworksToAutoconnect: true, | 933 AllowOnlyPolicyNetworksToAutoconnect: true, |
922 AllowOnlyPolicyNetworksToConnect: false, | 934 AllowOnlyPolicyNetworksToConnect: false, |
923 }, result); | 935 }, result); |
924 })); | 936 })); |
925 }, | 937 }, |
| 938 function getTetherNetworks() { |
| 939 chrome.networkingPrivate.getNetworks( |
| 940 {networkType: 'Tether'}, |
| 941 callbackPass(function(tetherNetworks) { |
| 942 assertEq(2, tetherNetworks.length); |
| 943 privateHelpers.verifyTetherNetwork(tetherNetworks[0], 'tetherGuid1', |
| 944 'tetherName1', 50, 'tetherCarrier1', 75); |
| 945 privateHelpers.verifyTetherNetwork(tetherNetworks[1], 'tetherGuid2', |
| 946 'tetherName2', 75, 'tetherCarrier2', 100); |
| 947 })); |
| 948 }, |
| 949 function getTetherNetworkProperties() { |
| 950 chrome.networkingPrivate.getProperties( |
| 951 'tetherGuid1', |
| 952 callbackPass(function(tetherNetwork) { |
| 953 privateHelpers.verifyTetherNetwork(tetherNetwork, 'tetherGuid1', |
| 954 'tetherName1', 50, 'tetherCarrier1', 75); |
| 955 })); |
| 956 }, |
| 957 function getTetherNetworkManagedProperties() { |
| 958 chrome.networkingPrivate.getManagedProperties( |
| 959 'tetherGuid1', |
| 960 callbackPass(function(tetherNetwork) { |
| 961 privateHelpers.verifyTetherNetwork(tetherNetwork, 'tetherGuid1', |
| 962 'tetherName1', 50, 'tetherCarrier1', 75); |
| 963 })); |
| 964 }, |
| 965 function getTetherNetworkState() { |
| 966 chrome.networkingPrivate.getState( |
| 967 'tetherGuid1', |
| 968 callbackPass(function(tetherNetwork) { |
| 969 privateHelpers.verifyTetherNetwork(tetherNetwork, 'tetherGuid1', |
| 970 'tetherName1', 50, 'tetherCarrier1', 75); |
| 971 })); |
| 972 }, |
926 ]; | 973 ]; |
927 | 974 |
928 chrome.test.getConfig(function(config) { | 975 chrome.test.getConfig(function(config) { |
929 var args = JSON.parse(config.customArg); | 976 var args = JSON.parse(config.customArg); |
930 var tests = availableTests.filter(function(op) { | 977 var tests = availableTests.filter(function(op) { |
931 return args.test == op.name; | 978 return args.test == op.name; |
932 }); | 979 }); |
933 if (tests.length !== 1) { | 980 if (tests.length !== 1) { |
934 chrome.test.notifyFail('Test not found ' + args.test); | 981 chrome.test.notifyFail('Test not found ' + args.test); |
935 return; | 982 return; |
936 } | 983 } |
937 | 984 |
938 chrome.test.runTests(tests); | 985 chrome.test.runTests(tests); |
939 }); | 986 }); |
OLD | NEW |