Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69d504b5 authored by Hai Shalom's avatar Hai Shalom
Browse files

[WPA3/DPP] Add unit tests for WPA3, OWE and DPP feature support APIs

Add unit tests to verify feature support public APIs:
isEnhancedOpenSupported
isWpa3SaeSupported
isWpa3SuiteBSupported
isEasyConnectSupported

Test: atest WifiManagerTest
Bug: 129543813
Change-Id: I3a3b0a7a40d36a377c59e16450fe68b43f012177
parent 3111cff3
Loading
Loading
Loading
Loading
+56 −0
Original line number Original line Diff line number Diff line
@@ -1382,4 +1382,60 @@ i * Verify that a call to cancel WPS immediately returns a failure.
            r.run();
            r.run();
        }
        }
    }
    }

    /**
     * Test behavior of isEnhancedOpenSupported
     * @throws Exception
     */
    @Test
    public void testIsEnhancedOpenSupported() throws Exception {
        when(mWifiService.getSupportedFeatures())
                .thenReturn(new Long(WifiManager.WIFI_FEATURE_OWE));
        assertTrue(mWifiManager.isEnhancedOpenSupported());
        when(mWifiService.getSupportedFeatures())
                .thenReturn(new Long(~WifiManager.WIFI_FEATURE_OWE));
        assertFalse(mWifiManager.isEnhancedOpenSupported());
    }

    /**
     * Test behavior of isWpa3SaeSupported
     * @throws Exception
     */
    @Test
    public void testIsWpa3SaeSupported() throws Exception {
        when(mWifiService.getSupportedFeatures())
                .thenReturn(new Long(WifiManager.WIFI_FEATURE_WPA3_SAE));
        assertTrue(mWifiManager.isWpa3SaeSupported());
        when(mWifiService.getSupportedFeatures())
                .thenReturn(new Long(~WifiManager.WIFI_FEATURE_WPA3_SAE));
        assertFalse(mWifiManager.isWpa3SaeSupported());
    }

    /**
     * Test behavior of isWpa3SuiteBSupported
     * @throws Exception
     */
    @Test
    public void testIsWpa3SuiteBSupported() throws Exception {
        when(mWifiService.getSupportedFeatures())
                .thenReturn(new Long(WifiManager.WIFI_FEATURE_WPA3_SUITE_B));
        assertTrue(mWifiManager.isWpa3SuiteBSupported());
        when(mWifiService.getSupportedFeatures())
                .thenReturn(new Long(~WifiManager.WIFI_FEATURE_WPA3_SUITE_B));
        assertFalse(mWifiManager.isWpa3SuiteBSupported());
    }

    /**
     * Test behavior of isEasyConnectSupported
     * @throws Exception
     */
    @Test
    public void testIsEasyConnectSupported() throws Exception {
        when(mWifiService.getSupportedFeatures())
                .thenReturn(new Long(WifiManager.WIFI_FEATURE_DPP));
        assertTrue(mWifiManager.isEasyConnectSupported());
        when(mWifiService.getSupportedFeatures())
                .thenReturn(new Long(~WifiManager.WIFI_FEATURE_DPP));
        assertFalse(mWifiManager.isEasyConnectSupported());
    }
}
}