chromeos::DelayNetworkCall is supposed to delay network calls until we actually have a network available, and are not behind a captive portal. During browser tests, the captive portal detection always returns "true", so all network requests coming through this code path get delayed forever. This happens before Test/FakeURLFetcher etc have a chance to respond to the request.
As a consequence, tests have to go through quite a dance to bypass the captive portal detection; something like this:
void InitNetwork() {
auto* portal_detector = new chromeos::NetworkPortalDetectorTestImpl();
const chromeos::NetworkState* default_network =
chromeos::NetworkHandler::Get()
->network_state_handler()
->DefaultNetwork();
portal_detector->SetDefaultNetworkForTesting(default_network->guid());
chromeos::NetworkPortalDetector::CaptivePortalState online_state;
online_state.status =
chromeos::NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE;
online_state.response_code = 204;
portal_detector->SetDetectionResultsForTesting(default_network->guid(),
online_state);
// Takes ownership.
chromeos::network_portal_detector::InitializeForTesting(portal_detector);
}
It'd be nice if this setup would happen automatically, or if there were at least a common helper function that does the above.
Comment 1 by marcuskoehler@chromium.org
, Jan 15