[Wi-Fi] Enhance AddAppNetworksFragment unit test cases

Add new unit test cases in AddAppNetworksFragmentTest.java

The coverage rate of com.android.settings.wifi.addappnetworks will raise from 65% to 81%

Bug: 151696220
Test: make RunSettingsRoboTests ROBOTEST_FILTER=AddAppNetworksFragmentTest
Change-Id: Iae15b5ad27b20f90cbf8b0318a24a9069b738a33
This commit is contained in:
govenliu
2020-05-15 15:59:18 +08:00
parent 2c8448e927
commit 23d91663f6
2 changed files with 203 additions and 17 deletions

View File

@@ -86,9 +86,9 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
static final int RESULT_NETWORK_ALREADY_EXISTS = 2;
// Handler messages for controlling different state and delay showing the status message.
private static final int MESSAGE_START_SAVING_NETWORK = 1;
private static final int MESSAGE_SHOW_SAVED_AND_CONNECT_NETWORK = 2;
private static final int MESSAGE_SHOW_SAVE_FAILED = 3;
@VisibleForTesting static final int MESSAGE_START_SAVING_NETWORK = 1;
@VisibleForTesting static final int MESSAGE_SHOW_SAVED_AND_CONNECT_NETWORK = 2;
@VisibleForTesting static final int MESSAGE_SHOW_SAVE_FAILED = 3;
private static final int MESSAGE_FINISH = 4;
// Signal level for the initial signal icon.
@@ -137,7 +137,8 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
private WifiManager.ActionListener mSaveListener;
private WifiManager mWifiManager;
private final Handler mHandler = new Handler() {
@VisibleForTesting
final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
showSaveStatusByState(msg.what);
@@ -638,7 +639,8 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
/**
* Call framework API to save single network.
*/
private void saveNetwork(int index) {
@VisibleForTesting
void saveNetwork(int index) {
final PasspointConfiguration passpointConfig =
mUiToRequestedList.get(index).mWifiNetworkSuggestion.getPasspointConfig();
if (passpointConfig != null) {
@@ -689,7 +691,8 @@ public class AddAppNetworksFragment extends InstrumentedFragment implements
return SettingsEnums.PANEL_ADD_WIFI_NETWORKS;
}
private void showSaveStatusByState(int status) {
@VisibleForTesting
void showSaveStatusByState(int status) {
switch (status) {
case MESSAGE_START_SAVING_NETWORK:
if (mIsSingleNetwork) {