translate_manager.cc check for network connectivity is hurting iOS testing |
||||||
Issue descriptionWhen 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.
,
Jun 16 2017
Agreed. I like droger's idea that does not need a new flag.
,
Jun 19 2017
Thank you. I'll take a look at implementing this.
,
Jul 6 2017
Sylvain, could you please update Component when you assigning the bug. Thanks!
,
Aug 17 2017
,
Jan 18 2018
,
Jun 11 2018
,
Oct 29
Bulk assigning iOS-specific Translate bugs to ghendel@ for triage as per our discussion. |
||||||
►
Sign in to add a comment |
||||||
Comment 1 by droger@chromium.org
, Jun 13 2017