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

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

Issue 2919343007: Check |errorCode| of translate.js and notify to Browser (Closed)
Patch Set: Addressed review comment. Proper order of enum variables in switch case. Created 3 years, 5 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..b0238cdbfd10693c5cd4ebcd1772ca577d77a820 100644
--- a/chrome/renderer/translate/translate_helper_browsertest.cc
+++ b/chrome/renderer/translate/translate_helper_browsertest.cc
@@ -112,12 +112,14 @@ 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));
MOCK_METHOD1(ExecuteScriptAndGetStringResult,
std::string(const std::string&));
MOCK_METHOD1(ExecuteScriptAndGetDoubleResult, double(const std::string&));
+ MOCK_METHOD1(ExecuteScriptAndGetIntegerResult, int64_t(const std::string&));
private:
void OnPageTranslated(bool cancelled,
@@ -184,12 +186,16 @@ TEST_F(TranslateHelperBrowserTest, TranslateLibNeverReady) {
// translate_helper.cc
.WillRepeatedly(Return(false));
+ EXPECT_CALL(*translate_helper_, GetErrorCode())
+ .Times(AtLeast(5))
+ .WillRepeatedly(Return(translate::TranslateErrors::NONE));
+
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 +211,9 @@ TEST_F(TranslateHelperBrowserTest, TranslateSuccess) {
.WillOnce(Return(false))
.WillOnce(Return(true));
+ EXPECT_CALL(*translate_helper_, GetErrorCode())
+ .WillOnce(Return(translate::TranslateErrors::NONE));
+
EXPECT_CALL(*translate_helper_, StartTranslation()).WillOnce(Return(true));
// Succeed after few checks.
@@ -259,6 +268,9 @@ TEST_F(TranslateHelperBrowserTest, TranslateFailure) {
.Times(AtLeast(1))
.WillRepeatedly(Return(false));
+ EXPECT_CALL(*translate_helper_, GetErrorCode())
+ .WillOnce(Return(translate::TranslateErrors::TRANSLATION_ERROR));
+
// 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