#include "components/translate/core/browser/translate_ranker_impl.h"
#include <initializer_list>
#include <memory>
#include <utility>
#include <vector>
#include "base/feature_list.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "components/assist_ranker/proto/ranker_model.pb.h"
#include "components/assist_ranker/proto/translate_ranker_model.pb.h"
#include "components/assist_ranker/ranker_model.h"
#include "components/translate/core/browser/mock_translate_metrics_logger.h"
#include "components/ukm/test_ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_source.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/metrics_proto/translate_event.pb.h"
#include "third_party/metrics_proto/ukm/source.pb.h"
#include "url/gurl.h"
namespace translate {
namespace {
constexpr uint32_t kModelVersion = …;
ukm::SourceId kUkmSourceId0 = …;
ukm::SourceId kUkmSourceId1 = …;
class TranslateRankerImplTest : public ::testing::Test { … };
TranslateRankerImplTest::TranslateRankerImplTest() = default;
void TranslateRankerImplTest::InitFeatures(
const std::vector<base::test::FeatureRef>& enabled,
const std::vector<base::test::FeatureRef>& disabled) { … }
std::unique_ptr<TranslateRankerImpl> TranslateRankerImplTest::GetRankerForTest(
float threshold) { … }
double TranslateRankerImplTest::Sigmoid(double x) { … }
metrics::TranslateEventProto TranslateRankerImplTest::CreateTranslateEvent(
const std::string& src_lang,
const std::string& dst_lang,
const std::string& country,
int accept_count,
int decline_count,
int ignore_count) { … }
metrics::TranslateEventProto
TranslateRankerImplTest::CreateDefaultTranslateEvent() { … }
TEST_F(TranslateRankerImplTest, GetVersion) { … }
TEST_F(TranslateRankerImplTest, ModelLoaderQueryNotEnabled) { … }
TEST_F(TranslateRankerImplTest, ModelLoaderQueryEnabledByDefault) { … }
TEST_F(TranslateRankerImplTest, GetModelDecision) { … }
TEST_F(TranslateRankerImplTest, ShouldOfferTranslation_AllEnabled) { … }
TEST_F(TranslateRankerImplTest, ShouldOfferTranslation_AllDisabled) { … }
TEST_F(TranslateRankerImplTest, ShouldOfferTranslation_QueryOnlyDontShow) { … }
TEST_F(TranslateRankerImplTest, ShouldOfferTranslation_QueryOnlyShow) { … }
TEST_F(TranslateRankerImplTest,
ShouldOfferTranslation_EnforcementOnlyDontShow) { … }
TEST_F(TranslateRankerImplTest, ShouldOfferTranslation_EnforcementOnlyShow) { … }
TEST_F(TranslateRankerImplTest, ShouldOfferTranslation_OverrideAndEnforcement) { … }
TEST_F(TranslateRankerImplTest, ShouldOfferTranslation_NoModel) { … }
TEST_F(TranslateRankerImplTest, RecordAndFlushEvents) { … }
TEST_F(TranslateRankerImplTest, EnableLogging) { … }
TEST_F(TranslateRankerImplTest, EnableLoggingClearsCache) { … }
TEST_F(TranslateRankerImplTest,
ShouldOverrideMatchesPreviousLanguageDecision_OverrideDisabled) { … }
TEST_F(TranslateRankerImplTest, ShouldOverrideMatchesPreviousLanguageDecision) { … }
TEST_F(TranslateRankerImplTest,
ShouldOverrideMatchesPreviousLanguageDecision_OverrideEnabled) { … }
TEST_F(TranslateRankerImplTest,
ShouldOverrideMatchesPreviousLanguageDecision_OverrideAndQueryEnabled) { … }
}
}