New issue
Advanced search Search tips

Issue 882770 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Task



Sign in to add a comment

chromeos::DelayNetworkCall doesn't work in tests

Project Member Reported by treib@chromium.org, Sep 11

Issue description

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.
 
Labels: Enterprise-Triaged

Sign in to add a comment