chromium/components/translate/core/browser/translate_manager_unittest.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/translate/core/browser/translate_manager.h"

#include <utility>

#include "base/containers/contains.h"
#include "base/json/json_reader.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/metrics_hashes.h"
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/infobars/core/infobar.h"
#include "components/language/core/browser/accept_languages_service.h"
#include "components/language/core/browser/language_model.h"
#include "components/language/core/browser/language_prefs.h"
#include "components/language/core/common/language_experiments.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/translate/core/browser/mock_translate_client.h"
#include "components/translate/core/browser/mock_translate_driver.h"
#include "components/translate/core/browser/mock_translate_metrics_logger.h"
#include "components/translate/core/browser/mock_translate_ranker.h"
#include "components/translate/core/browser/translate_browser_metrics.h"
#include "components/translate/core/browser/translate_client.h"
#include "components/translate/core/browser/translate_download_manager.h"
#include "components/translate/core/browser/translate_metrics_logger_impl.h"
#include "components/translate/core/browser/translate_pref_names.h"
#include "components/translate/core/browser/translate_prefs.h"
#include "components/translate/core/browser/translate_step.h"
#include "components/translate/core/common/translate_constants.h"
#include "components/translate/core/common/translate_util.h"
#include "components/variations/scoped_variations_ids_provider.h"
#include "components/variations/variations_associated_data.h"
#include "net/base/mock_network_change_notifier.h"
#include "net/base/network_change_notifier.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/metrics_proto/translate_event.pb.h"

_;
Pointee;
Return;
SetArgPointee;

namespace translate {
namespace {

const char kMenuTranslationIsAvailableName[] =;

// Overrides NetworkChangeNotifier, simulating connection type changes
// for tests.
// TODO(groby): Combine with similar code in ResourceRequestAllowedNotifierTest.
class TestNetworkChangeNotifier {};

// Compares TranslateEventProto on a restricted set of fields.
MATCHER_P(EqualsTranslateEventProto, translate_event, "") {}

// A language model that just returns its instance variable.
class MockLanguageModel : public language::LanguageModel {};

}  // namespace

namespace testing {

metrics;
Bucket;
ElementsAre;

// The constructor of this class is used to register preferences before
// TranslatePrefs gets created.
struct ProfilePrefRegistration {};

class TranslateManagerTest : public ::testing::Test {};

// Target language comes from most recent target language if supported.
TEST_F(TranslateManagerTest, GetTargetLanguageFromRecentTargetLanguage) {}

// Target language comes from application locale if the locale's language
// is supported.
TEST_F(TranslateManagerTest, GetTargetLanguageDefaultsToAppLocale) {}

// Test that the language model is used if provided.
TEST_F(TranslateManagerTest, GetTargetLanguageFromModel) {}

TEST_F(TranslateManagerTest,
       OverrideTriggerWithIndiaEnglish_SourceUnspecified) {}

TEST_F(TranslateManagerTest, OverrideTriggerWithIndiaEnglish) {}

TEST_F(TranslateManagerTest, OverrideTriggerWithIndiaEnglishReachThreshold) {}

TEST_F(TranslateManagerTest, OverrideTriggerWithIndiaEnglishAcceptPrompt) {}

TEST_F(TranslateManagerTest, ShouldHonorRankerEnforcement_Enforce) {}

TEST_F(TranslateManagerTest, LanguageAddedToAcceptLanguagesAfterTranslation) {}

TEST_F(TranslateManagerTest,
       RedundantLanguageNotAddedToAcceptLanguagesAfterTranslation) {}

TEST_F(TranslateManagerTest, DontTranslateOffline) {}

TEST_F(TranslateManagerTest, TestRecordTranslateEvent) {}

TEST_F(TranslateManagerTest,
       TestShouldOverrideMatchesPreviousLanguageDecision) {}

TEST_F(TranslateManagerTest, ShouldSuppressBubbleUI_Default) {}

TEST_F(TranslateManagerTest, ShouldSuppressBubbleUI_HasLanguageChangedFalse) {}

TEST_F(TranslateManagerTest, ShouldSuppressBubbleUI_Override) {}

TEST_F(TranslateManagerTest,
       ShouldSuppressBubbleUI_HrefTranslateMatchesTarget) {}

TEST_F(TranslateManagerTest,
       ShouldSuppressBubbleUI_HrefTranslateMismatchTarget) {}

TEST_F(TranslateManagerTest, RecordInitilizationError) {}

TEST_F(TranslateManagerTest, GetTargetLanguage_AutoTranslatedSource) {}

TEST_F(TranslateManagerTest, GetTargetLanguageForDisplay_NonTranslatedPage) {}

TEST_F(TranslateManagerTest, GetTargetLanguageForDisplay_OnTranslatedPage) {}

TEST_F(TranslateManagerTest, CanManuallyTranslate_PageNeedsTranslation) {}

TEST_F(TranslateManagerTest, CanManuallyTranslate_Offline) {}

TEST_F(TranslateManagerTest, CanManuallyTranslate_TranslatableURL) {}

TEST_F(TranslateManagerTest, CanManuallyTranslate_EmptySourceLanguage) {}

TEST_F(TranslateManagerTest, CanManuallyTranslate_UndefinedSourceLanguage) {}

TEST_F(TranslateManagerTest, CanPartiallyTranslateTargetLanguage) {}

TEST_F(TranslateManagerTest, PredefinedTargetLanguage) {}

TEST_F(TranslateManagerTest, CanManuallyTranslate_ImagePage) {}

TEST_F(TranslateManagerTest,
       PredefinedTargetLanguage_UserSpecifiedAutoTranslation) {}

TEST_F(TranslateManagerTest, PredefinedTargetLanguage_BlockedLanguage) {}

TEST_F(TranslateManagerTest, PredefinedTargetLanguage_OverrideBlockedLanguage) {}

TEST_F(TranslateManagerTest, PredefinedTargetLanguage_BlockedSite) {}

TEST_F(TranslateManagerTest, PredefinedTargetLanguage_AutoTranslate) {}

TEST_F(TranslateManagerTest, ShowTranslateUI_NoTranslation) {}

TEST_F(TranslateManagerTest, ShowTranslateUI_Translation) {}

TEST_F(TranslateManagerTest, ShowTranslateUI_PageAlreadyTranslated) {}

TEST_F(TranslateManagerTest,
       ShowTranslateUI_ExplicitTargetLanguageTranslation) {}

TEST_F(TranslateManagerTest, ShowTranslateUI_ExplicitTargetSameAsTarget) {}

TEST_F(TranslateManagerTest, GetActiveTranslateMetricsLogger) {}

TEST_F(TranslateManagerTest, HrefTranslateUnknownPageLanguage) {}

TEST_F(TranslateManagerTest, HrefTranslateSimilarLanguages) {}

}  // namespace testing

}  // namespace translate