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

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

Issue 1978203002: Translate: Remove the legacy pref 'translate_language_blacklist' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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_prefs.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_prefs_unittest.cc
diff --git a/components/translate/core/browser/translate_prefs_unittest.cc b/components/translate/core/browser/translate_prefs_unittest.cc
index 2f941921cdc42d24554b5ec6056108c34f4ceb90..881718d92d8e193fe97b1931146b68d3ed47de57 100644
--- a/components/translate/core/browser/translate_prefs_unittest.cc
+++ b/components/translate/core/browser/translate_prefs_unittest.cc
@@ -24,107 +24,6 @@ const char kTestLanguage[] = "en";
namespace translate {
-TEST(TranslatePrefsTest, CreateBlockedLanguages) {
- TranslateDownloadManager::GetInstance()->set_application_locale("en");
- std::vector<std::string> blacklisted_languages;
- blacklisted_languages.push_back("en");
- blacklisted_languages.push_back("fr");
- // Hebrew: synonym to 'he'
- blacklisted_languages.push_back("iw");
- // Haitian is not used as Accept-Language
- blacklisted_languages.push_back("ht");
-
- std::vector<std::string> accept_languages;
- accept_languages.push_back("en");
- // The subcode (IT) will be ignored when merging, except for Chinese.
- accept_languages.push_back("it-IT");
- accept_languages.push_back("ja");
- // Filippino: synonym to 'tl'
- accept_languages.push_back("fil");
- // General Chinese is not used as Translate language, but not filtered
- // when merging.
- accept_languages.push_back("zh");
- // Chinese with a sub code is acceptable for the blocked-language list.
- accept_languages.push_back("zh-TW");
-
- std::vector<std::string> blocked_languages;
-
- TranslatePrefs::CreateBlockedLanguages(
- &blocked_languages, blacklisted_languages, accept_languages);
-
- // The order of the elements cannot be determined.
- std::vector<std::string> expected;
- expected.push_back("en");
- expected.push_back("fr");
- expected.push_back("iw");
- expected.push_back("ht");
- expected.push_back("it");
- expected.push_back("ja");
- expected.push_back("tl");
- expected.push_back("zh");
- expected.push_back("zh-TW");
-
- EXPECT_EQ(expected.size(), blocked_languages.size());
- for (std::vector<std::string>::const_iterator it = expected.begin();
- it != expected.end(); ++it) {
- EXPECT_NE(blocked_languages.end(), std::find(blocked_languages.begin(),
- blocked_languages.end(), *it));
- }
-}
-
-TEST(TranslatePrefsTest, CreateBlockedLanguagesNonEnglishUI) {
- std::vector<std::string> blacklisted_languages;
- blacklisted_languages.push_back("fr");
-
- std::vector<std::string> accept_languages;
- accept_languages.push_back("en");
- accept_languages.push_back("ja");
- accept_languages.push_back("zh");
-
- // Run in an English locale.
- {
- TranslateDownloadManager::GetInstance()->set_application_locale("en");
- std::vector<std::string> blocked_languages;
- TranslatePrefs::CreateBlockedLanguages(
- &blocked_languages, blacklisted_languages, accept_languages);
- std::vector<std::string> expected;
- expected.push_back("en");
- expected.push_back("fr");
- expected.push_back("ja");
- expected.push_back("zh");
-
- EXPECT_EQ(expected.size(), blocked_languages.size());
- for (std::vector<std::string>::const_iterator it = expected.begin();
- it != expected.end(); ++it) {
- EXPECT_NE(
- blocked_languages.end(),
- std::find(blocked_languages.begin(), blocked_languages.end(), *it));
- }
- }
-
- // Run in a Japanese locale.
- // English should not be included in the result even though Accept Languages
- // has English because the UI is not English.
- {
- TranslateDownloadManager::GetInstance()->set_application_locale("ja");
- std::vector<std::string> blocked_languages;
- TranslatePrefs::CreateBlockedLanguages(
- &blocked_languages, blacklisted_languages, accept_languages);
- std::vector<std::string> expected;
- expected.push_back("fr");
- expected.push_back("ja");
- expected.push_back("zh");
-
- EXPECT_EQ(expected.size(), blocked_languages.size());
- for (std::vector<std::string>::const_iterator it = expected.begin();
- it != expected.end(); ++it) {
- EXPECT_NE(
- blocked_languages.end(),
- std::find(blocked_languages.begin(), blocked_languages.end(), *it));
- }
- }
-}
-
class TranslatePrefTest : public testing::Test {
protected:
TranslatePrefTest() : prefs_(new user_prefs::TestingPrefServiceSyncable()) {
« no previous file with comments | « components/translate/core/browser/translate_prefs.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698