New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 732821 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Last visit > 30 days ago
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: iOS
Pri: 3
Type: Bug



Sign in to add a comment

translate_manager.cc check for network connectivity is hurting iOS testing

Project Member Reported by sdefresne@chromium.org, Jun 13 2017

Issue description

When testing the translation feature on iOS, the code takes care of using command-line flags to configure an URL that does not hit the network (it is intercepted by a local in-memory server). See ios/chrome/browser/translate/translate_egtest.mm. This should ensure that the test pass even if the network is flaky since no network connection is used.

However TranslateManager checks whether the network is up and aborts if it is not as can be seen at [1]. Code copied below:

[1]: https://cs.chromium.org/chromium/src/components/translate/core/browser/translate_manager.cc?q=net::NetworkChangeNotifier::IsOffline+translate_manager.cc&sq=package:chromium&l=165

void TranslateManager::InitiateTranslation(const std::string& page_lang) {
  // TODO(rogerm): Remove ScopedTracker below once crbug.com/646711 is closed.
  tracked_objects::ScopedTracker tracking_profile(
      FROM_HERE_WITH_EXPLICIT_FUNCTION(
          "646711 translate::TranslateManager::InitiateTranslation"));

  // Short-circuit out if not in a state where initiating translation makes
  // sense (this method may be called muhtiple times for a given page).
  if (!language_state_.page_needs_translation() ||
      language_state_.translation_pending() ||
      language_state_.translation_declined() ||
      language_state_.IsPageTranslated()) {
    return;
  }

  // Also, skip if the connection is currently offline - initiation doesn't make
  // sense there, either.
  if (net::NetworkChangeNotifier::IsOffline())
    return;

This prevents running the tests on iOS on device. For devices the network is flaky (and the flakyness is more or less outside of our control since there are no way to have the device use a wired connection). Disabling the NetworkChangeNotifier using NetworkChangeNotifier::DisableForTest is not possible as the EarlGrey tests are integration tests and NetworkChangeNotifier is a global for the whole process (and documentation explicitly says it is not thread-safe to change the global).

Currently, this mean we can only run the translate integration tests on private downstream bots on iOS, increasing the friction of development.

Can we add a configuration option to TranslateManager (maybe another command-line flag, but could also be a simple boolean in the class) to disable this check and attempt the network connection even if the network is down?

groby/andrewhayden/droger/hajimehosi/toyoshim: WDYT as OWNERS of components/translate? I can volunteer to add the configuration hook if we agree we want one.
 

Comment 1 by droger@chromium.org, Jun 13 2017

I don't see a reason to object.

A random idea: could we disable the offline test if translate::switches::kTranslateScriptURL points to a local URL (i.e. localhost...)
Agreed.

I like droger's idea that does not need a new flag.
Thank you. I'll take a look at implementing this.
Components: UI>Browser>Translate
Sylvain, could you please update Component when you assigning the bug. Thanks!
Components: -UI>Browser>Translate UI>Browser>Language>Translate
Labels: Hotlist-TranslateiOS
Owner: ----
Status: Available (was: Assigned)
Owner: ghendel@chromium.org
Status: Assigned (was: Available)
Bulk assigning iOS-specific Translate bugs to ghendel@ for triage as per our discussion.

Sign in to add a comment