OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <algorithm> | 5 #include <algorithm> |
6 #include <set> | 6 #include <set> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/ui/translate/translate_bubble_factory.h" | 21 #include "chrome/browser/ui/translate/translate_bubble_factory.h" |
22 #include "chrome/browser/ui/translate/translate_bubble_model.h" | 22 #include "chrome/browser/ui/translate/translate_bubble_model.h" |
23 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" | 23 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" |
24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
26 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
27 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 27 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
28 #include "chrome/test/base/testing_browser_process.h" | 28 #include "chrome/test/base/testing_browser_process.h" |
29 #include "chrome/test/base/testing_profile.h" | 29 #include "chrome/test/base/testing_profile.h" |
30 #include "components/infobars/core/infobar.h" | 30 #include "components/infobars/core/infobar.h" |
| 31 #include "components/translate/content/browser/content_translate_driver.h" |
31 #include "components/translate/content/common/translate_messages.h" | 32 #include "components/translate/content/common/translate_messages.h" |
32 #include "components/translate/core/browser/translate_accept_languages.h" | 33 #include "components/translate/core/browser/translate_accept_languages.h" |
33 #include "components/translate/core/browser/translate_download_manager.h" | 34 #include "components/translate/core/browser/translate_download_manager.h" |
34 #include "components/translate/core/browser/translate_infobar_delegate.h" | 35 #include "components/translate/core/browser/translate_infobar_delegate.h" |
35 #include "components/translate/core/browser/translate_language_list.h" | 36 #include "components/translate/core/browser/translate_language_list.h" |
36 #include "components/translate/core/browser/translate_manager.h" | 37 #include "components/translate/core/browser/translate_manager.h" |
37 #include "components/translate/core/browser/translate_prefs.h" | 38 #include "components/translate/core/browser/translate_prefs.h" |
38 #include "components/translate/core/browser/translate_script.h" | 39 #include "components/translate/core/browser/translate_script.h" |
39 #include "components/translate/core/common/language_detection_details.h" | 40 #include "components/translate/core/common/language_detection_details.h" |
40 #include "components/translate/core/common/translate_pref_names.h" | 41 #include "components/translate/core/common/translate_pref_names.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 // previous test). | 253 // previous test). |
253 translate::TranslateDownloadManager* download_manager = | 254 translate::TranslateDownloadManager* download_manager = |
254 translate::TranslateDownloadManager::GetInstance(); | 255 translate::TranslateDownloadManager::GetInstance(); |
255 download_manager->ClearTranslateScriptForTesting(); | 256 download_manager->ClearTranslateScriptForTesting(); |
256 download_manager->SetTranslateScriptExpirationDelay(60 * 60 * 1000); | 257 download_manager->SetTranslateScriptExpirationDelay(60 * 60 * 1000); |
257 | 258 |
258 ChromeRenderViewHostTestHarness::SetUp(); | 259 ChromeRenderViewHostTestHarness::SetUp(); |
259 InfoBarService::CreateForWebContents(web_contents()); | 260 InfoBarService::CreateForWebContents(web_contents()); |
260 ChromeTranslateClient::CreateForWebContents(web_contents()); | 261 ChromeTranslateClient::CreateForWebContents(web_contents()); |
261 ChromeTranslateClient::FromWebContents(web_contents()) | 262 ChromeTranslateClient::FromWebContents(web_contents()) |
262 ->set_translate_max_reload_attempts(0); | 263 ->translate_driver() |
| 264 .set_translate_max_reload_attempts(0); |
263 | 265 |
264 notification_registrar_.Add( | 266 notification_registrar_.Add( |
265 this, | 267 this, |
266 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, | 268 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
267 content::Source<InfoBarService>(infobar_service())); | 269 content::Source<InfoBarService>(infobar_service())); |
268 } | 270 } |
269 | 271 |
270 virtual void TearDown() { | 272 virtual void TearDown() { |
271 process()->sink().ClearMessages(); | 273 process()->sink().ClearMessages(); |
272 | 274 |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 810 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
809 EXPECT_TRUE(CloseTranslateInfoBar()); | 811 EXPECT_TRUE(CloseTranslateInfoBar()); |
810 | 812 |
811 // ...But not show it if the reload fails. | 813 // ...But not show it if the reload fails. |
812 ReloadAndWait(false); | 814 ReloadAndWait(false); |
813 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 815 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
814 | 816 |
815 // If we set reload attempts to a high value, we will not see the infobar | 817 // If we set reload attempts to a high value, we will not see the infobar |
816 // immediately. | 818 // immediately. |
817 ChromeTranslateClient::FromWebContents(web_contents()) | 819 ChromeTranslateClient::FromWebContents(web_contents()) |
818 ->set_translate_max_reload_attempts(100); | 820 ->translate_driver() |
| 821 .set_translate_max_reload_attempts(100); |
819 ReloadAndWait(true); | 822 ReloadAndWait(true); |
820 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 823 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
821 } | 824 } |
822 | 825 |
823 // Test that reloading the page by way of typing again the URL in the | 826 // Test that reloading the page by way of typing again the URL in the |
824 // location bar brings back the infobar. | 827 // location bar brings back the infobar. |
825 TEST_F(TranslateManagerRenderViewHostTest, ReloadFromLocationBar) { | 828 TEST_F(TranslateManagerRenderViewHostTest, ReloadFromLocationBar) { |
826 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 | 829 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 |
827 if (TranslateService::IsTranslateBubbleEnabled()) | 830 if (TranslateService::IsTranslateBubbleEnabled()) |
828 return; | 831 return; |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE, 0); | 1671 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE, 0); |
1669 | 1672 |
1670 // Check the bubble exists instead of the infobar. | 1673 // Check the bubble exists instead of the infobar. |
1671 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 1674 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
1672 ASSERT_TRUE(infobar == NULL); | 1675 ASSERT_TRUE(infobar == NULL); |
1673 TranslateBubbleModel* bubble = factory->model(); | 1676 TranslateBubbleModel* bubble = factory->model(); |
1674 ASSERT_TRUE(bubble != NULL); | 1677 ASSERT_TRUE(bubble != NULL); |
1675 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, | 1678 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, |
1676 bubble->GetViewState()); | 1679 bubble->GetViewState()); |
1677 } | 1680 } |
OLD | NEW |