| 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/renderer/translate/translate_helper.h" | 6 #include "chrome/renderer/isolated_world_ids.h" |
| 7 #include "chrome/test/base/chrome_render_view_test.h" | 7 #include "chrome/test/base/chrome_render_view_test.h" |
| 8 #include "components/translate/content/common/translate_messages.h" | 8 #include "components/translate/content/common/translate_messages.h" |
| 9 #include "components/translate/content/renderer/translate_helper.h" |
| 9 #include "components/translate/core/common/translate_constants.h" | 10 #include "components/translate/core/common/translate_constants.h" |
| 10 #include "content/public/renderer/render_view.h" | 11 #include "content/public/renderer/render_view.h" |
| 12 #include "extensions/common/constants.h" |
| 13 #include "extensions/renderer/extension_groups.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 16 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 14 | 17 |
| 15 using testing::AtLeast; | 18 using testing::AtLeast; |
| 16 using testing::Return; | 19 using testing::Return; |
| 17 using testing::_; | 20 using testing::_; |
| 18 | 21 |
| 19 class TestTranslateHelper : public TranslateHelper { | 22 class TestTranslateHelper : public translate::TranslateHelper { |
| 20 public: | 23 public: |
| 21 explicit TestTranslateHelper(content::RenderView* render_view) | 24 explicit TestTranslateHelper(content::RenderView* render_view) |
| 22 : TranslateHelper(render_view) { | 25 : translate::TranslateHelper( |
| 23 } | 26 render_view, |
| 27 chrome::ISOLATED_WORLD_ID_TRANSLATE, |
| 28 extensions::EXTENSION_GROUP_INTERNAL_TRANSLATE_SCRIPTS, |
| 29 extensions::kExtensionScheme) {} |
| 24 | 30 |
| 25 virtual base::TimeDelta AdjustDelay(int delayInMs) OVERRIDE { | 31 virtual base::TimeDelta AdjustDelay(int delayInMs) OVERRIDE { |
| 26 // Just returns base::TimeDelta() which has initial value 0. | 32 // Just returns base::TimeDelta() which has initial value 0. |
| 27 // Tasks doesn't need to be delayed in tests. | 33 // Tasks doesn't need to be delayed in tests. |
| 28 return base::TimeDelta(); | 34 return base::TimeDelta(); |
| 29 } | 35 } |
| 30 | 36 |
| 31 void TranslatePage(const std::string& source_lang, | 37 void TranslatePage(const std::string& source_lang, |
| 32 const std::string& target_lang, | 38 const std::string& target_lang, |
| 33 const std::string& translate_script) { | 39 const std::string& translate_script) { |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 454 |
| 449 GoBack(back_state); | 455 GoBack(back_state); |
| 450 | 456 |
| 451 message = render_thread_->sink().GetUniqueMessageMatching( | 457 message = render_thread_->sink().GetUniqueMessageMatching( |
| 452 ChromeViewHostMsg_TranslateLanguageDetermined::ID); | 458 ChromeViewHostMsg_TranslateLanguageDetermined::ID); |
| 453 ASSERT_NE(static_cast<IPC::Message*>(NULL), message); | 459 ASSERT_NE(static_cast<IPC::Message*>(NULL), message); |
| 454 ChromeViewHostMsg_TranslateLanguageDetermined::Read(message, ¶ms); | 460 ChromeViewHostMsg_TranslateLanguageDetermined::Read(message, ¶ms); |
| 455 EXPECT_EQ("zh", params.a.adopted_language); | 461 EXPECT_EQ("zh", params.a.adopted_language); |
| 456 render_thread_->sink().ClearMessages(); | 462 render_thread_->sink().ClearMessages(); |
| 457 } | 463 } |
| OLD | NEW |