Chromium Code Reviews| Index: components/translate/core/browser/mock_translate_client.h |
| diff --git a/components/translate/core/browser/mock_translate_client.h b/components/translate/core/browser/mock_translate_client.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6e6fac1829f2a1e38d45a61e0b7bb464fb39697c |
| --- /dev/null |
| +++ b/components/translate/core/browser/mock_translate_client.h |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2017 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_CLIENT_H_ |
| +#define COMPONENTS_TRANSLATE_CORE_BROWSER_MOCK_TRANSLATE_CLIENT_H_ |
| + |
| +#include <memory> |
| +#include <string> |
| + |
| +#include "base/memory/ptr_util.h" |
| +#include "components/infobars/core/infobar.h" |
| +#include "components/translate/core/browser/translate_client.h" |
| +#include "components/translate/core/browser/translate_driver.h" |
| +#include "components/translate/core/browser/translate_prefs.h" |
| +#include "testing/gmock/include/gmock/gmock.h" |
| + |
| +namespace translate { |
| + |
| +extern const char* preferred_languages_prefs; |
|
groby-ooo-7-16
2017/05/31 00:41:15
We really shouldn't expose global constants from a
napper
2017/05/31 01:16:37
Yes this isn't very nice. Can you put the constant
Leo
2017/05/31 01:38:26
Thanks for the concern and tips. I moved these to
|
| +extern const char* accept_languages_prefs; |
| + |
| +namespace testing { |
| + |
| +class MockTranslateClient : public TranslateClient { |
| + public: |
| + MockTranslateClient(TranslateDriver* driver, PrefService* prefs); |
| + |
| + ~MockTranslateClient() override; |
| + |
| + TranslateDriver* GetTranslateDriver() override; |
| + |
| + PrefService* GetPrefs() override; |
| + |
| + std::unique_ptr<TranslatePrefs> GetTranslatePrefs() override; |
| + |
| + MOCK_METHOD0(GetTranslateAcceptLanguages, TranslateAcceptLanguages*()); |
| + MOCK_CONST_METHOD0(GetInfobarIconID, int()); |
| + |
| +#if !defined(USE_AURA) |
| + MOCK_CONST_METHOD1(CreateInfoBarMock, |
| + infobars::InfoBar*(TranslateInfoBarDelegate*)); |
| + std::unique_ptr<infobars::InfoBar> CreateInfoBar( |
| + std::unique_ptr<TranslateInfoBarDelegate> delegate) const { |
| + return base::WrapUnique(CreateInfoBarMock(std::move(delegate).get())); |
|
napper
2017/05/30 06:24:36
This doesn't make sense to me:
std::move(delegate
groby-ooo-7-16
2017/05/31 00:41:15
I've done digging through history, and it seems th
Leo
2017/05/31 01:38:26
Great to know the details.
Removed std::move()
|
| + } |
| +#endif |
| + |
| + MOCK_METHOD5(ShowTranslateUI, |
| + void(translate::TranslateStep, |
| + const std::string&, |
| + const std::string&, |
| + TranslateErrors::Type, |
| + bool)); |
| + MOCK_METHOD1(IsTranslatableURL, bool(const GURL&)); |
| + MOCK_METHOD1(ShowReportLanguageDetectionErrorUI, void(const GURL&)); |
| + |
| + private: |
| + TranslateDriver* driver_; |
| + PrefService* prefs_; |
| +}; |
| + |
| +} // namespace testing |
| + |
| +} // namespace translate |
| + |
| +#endif // COMPONENTS_TRANSLATE_CORE_BROWSER_MOCK_TRANSLATE_CLIENT_H_ |