Merge "wifi direct: Close the channel after leaving the Setting page" into sc-dev am: c48cf5ee37 am: 0c4c0e5e33 am: 54ef94eded

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/14786728

Change-Id: Ifaabf8fe1cefdc7a617a4590fd2aa8f8c3bf969a
This commit is contained in:
Les Lee
2021-06-03 15:08:06 +00:00
committed by Automerger Merge Worker
2 changed files with 63 additions and 29 deletions

View File

@@ -322,6 +322,18 @@ public class WifiP2pSettingsTest {
mFragment.onPause();
verify(mWifiP2pManager, times(1)).stopPeerDiscovery(any(), any());
assertThat(mFragment.mChannel).isNull();
}
@Test
public void peerDiscovery_whenOnResume_shouldInitChannelAgain() {
mFragment.onPause();
verify(mWifiP2pManager, times(1)).stopPeerDiscovery(any(), any());
assertThat(mFragment.mChannel).isNull();
mFragment.onResume();
assertThat(mFragment.mChannel).isNotNull();
}
@Test
@@ -492,6 +504,7 @@ public class WifiP2pSettingsTest {
@Test
public void onActivityCreate_withNullP2pManager_shouldGetP2pManagerAgain() {
mFragment.mChannel = null; // Reset channel to re-test onActivityCreated flow
mFragment.mWifiP2pManager = null;
mFragment.onActivityCreated(new Bundle());
@@ -502,7 +515,7 @@ public class WifiP2pSettingsTest {
@Test
public void onActivityCreate_withNullChannel_shouldSetP2pManagerNull() {
doReturn(null).when(mWifiP2pManager).initialize(any(), any(), any());
mFragment.mChannel = null; // Reset channel to re-test onActivityCreated flow
mFragment.onActivityCreated(new Bundle());
assertThat(mFragment.mWifiP2pManager).isNull();