| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <tuple> | 5 #include <tuple> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/common/chrome_isolated_world_ids.h" | 10 #include "chrome/common/chrome_isolated_world_ids.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 EXPECT_CALL(*translate_helper_, IsTranslateLibReady()) | 182 EXPECT_CALL(*translate_helper_, IsTranslateLibReady()) |
| 183 .Times(AtLeast(5)) // See kMaxTranslateInitCheckAttempts in | 183 .Times(AtLeast(5)) // See kMaxTranslateInitCheckAttempts in |
| 184 // translate_helper.cc | 184 // translate_helper.cc |
| 185 .WillRepeatedly(Return(false)); | 185 .WillRepeatedly(Return(false)); |
| 186 | 186 |
| 187 translate_helper_->TranslatePage("en", "fr", std::string()); | 187 translate_helper_->TranslatePage("en", "fr", std::string()); |
| 188 base::RunLoop().RunUntilIdle(); | 188 base::RunLoop().RunUntilIdle(); |
| 189 | 189 |
| 190 translate::TranslateErrors::Type error; | 190 translate::TranslateErrors::Type error; |
| 191 ASSERT_TRUE(translate_helper_->GetPageTranslatedResult(NULL, NULL, &error)); | 191 ASSERT_TRUE(translate_helper_->GetPageTranslatedResult(NULL, NULL, &error)); |
| 192 EXPECT_EQ(translate::TranslateErrors::INITIALIZATION_ERROR, error); | 192 EXPECT_EQ(translate::TranslateErrors::TRANSLATION_TIMEOUT, error); |
| 193 } | 193 } |
| 194 | 194 |
| 195 // Tests that the browser gets notified of the translation success when the | 195 // Tests that the browser gets notified of the translation success when the |
| 196 // translation succeeds. | 196 // translation succeeds. |
| 197 TEST_F(TranslateHelperBrowserTest, TranslateSuccess) { | 197 TEST_F(TranslateHelperBrowserTest, TranslateSuccess) { |
| 198 // We make IsTranslateLibAvailable true so we don't attempt to inject the | 198 // We make IsTranslateLibAvailable true so we don't attempt to inject the |
| 199 // library. | 199 // library. |
| 200 EXPECT_CALL(*translate_helper_, IsTranslateLibAvailable()) | 200 EXPECT_CALL(*translate_helper_, IsTranslateLibAvailable()) |
| 201 .Times(AtLeast(1)) | 201 .Times(AtLeast(1)) |
| 202 .WillRepeatedly(Return(true)); | 202 .WillRepeatedly(Return(true)); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 | 498 |
| 499 GoBack(GURL("data:text/html;charset=utf-8,<html><head>" | 499 GoBack(GURL("data:text/html;charset=utf-8,<html><head>" |
| 500 "<meta http-equiv=\"content-language\" content=\"zh\">" | 500 "<meta http-equiv=\"content-language\" content=\"zh\">" |
| 501 "</head><body>This page is in Chinese.</body></html>"), | 501 "</head><body>This page is in Chinese.</body></html>"), |
| 502 back_state); | 502 back_state); |
| 503 | 503 |
| 504 base::RunLoop().RunUntilIdle(); | 504 base::RunLoop().RunUntilIdle(); |
| 505 ASSERT_TRUE(fake_translate_driver_.called_new_page_); | 505 ASSERT_TRUE(fake_translate_driver_.called_new_page_); |
| 506 EXPECT_EQ("zh", fake_translate_driver_.details_->adopted_language); | 506 EXPECT_EQ("zh", fake_translate_driver_.details_->adopted_language); |
| 507 } | 507 } |
| OLD | NEW |