CtsNetTests: Fix WifiInfoTest

According to the public documentation of WifiInfo.getSSID(), the
returned value can be one of the following:
1. Hex digits if the SSID cannot be decoded as UTF-8.
2. String surrounded by double quotes if the SSID can be decoded as
UTF-8.
3. <unknown ssid>, if not connected.

Fix the test to check for all these 3 string values.

BUG: 31272462
TEST: The failing CTS test passes now.
Change-Id: I26e12d28994e3cdb4cd1bd9e999633b327ad5830
This commit is contained in:
Roshan Pius
2016-09-07 08:56:45 -07:00
parent 83bddfd9ec
commit f1bb48635d

View File

@@ -26,6 +26,7 @@ import android.net.wifi.SupplicantState;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiManager.WifiLock;
import android.net.wifi.WifiSsid;
import android.test.AndroidTestCase;
import java.util.concurrent.Callable;
@@ -123,7 +124,7 @@ public class WifiInfoTest extends AndroidTestCase {
SupplicantState.isValidState(wifiInfo.getSupplicantState());
WifiInfo.getDetailedStateOf(SupplicantState.DISCONNECTED);
String ssid = wifiInfo.getSSID();
if (ssid.startsWith("0x") == false) {
if (!ssid.startsWith("0x") && !ssid.equals(WifiSsid.NONE)) {
// Non-hex string should be quoted
assertTrue(ssid.charAt(0) == '"');
assertTrue(ssid.charAt(ssid.length() - 1) == '"');