Fix back arrow in wifi settings "connect to this network connection qr code" does not work
When clicking back button, pop fragment and Finish the activity if there is nothing to pop Bug: 132132756 Test: atest WifiDppConfiguratorActivityTest Change-Id: Ia16951e79e578f1625e5fadd26553735fa90bffa
This commit is contained in:
@@ -323,15 +323,10 @@ public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onNavigateUp() {
|
public boolean onNavigateUp() {
|
||||||
Fragment fragment = mFragmentManager.findFragmentById(R.id.fragment_container);
|
if (!mFragmentManager.popBackStackImmediate()) {
|
||||||
if (fragment instanceof WifiDppQrCodeGeneratorFragment) {
|
|
||||||
finish();
|
finish();
|
||||||
return true;
|
|
||||||
} else if (fragment instanceof WifiDppQrCodeScannerFragment) {
|
|
||||||
mFragmentManager.popBackStackImmediate();
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -175,4 +175,40 @@ public class WifiDppConfiguratorActivityTest {
|
|||||||
assertThat(restoredWifiNetworkConfig.getNetworkId()).isEqualTo(0);
|
assertThat(restoredWifiNetworkConfig.getNetworkId()).isEqualTo(0);
|
||||||
assertThat(restoredWifiNetworkConfig.isHotspot()).isTrue();
|
assertThat(restoredWifiNetworkConfig.isHotspot()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void launchScanner_onNavigateUp_shouldFinish() {
|
||||||
|
Intent intent = new Intent(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
|
||||||
|
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
|
||||||
|
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
|
||||||
|
intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
|
||||||
|
final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||||
|
|
||||||
|
mActivityRule.launchActivity(intent);
|
||||||
|
|
||||||
|
instrumentation.runOnMainSync(() -> {
|
||||||
|
mActivityRule.getActivity().onNavigateUp();
|
||||||
|
|
||||||
|
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void launchGenerator_onNavigateUp_shouldFinish() {
|
||||||
|
Intent intent = new Intent(
|
||||||
|
WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
|
||||||
|
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
|
||||||
|
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
|
||||||
|
intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
|
||||||
|
final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||||
|
|
||||||
|
mActivityRule.launchActivity(intent);
|
||||||
|
|
||||||
|
instrumentation.runOnMainSync(() -> {
|
||||||
|
mActivityRule.getActivity().onNavigateUp();
|
||||||
|
|
||||||
|
assertThat(mActivityRule.getActivity().isFinishing()).isEqualTo(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user