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

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

Issue 2650003004: Don't offer to translate between Simplified and Traditional Chinese (Closed)
Patch Set: Updates comments Created 3 years, 11 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 fda38d798ab21257c32a8274876b62fa875d7958..270db7b8dc4ffb4322e5df41657ef2f96dd7d25c 100644
--- a/components/translate/core/browser/translate_manager_unittest.cc
+++ b/components/translate/core/browser/translate_manager_unittest.cc
@@ -307,6 +307,72 @@ TEST_F(TranslateManagerTest, DontTranslateOffline) {
1);
}
+// The test measures that Translate is not triggered for a zh-TW page for a
+// zh-CN user.
+TEST_F(TranslateManagerTest,
+ DontTranslateZhTraditionalPageForZhSimplifiedLocale) {
+ TranslateManager::SetIgnoreMissingKeyForTesting(true);
+ translate_manager_.reset(new translate::TranslateManager(
+ &mock_translate_client_, kAcceptLanguages));
+
+ const char kMetricName[] = "Translate.InitiationStatus.v2";
+ base::HistogramTester histogram_tester;
+
+ prefs_.SetBoolean(prefs::kEnableTranslate, false);
groby-ooo-7-16 2017/01/25 01:52:07 I'm surprised the tests work for translate being d
+
+ const std::string locale = "zh-TW";
+ const std::string page_lang = "zh-CN";
+ manager_->set_application_locale(locale);
+ translate_manager_->GetLanguageState().LanguageDetermined(page_lang, true);
+
+ // In the offline case, Initiate will early-out before even hitting the API
groby-ooo-7-16 2017/01/25 01:52:07 Might want to fix the comment :)
+ // key test.
+ network_notifier_.SimulateOffline();
groby-ooo-7-16 2017/01/25 01:52:07 And remove SimulateOffline
+ translate_manager_->InitiateTranslation(page_lang);
+ histogram_tester.ExpectTotalCount(kMetricName, 0);
+
+ // In the online case, InitiateTranslation will proceed past early out tests.
+ network_notifier_.SimulateOnline();
groby-ooo-7-16 2017/01/25 01:52:07 See above
+ translate_manager_->InitiateTranslation(page_lang);
+ histogram_tester.ExpectUniqueSample(
+ kMetricName,
+ translate::TranslateBrowserMetrics::INITIATION_STATUS_SIMILAR_LANGUAGES,
+ 1);
+}
+
+// The test measures that Translate is not triggered for a zh-CN page for a
+// zh-TW user.
+TEST_F(TranslateManagerTest,
+ DontTranslateZhSimplifiedPageForZhTraditionalLocale) {
+ TranslateManager::SetIgnoreMissingKeyForTesting(true);
+ translate_manager_.reset(new translate::TranslateManager(
+ &mock_translate_client_, kAcceptLanguages));
+
+ const char kMetricName[] = "Translate.InitiationStatus.v2";
+ base::HistogramTester histogram_tester;
+
+ prefs_.SetBoolean(prefs::kEnableTranslate, false);
+
+ const std::string locale = "zh-CN";
+ const std::string page_lang = "zh-TW";
+ manager_->set_application_locale(locale);
+ translate_manager_->GetLanguageState().LanguageDetermined(page_lang, true);
+
+ // In the offline case, Initiate will early-out before even hitting the API
+ // key test.
groby-ooo-7-16 2017/01/25 01:52:07 See previous test
+ network_notifier_.SimulateOffline();
+ translate_manager_->InitiateTranslation(page_lang);
+ histogram_tester.ExpectTotalCount(kMetricName, 0);
+
+ // In the online case, InitiateTranslation will proceed past early out tests.
+ network_notifier_.SimulateOnline();
+ translate_manager_->InitiateTranslation(page_lang);
+ histogram_tester.ExpectUniqueSample(
+ kMetricName,
+ translate::TranslateBrowserMetrics::INITIATION_STATUS_SIMILAR_LANGUAGES,
+ 1);
+}
+
// 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