Don't check broadcast intent on connection status check

testRequestNetworkCallback_onUnavailable is flaky because
the test expects a connectivity broadcast to be sent for the
lost network. But after testSetAirplaneMode, the wifi network
is not yet default network so a broadcast is never sent but
only onUnavailable is triggered. Replace disconnectFromWifi
with ensureWifiDisconnected to skip checking the broadcast.

Bug: 162323152
Test: atest CtsNetTestCasesLatestSdk:ConnectivityManagerTest\
      --rerun-until-failure 20
Change-Id: I88f434798ec83539df9cc6a81446ca37a0081e3b
This commit is contained in:
Chiachang Wang
2020-09-24 14:44:32 +08:00
parent 17ee20dc59
commit 8ff9c262ca

View File

@@ -607,7 +607,7 @@ public class ConnectivityManagerTest {
public void testRequestNetworkCallback_onUnavailable() {
final boolean previousWifiEnabledState = mWifiManager.isWifiEnabled();
if (previousWifiEnabledState) {
mCtsNetUtils.disconnectFromWifi(null);
mCtsNetUtils.ensureWifiDisconnected(null);
}
final TestNetworkCallback callback = new TestNetworkCallback();