Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: components/translate/core/browser/translate_manager_unittest.cc

Issue 2822383002: check network connectivity in onPageTranslated callback. (Closed)
Patch Set: add unit tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/translate/core/browser/translate_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/translate/core/browser/translate_manager_unittest.cc
diff --git a/components/translate/core/browser/translate_manager_unittest.cc b/components/translate/core/browser/translate_manager_unittest.cc
index 043e036075e89367fc17ce6bfdb3ce542bd8e6f8..fc5515f93f9cf7cd4741e4a531709f20c09545fc 100644
--- a/components/translate/core/browser/translate_manager_unittest.cc
+++ b/components/translate/core/browser/translate_manager_unittest.cc
@@ -368,6 +368,21 @@ TEST_F(TranslateManagerTest, DontTranslateOffline) {
1);
}
+TEST_F(TranslateManagerTest, DontTranslateIfOfflineBeforeTranslate) {
+ TranslateManager::SetIgnoreMissingKeyForTesting(true);
+ translate_manager_.reset(new translate::TranslateManager(
+ &mock_translate_client_, &mock_translate_ranker_, kAcceptLanguages));
+ translate_manager_->GetLanguageState().LanguageDetermined("de", true);
+ translate_manager_->InitiateTranslation("de");
+
+ // Trigger translate page.
+ network_notifier_.SimulateOffline();
+ translate_manager_->TranslatePage("de", "en", false);
+
+ // Don't expect calls if network is off.
+ EXPECT_FALSE(driver_.TranslatePage_is_called());
+}
+
// Utility function to set the threshold params
void ChangeThresholdInParams(
const char* initiate_translation_confidence_threshold,
« no previous file with comments | « components/translate/core/browser/translate_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698