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

Unified Diff: components/translate/core/browser/mock_translate_ranker.h

Issue 2565873002: [translate] Add translate ranker model loader. (Closed)
Patch Set: comments from sdefresne Created 3 years, 10 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
Index: components/translate/core/browser/mock_translate_ranker.h
diff --git a/components/translate/core/browser/mock_translate_ranker.h b/components/translate/core/browser/mock_translate_ranker.h
new file mode 100644
index 0000000000000000000000000000000000000000..7e971c87271868738b4ae0c735fe794ed8ef61a6
--- /dev/null
+++ b/components/translate/core/browser/mock_translate_ranker.h
@@ -0,0 +1,65 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_MOCK_TRANSLATE_RANKER_H_
+#define COMPONENTS_TRANSLATE_CORE_BROWSER_MOCK_TRANSLATE_RANKER_H_
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "components/translate/core/browser/translate_ranker.h"
+
+namespace metrics {
+class TranslateEventProto;
+}
+
+namespace translate {
+
+class TranslatePrefs;
+
+namespace testing {
+
+class MockTranslateRanker : public TranslateRanker {
+ public:
+ MockTranslateRanker();
+ ~MockTranslateRanker() override;
+
+ void set_is_logging_enabled(bool val) { is_logging_enabled_ = val; }
+ void set_is_query_enabled(bool val) { is_query_enabled_ = val; }
+ void set_is_enforcement_enabled(bool val) { is_enforcement_enabled_ = val; }
+ void set_model_version(int val) { model_version_ = val; }
+ void set_should_offer_translation(bool val) {
+ should_offer_translation_ = val;
+ }
+
+ // TranslateRanker...
+ bool IsLoggingEnabled() override;
+ bool IsQueryEnabled() override;
+ bool IsEnforcementEnabled() override;
+ int GetModelVersion() const override;
+ bool ShouldOfferTranslation(const TranslatePrefs& translate_prefs,
+ const std::string& src_lang,
+ const std::string& dst_lang) override;
+ void AddTranslateEvent(
+ const metrics::TranslateEventProto& translate_event) override;
+ void FlushTranslateEvents(
+ std::vector<metrics::TranslateEventProto>* events) override;
+
+ private:
+ std::vector<metrics::TranslateEventProto> event_cache_;
+
+ bool is_logging_enabled_ = false;
+ bool is_query_enabled_ = false;
+ bool is_enforcement_enabled_ = false;
+ bool model_version_ = 0;
+ bool should_offer_translation_ = true;
+
+ DISALLOW_COPY_AND_ASSIGN(MockTranslateRanker);
+};
+
+} // namespace testing
+} // namespace translate
+
+#endif // COMPONENTS_TRANSLATE_CORE_BROWSER_MOCK_TRANSLATE_RANKER_H_
« no previous file with comments | « components/translate/core/browser/BUILD.gn ('k') | components/translate/core/browser/mock_translate_ranker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698