diff options
author | Roshan Pius <rpius@google.com> | 2017-03-22 11:15:50 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2017-03-27 10:15:21 -0700 |
commit | 7adcbd6f7b0baef1e4186376b0b43789303856cf (patch) | |
tree | ed330d3dbd11c6109c7bf5176cba94f2262e6f0d /tests | |
parent | cdd56a55709407c9efe2a24b4ed25666e2e8318e (diff) |
Add try/catch blocks for incoming HAL params
Add try/catch blocks for handling exceptions raised during handling
incoming params to the HAL calling code.
While there,
Rename SupplicantStaIfaceHal.addNetwork to
SupplicantStaIfaceHal.addNetworkAndSaveConfig
Bug: 36510794
Bug: 36510113
Test: Compiles & able to connect to wifi networks
Change-Id: Idc52d6ea63c4c23e9a3c8f12827f7b6ef1ea07b8
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java index abf533d1f..8a2ceaf08 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java @@ -501,6 +501,24 @@ public class SupplicantStaIfaceHalTest { } /** + * Tests connection to a specified network failure due to exception in network save. + */ + @Test + public void testConnectFailureDueToNetworkSaveException() throws Exception { + executeAndValidateInitializationSequence(); + setupMocksForConnectSequence(true); + + doThrow(new IllegalArgumentException("Some error!!!")) + .when(mSupplicantStaNetworkMock).saveWifiConfiguration( + any(WifiConfiguration.class)); + + assertFalse(mDut.connectToNetwork(new WifiConfiguration(), false)); + // We should have removed the existing network once before connection and once more + // on failure to save network configuration. + verify(mISupplicantStaIfaceMock, times(2)).removeNetwork(anyInt()); + } + + /** * Tests connection to a specified network failure due to network select. */ @Test |