From cdc077c9dd6473b5abfad4edfaf1ff41a436caaf Mon Sep 17 00:00:00 2001 From: Irfan Sheriff Date: Sun, 11 Dec 2011 22:33:31 -0800 Subject: Fix configured network status For a connected network, keep status as CURRENT. For a network, that is disconnected it should be ENABLED. A disabled network will have the status as DISABLED Also, add a unit test to ensure there is only one CURRENT network that is connected Change-Id: Iaa4a7124a0c372a8f6df3d846ae8c15d9b29cf13 --- .../unit/WifiClientTest.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'core/tests/ConnectivityManagerTest') diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/unit/WifiClientTest.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/unit/WifiClientTest.java index e22b018..e44023b 100644 --- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/unit/WifiClientTest.java +++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/unit/WifiClientTest.java @@ -271,4 +271,46 @@ public class WifiClientTest extends AndroidTestCase { } + // Test case 6: test configured network status + @LargeTest + public void testWifiConfiguredNetworkStatus() { + + /* Initialize */ + mWifiManager.setWifiEnabled(false); + sleepAfterWifiEnable(); + + /* Ensure no network is CURRENT */ + List configList = mWifiManager.getConfiguredNetworks(); + for (WifiConfiguration c : configList) { + assertTrue(c.status != WifiConfiguration.Status.CURRENT); + } + + /* Enable wifi */ + mWifiManager.setWifiEnabled(true); + sleepAfterWifiEnable(); + + /* Ensure connected network is CURRENT */ + String connectedSSID = mWifiManager.getConnectionInfo().getSSID(); + configList = mWifiManager.getConfiguredNetworks(); + for (WifiConfiguration c : configList) { + if (c.SSID.contains(connectedSSID)) { + assertTrue(c.status == WifiConfiguration.Status.CURRENT); + } else { + assertTrue(c.status != WifiConfiguration.Status.CURRENT); + } + } + + /* Disable wifi */ + mWifiManager.setWifiEnabled(false); + sleepAfterWifiEnable(); + + /* Ensure no network is CURRENT */ + configList = mWifiManager.getConfiguredNetworks(); + for (WifiConfiguration c : configList) { + assertTrue(c.status != WifiConfiguration.Status.CURRENT); + } + } + + + } -- cgit v1.1