| 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 "base/time/time.h" | 5 #include "base/time/time.h" |
| 6 #include "chrome/common/chrome_constants.h" | |
| 7 #include "chrome/common/render_messages.h" | 6 #include "chrome/common/render_messages.h" |
| 8 #include "chrome/renderer/translate/translate_helper.h" | 7 #include "chrome/renderer/translate/translate_helper.h" |
| 9 #include "chrome/test/base/chrome_render_view_test.h" | 8 #include "chrome/test/base/chrome_render_view_test.h" |
| 9 #include "components/translate/common/translate_constants.h" |
| 10 #include "content/public/renderer/render_view.h" | 10 #include "content/public/renderer/render_view.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 13 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
| 14 | 14 |
| 15 using testing::AtLeast; | 15 using testing::AtLeast; |
| 16 using testing::Return; | 16 using testing::Return; |
| 17 using testing::_; | 17 using testing::_; |
| 18 | 18 |
| 19 class TestTranslateHelper : public TranslateHelper { | 19 class TestTranslateHelper : public TranslateHelper { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 .WillOnce(Return(false)); | 226 .WillOnce(Return(false)); |
| 227 EXPECT_CALL(*translate_helper_, HasTranslationFinished()) | 227 EXPECT_CALL(*translate_helper_, HasTranslationFinished()) |
| 228 .Times(AtLeast(1)) | 228 .Times(AtLeast(1)) |
| 229 .WillRepeatedly(Return(true)); | 229 .WillRepeatedly(Return(true)); |
| 230 | 230 |
| 231 // V8 call for performance monitoring should be ignored. | 231 // V8 call for performance monitoring should be ignored. |
| 232 EXPECT_CALL(*translate_helper_, | 232 EXPECT_CALL(*translate_helper_, |
| 233 ExecuteScriptAndGetDoubleResult(_)).Times(3); | 233 ExecuteScriptAndGetDoubleResult(_)).Times(3); |
| 234 | 234 |
| 235 translate_helper_->TranslatePage(view_->GetPageId(), | 235 translate_helper_->TranslatePage(view_->GetPageId(), |
| 236 chrome::kUnknownLanguageCode, "fr", | 236 translate::kUnknownLanguageCode, "fr", |
| 237 std::string()); | 237 std::string()); |
| 238 base::MessageLoop::current()->RunUntilIdle(); | 238 base::MessageLoop::current()->RunUntilIdle(); |
| 239 | 239 |
| 240 int page_id; | 240 int page_id; |
| 241 TranslateErrors::Type error; | 241 TranslateErrors::Type error; |
| 242 std::string original_lang; | 242 std::string original_lang; |
| 243 std::string target_lang; | 243 std::string target_lang; |
| 244 ASSERT_TRUE(GetPageTranslatedMessage(&page_id, &original_lang, &target_lang, | 244 ASSERT_TRUE(GetPageTranslatedMessage(&page_id, &original_lang, &target_lang, |
| 245 &error)); | 245 &error)); |
| 246 EXPECT_EQ(view_->GetPageId(), page_id); | 246 EXPECT_EQ(view_->GetPageId(), page_id); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 472 |
| 473 GoBack(GetMainFrame()->previousHistoryItem()); | 473 GoBack(GetMainFrame()->previousHistoryItem()); |
| 474 | 474 |
| 475 message = render_thread_->sink().GetUniqueMessageMatching( | 475 message = render_thread_->sink().GetUniqueMessageMatching( |
| 476 ChromeViewHostMsg_TranslateLanguageDetermined::ID); | 476 ChromeViewHostMsg_TranslateLanguageDetermined::ID); |
| 477 ASSERT_NE(static_cast<IPC::Message*>(NULL), message); | 477 ASSERT_NE(static_cast<IPC::Message*>(NULL), message); |
| 478 ChromeViewHostMsg_TranslateLanguageDetermined::Read(message, ¶ms); | 478 ChromeViewHostMsg_TranslateLanguageDetermined::Read(message, ¶ms); |
| 479 EXPECT_EQ("zh", params.a.adopted_language); | 479 EXPECT_EQ("zh", params.a.adopted_language); |
| 480 render_thread_->sink().ClearMessages(); | 480 render_thread_->sink().ClearMessages(); |
| 481 } | 481 } |
| OLD | NEW |