Merge "onConnectedChanged should not update access points"
This commit is contained in:
committed by
Android (Google) Code Review
commit
65e557754e
@@ -737,12 +737,10 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the connection state of wifi has changed and isConnected
|
* Called when the connection state of wifi has changed.
|
||||||
* should be called to get the updated state.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onConnectedChanged() {
|
public void onConnectedChanged() {
|
||||||
updateAccessPointsDelayed();
|
|
||||||
changeNextButtonState(mWifiTracker.isConnected());
|
changeNextButtonState(mWifiTracker.isConnected());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,6 +31,7 @@ import static org.hamcrest.Matchers.allOf;
|
|||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
import static org.hamcrest.Matchers.startsWith;
|
import static org.hamcrest.Matchers.startsWith;
|
||||||
import static org.mockito.Mockito.atMost;
|
import static org.mockito.Mockito.atMost;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -359,4 +360,23 @@ public class WifiSettingsUiTest {
|
|||||||
onView(withId(resourceId(ID, PASSWORD_LAYOUT))).check(matches(isDisplayed()));
|
onView(withId(resourceId(ID, PASSWORD_LAYOUT))).check(matches(isDisplayed()));
|
||||||
onView(withId(resourceId(ID, PASSWORD))).check(matches(isDisplayed()));
|
onView(withId(resourceId(ID, PASSWORD))).check(matches(isDisplayed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onConnectedChanged_shouldNotFetchAPs() {
|
||||||
|
setWifiState(WifiManager.WIFI_STATE_ENABLED);
|
||||||
|
when(mWifiTracker.isConnected()).thenReturn(true);
|
||||||
|
|
||||||
|
launchActivity();
|
||||||
|
|
||||||
|
verify(mWifiTracker, atMost(1)).forceUpdate();
|
||||||
|
verify(mWifiTracker, times(1)).getAccessPoints();
|
||||||
|
onView(withText(WIFI_DISPLAY_STATUS_CONNECTED)).check(matches(isDisplayed()));
|
||||||
|
|
||||||
|
// Invoke onConnectedChanged
|
||||||
|
when(mWifiTracker.isConnected()).thenReturn(false);
|
||||||
|
mWifiListener.onConnectedChanged();
|
||||||
|
|
||||||
|
// Verify no additional call to getAccessPoints
|
||||||
|
getInstrumentation().waitForIdleSync();
|
||||||
|
verify(mWifiTracker, times(1)).getAccessPoints();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user