| 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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 ReloadAndWait(true); | 771 ReloadAndWait(true); |
| 773 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 772 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
| 774 EXPECT_TRUE(CloseTranslateInfoBar()); | 773 EXPECT_TRUE(CloseTranslateInfoBar()); |
| 775 | 774 |
| 776 // ...But not show it if the reload fails. | 775 // ...But not show it if the reload fails. |
| 777 ReloadAndWait(false); | 776 ReloadAndWait(false); |
| 778 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 777 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
| 779 | 778 |
| 780 // If we set reload attempts to a high value, we will not see the infobar | 779 // If we set reload attempts to a high value, we will not see the infobar |
| 781 // immediately. | 780 // immediately. |
| 782 TranslateManager* manager = | 781 TranslateTabHelper::FromWebContents(web_contents()) |
| 783 TranslateTabHelper::GetManagerFromWebContents(web_contents()); | 782 ->set_translate_max_reload_attempts(100); |
| 784 manager->set_translate_max_reload_attemps(100); | |
| 785 ReloadAndWait(true); | 783 ReloadAndWait(true); |
| 786 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 784 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
| 787 } | 785 } |
| 788 | 786 |
| 789 // Test that reloading the page by way of typing again the URL in the | 787 // Test that reloading the page by way of typing again the URL in the |
| 790 // location bar brings back the infobar. | 788 // location bar brings back the infobar. |
| 791 TEST_F(TranslateManagerRenderViewHostTest, ReloadFromLocationBar) { | 789 TEST_F(TranslateManagerRenderViewHostTest, ReloadFromLocationBar) { |
| 792 GURL url("http://www.google.fr"); | 790 GURL url("http://www.google.fr"); |
| 793 SimulateNavigation(url, "fr", true); | 791 SimulateNavigation(url, "fr", true); |
| 794 | 792 |
| (...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 // Check the bubble exists instead of the infobar. | 1547 // Check the bubble exists instead of the infobar. |
| 1550 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 1548 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
| 1551 ASSERT_TRUE(infobar == NULL); | 1549 ASSERT_TRUE(infobar == NULL); |
| 1552 TranslateBubbleModel* bubble = factory->model(); | 1550 TranslateBubbleModel* bubble = factory->model(); |
| 1553 ASSERT_TRUE(bubble != NULL); | 1551 ASSERT_TRUE(bubble != NULL); |
| 1554 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, | 1552 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, |
| 1555 bubble->GetViewState()); | 1553 bubble->GetViewState()); |
| 1556 } | 1554 } |
| 1557 | 1555 |
| 1558 #endif // defined(USE_AURA) | 1556 #endif // defined(USE_AURA) |
| OLD | NEW |