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

Unified Diff: chrome/renderer/translate/translate_helper_browsertest.cc

Issue 2919343007: Check |errorCode| of translate.js and notify to Browser (Closed)
Patch Set: Update comment in translate_errors.h Created 3 years, 6 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: chrome/renderer/translate/translate_helper_browsertest.cc
diff --git a/chrome/renderer/translate/translate_helper_browsertest.cc b/chrome/renderer/translate/translate_helper_browsertest.cc
index 679b62803a798fb432ee3297c481dec8d4eeb2ba..515a49c5680123257d167d4a05577230f3992ffe 100644
--- a/chrome/renderer/translate/translate_helper_browsertest.cc
+++ b/chrome/renderer/translate/translate_helper_browsertest.cc
@@ -112,6 +112,7 @@ class TestTranslateHelper : public translate::TranslateHelper {
MOCK_METHOD0(HasTranslationFinished, bool());
MOCK_METHOD0(HasTranslationFailed, bool());
MOCK_METHOD0(GetOriginalPageLanguage, std::string());
+ MOCK_METHOD0(GetErrorCode, int64_t());
MOCK_METHOD0(StartTranslation, bool());
MOCK_METHOD1(ExecuteScript, void(const std::string&));
MOCK_METHOD2(ExecuteScriptAndGetBoolResult, bool(const std::string&, bool));
@@ -184,12 +185,16 @@ TEST_F(TranslateHelperBrowserTest, TranslateLibNeverReady) {
// translate_helper.cc
.WillRepeatedly(Return(false));
+ EXPECT_CALL(*translate_helper_, GetErrorCode())
+ .Times(AtLeast(5))
+ .WillRepeatedly(Return(0));
+
translate_helper_->TranslatePage("en", "fr", std::string());
base::RunLoop().RunUntilIdle();
translate::TranslateErrors::Type error;
ASSERT_TRUE(translate_helper_->GetPageTranslatedResult(NULL, NULL, &error));
- EXPECT_EQ(translate::TranslateErrors::INITIALIZATION_ERROR, error);
+ EXPECT_EQ(translate::TranslateErrors::TRANSLATION_TIMEOUT, error);
}
// Tests that the browser gets notified of the translation success when the
@@ -205,6 +210,8 @@ TEST_F(TranslateHelperBrowserTest, TranslateSuccess) {
.WillOnce(Return(false))
.WillOnce(Return(true));
+ EXPECT_CALL(*translate_helper_, GetErrorCode()).WillOnce(Return(0));
+
EXPECT_CALL(*translate_helper_, StartTranslation()).WillOnce(Return(true));
// Succeed after few checks.
@@ -259,6 +266,9 @@ TEST_F(TranslateHelperBrowserTest, TranslateFailure) {
.Times(AtLeast(1))
.WillRepeatedly(Return(false));
+ EXPECT_CALL(*translate_helper_, GetErrorCode())
+ .WillOnce(Return(6)); // TRANSLATION_ERROR = 6
Takashi Toyoshima 2017/06/29 11:59:15 why don't you use translate::TranslationErrors::TR
+
// V8 call for performance monitoring should be ignored.
EXPECT_CALL(*translate_helper_,
ExecuteScriptAndGetDoubleResult(_)).Times(2);
« no previous file with comments | « chrome/browser/translate/translate_manager_browsertest.cc ('k') | components/translate/content/renderer/translate_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698