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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/prefs/pref_change_registrar.h" | 10 #include "base/prefs/pref_change_registrar.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // expiration delay to a large value by default (in case it was zeroed in a | 256 // expiration delay to a large value by default (in case it was zeroed in a |
257 // previous test). | 257 // previous test). |
258 TranslateDownloadManager* download_manager = | 258 TranslateDownloadManager* download_manager = |
259 TranslateDownloadManager::GetInstance(); | 259 TranslateDownloadManager::GetInstance(); |
260 download_manager->ClearTranslateScriptForTesting(); | 260 download_manager->ClearTranslateScriptForTesting(); |
261 download_manager->SetTranslateScriptExpirationDelay(60 * 60 * 1000); | 261 download_manager->SetTranslateScriptExpirationDelay(60 * 60 * 1000); |
262 | 262 |
263 ChromeRenderViewHostTestHarness::SetUp(); | 263 ChromeRenderViewHostTestHarness::SetUp(); |
264 InfoBarService::CreateForWebContents(web_contents()); | 264 InfoBarService::CreateForWebContents(web_contents()); |
265 TranslateTabHelper::CreateForWebContents(web_contents()); | 265 TranslateTabHelper::CreateForWebContents(web_contents()); |
266 TranslateManager* manager = | 266 TranslateTabHelper::FromWebContents(web_contents()) |
267 TranslateTabHelper::GetManagerFromWebContents(web_contents()); | 267 ->set_translate_max_reload_attempts(0); |
268 manager->set_translate_max_reload_attemps(0); | |
269 | 268 |
270 notification_registrar_.Add( | 269 notification_registrar_.Add( |
271 this, | 270 this, |
272 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, | 271 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
273 content::Source<InfoBarService>(infobar_service())); | 272 content::Source<InfoBarService>(infobar_service())); |
274 } | 273 } |
275 | 274 |
276 virtual void TearDown() { | 275 virtual void TearDown() { |
277 process()->sink().ClearMessages(); | 276 process()->sink().ClearMessages(); |
278 | 277 |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 ReloadAndWait(true); | 762 ReloadAndWait(true); |
764 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 763 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
765 EXPECT_TRUE(CloseTranslateInfoBar()); | 764 EXPECT_TRUE(CloseTranslateInfoBar()); |
766 | 765 |
767 // ...But not show it if the reload fails. | 766 // ...But not show it if the reload fails. |
768 ReloadAndWait(false); | 767 ReloadAndWait(false); |
769 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 768 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
770 | 769 |
771 // If we set reload attempts to a high value, we will not see the infobar | 770 // If we set reload attempts to a high value, we will not see the infobar |
772 // immediately. | 771 // immediately. |
773 TranslateManager* manager = | 772 TranslateTabHelper::FromWebContents(web_contents()) |
774 TranslateTabHelper::GetManagerFromWebContents(web_contents()); | 773 ->set_translate_max_reload_attempts(100); |
775 manager->set_translate_max_reload_attemps(100); | |
776 ReloadAndWait(true); | 774 ReloadAndWait(true); |
777 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 775 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
778 } | 776 } |
779 | 777 |
780 // Test that reloading the page by way of typing again the URL in the | 778 // Test that reloading the page by way of typing again the URL in the |
781 // location bar brings back the infobar. | 779 // location bar brings back the infobar. |
782 TEST_F(TranslateManagerRenderViewHostTest, ReloadFromLocationBar) { | 780 TEST_F(TranslateManagerRenderViewHostTest, ReloadFromLocationBar) { |
783 GURL url("http://www.google.fr"); | 781 GURL url("http://www.google.fr"); |
784 SimulateNavigation(url, "fr", true); | 782 SimulateNavigation(url, "fr", true); |
785 | 783 |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 // Check the bubble exists instead of the infobar. | 1534 // Check the bubble exists instead of the infobar. |
1537 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 1535 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
1538 ASSERT_TRUE(infobar == NULL); | 1536 ASSERT_TRUE(infobar == NULL); |
1539 TranslateBubbleModel* bubble = factory->model(); | 1537 TranslateBubbleModel* bubble = factory->model(); |
1540 ASSERT_TRUE(bubble != NULL); | 1538 ASSERT_TRUE(bubble != NULL); |
1541 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, | 1539 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, |
1542 bubble->GetViewState()); | 1540 bubble->GetViewState()); |
1543 } | 1541 } |
1544 | 1542 |
1545 #endif // defined(USE_AURA) | 1543 #endif // defined(USE_AURA) |
OLD | NEW |