blob: e921ed6cf181aef5f30c37282b16460a3785c825 [file] [log] [blame]
// Copyright 2018 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.
#include <string>
#import "ios/web_view/internal/translate/web_view_translate_client.h"
namespace ios_web_view {
// Contains the list of parameters passed to |TranslatePage|.
struct TranslatePageInvocation {
std::string source_lang;
std::string target_lang;
bool triggered_from_menu;
// Fake translate client used in unit tests.
class FakeWebViewTranslateClient : public WebViewTranslateClient {
// |page_lang| The original language of the page.
explicit FakeWebViewTranslateClient(web::WebState* web_state,
std::string page_lang);
~FakeWebViewTranslateClient() override;
// WebViewTranslateClient implementation.
void TranslatePage(const std::string& source_lang,
const std::string& target_lang,
bool triggered_from_menu) override;
void RevertTranslation() override;
// Getters for ivars used for testing.
std::string GetPageLang() { return page_lang_; }
std::string GetCurrentLang() { return current_lang_; }
TranslatePageInvocation GetLastTraslatePageInvocation() {
return last_translate_page_invocation_;
std::string page_lang_;
TranslatePageInvocation last_translate_page_invocation_;
std::string current_lang_;
} // namespace ios_web_view