#include "components/translate/core/browser/translate_prefs.h"
#include <algorithm>
#include <limits>
#include <string>
#include <utility>
#include <vector>
#include "base/json/json_reader.h"
#include "base/json/values_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_timeouts.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/language/core/browser/language_prefs.h"
#include "components/language/core/browser/language_prefs_test_util.h"
#include "components/language/core/browser/pref_names.h"
#include "components/language/core/common/language_experiments.h"
#include "components/prefs/mock_pref_change_callback.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/translate/core/browser/translate_download_manager.h"
#include "components/translate/core/browser/translate_pref_names.h"
#include "components/translate/core/common/translate_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_collator.h"
namespace translate {
namespace {
ElementsAre;
ElementsAreArray;
IsEmpty;
UnorderedElementsAreArray;
static void ExpectEqualLanguageLists(
const base::Value::List& language_values,
const std::vector<std::string>& languages) { … }
}
class TranslatePrefsTest : public testing::Test { … };
TEST_F(TranslatePrefsTest, GetLanguageInfoListCorrectLocale) { … }
TEST_F(TranslatePrefsTest, GetLanguageInfoListOutput) { … }
TEST_F(TranslatePrefsTest, GetLanguageInfoList) { … }
TEST_F(TranslatePrefsTest, GetTranslatableContentLanguagesCorrectLocale) { … }
TEST_F(TranslatePrefsTest, BlockLanguage) { … }
TEST_F(TranslatePrefsTest, UnblockLanguage) { … }
TEST_F(TranslatePrefsTest, ResetEmptyBlockedLanguagesToDefaultTest) { … }
TEST_F(TranslatePrefsTest, GetNeverTranslateLanguagesTest) { … }
TEST_F(TranslatePrefsTest, AddToLanguageList) { … }
TEST_F(TranslatePrefsTest, RemoveFromLanguageList) { … }
TEST_F(TranslatePrefsTest, RemoveFromLanguageListRemovesRemainingUnsupported) { … }
TEST_F(TranslatePrefsTest, RemoveFromLanguageListClearsRecentLanguage) { … }
TEST_F(TranslatePrefsTest, MoveLanguageToTheTop) { … }
TEST_F(TranslatePrefsTest, MoveLanguageUp) { … }
TEST_F(TranslatePrefsTest, MoveLanguageDown) { … }
TEST_F(TranslatePrefsTest, MigrateNeverPromptSites) { … }
TEST_F(TranslatePrefsTest, InvalidNeverPromptSites) { … }
TEST_F(TranslatePrefsTest, MigrateInvalidNeverPromptSites) { … }
TEST_F(TranslatePrefsTest, ShouldNotifyUponMigrateNeverPromptSites) { … }
TEST_F(TranslatePrefsTest,
ShouldNotifyUponMigrateNeverPromptSitesForNonEmptyInitialValue) { … }
TEST_F(TranslatePrefsTest, ShouldNotNotifyUponMigrateInvalidNeverPromptSites) { … }
TEST_F(TranslatePrefsTest, ShouldNotNotifyUponMigrateNoNeverPromptSites) { … }
TEST_F(TranslatePrefsTest, SiteNeverPromptList) { … }
TEST_F(TranslatePrefsTest, DefaultBlockedLanguages) { … }
TEST_F(TranslatePrefsTest, SetRecentTargetLanguage) { … }
TEST_F(TranslatePrefsTest, AlwaysTranslateLanguages) { … }
TEST_F(TranslatePrefsTest, NeverOnAlwaysAndNever) { … }
TEST_F(TranslatePrefsTest, CanTranslateLanguage) { … }
TEST_F(TranslatePrefsTest, ForceTriggerOnEnglishPagesCount) { … }
class TranslatePrefsMigrationTest : public testing::Test { … };
TEST_F(TranslatePrefsMigrationTest,
MigrateObsoleteAlwaysTranslateLanguagesPref_Disabled) { … }
TEST_F(TranslatePrefsMigrationTest,
MigrateObsoleteAlwaysTranslateLanguagesPref_Enabled) { … }
}