Merge "Improve error message when testing network factory"

This commit is contained in:
Treehugger Robot
2021-01-12 03:50:30 +00:00
committed by Gerrit Code Review

View File

@@ -3624,6 +3624,8 @@ public class ConnectivityServiceTest {
// Register the factory and expect it to start looking for a network. // Register the factory and expect it to start looking for a network.
testFactory.expectAddRequestsWithScores(0); // Score 0 as the request is not served yet. testFactory.expectAddRequestsWithScores(0); // Score 0 as the request is not served yet.
testFactory.register(); testFactory.register();
try {
testFactory.waitForNetworkRequests(1); testFactory.waitForNetworkRequests(1);
assertTrue(testFactory.getMyStartRequested()); assertTrue(testFactory.getMyStartRequested());
@@ -3650,7 +3652,8 @@ public class ConnectivityServiceTest {
mCellNetworkAgent.connect(true); mCellNetworkAgent.connect(true);
cellNetworkCallback.expectAvailableThenValidatedCallbacks(mCellNetworkAgent); cellNetworkCallback.expectAvailableThenValidatedCallbacks(mCellNetworkAgent);
testFactory.waitForNetworkRequests(2); testFactory.waitForNetworkRequests(2);
assertFalse(testFactory.getMyStartRequested()); // Because the cell network outscores us. assertFalse(
testFactory.getMyStartRequested()); // Because the cell network outscores us.
// Check that cell data stays up. // Check that cell data stays up.
waitForIdle(); waitForIdle();
@@ -3665,11 +3668,12 @@ public class ConnectivityServiceTest {
// ... and cell data to be torn down. // ... and cell data to be torn down.
cellNetworkCallback.expectCallback(CallbackEntry.LOST, mCellNetworkAgent); cellNetworkCallback.expectCallback(CallbackEntry.LOST, mCellNetworkAgent);
assertLength(1, mCm.getAllNetworks()); assertLength(1, mCm.getAllNetworks());
} finally {
testFactory.terminate(); testFactory.terminate();
mCm.unregisterNetworkCallback(cellNetworkCallback); mCm.unregisterNetworkCallback(cellNetworkCallback);
handlerThread.quit(); handlerThread.quit();
} }
}
@Test @Test
public void testAvoidBadWifiSetting() throws Exception { public void testAvoidBadWifiSetting() throws Exception {