Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: chrome/browser/translate/translate_manager_browsertest.cc

Issue 14846026: [Translate] When reloading a page Wait until some content has actually been re-loaded before trigg… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/translate/translate_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5
6 #include <algorithm> 6 #include <algorithm>
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // ChromeRenderViewHostTestHarness::SetUp() to match what's done in Chrome, 228 // ChromeRenderViewHostTestHarness::SetUp() to match what's done in Chrome,
229 // where the TranslateManager is created before the WebContents. This 229 // where the TranslateManager is created before the WebContents. This
230 // matters as they both register for similar events and we want the 230 // matters as they both register for similar events and we want the
231 // notifications to happen in the same sequence (TranslateManager first, 231 // notifications to happen in the same sequence (TranslateManager first,
232 // WebContents second). Also clears the translate script so it is fetched 232 // WebContents second). Also clears the translate script so it is fetched
233 // everytime and sets the expiration delay to a large value by default (in 233 // everytime and sets the expiration delay to a large value by default (in
234 // case it was zeroed in a previous test). 234 // case it was zeroed in a previous test).
235 TranslateManager::GetInstance()->ClearTranslateScript(); 235 TranslateManager::GetInstance()->ClearTranslateScript();
236 TranslateManager::GetInstance()-> 236 TranslateManager::GetInstance()->
237 set_translate_script_expiration_delay(60 * 60 * 1000); 237 set_translate_script_expiration_delay(60 * 60 * 1000);
238 TranslateManager::GetInstance()->set_translate_max_reload_attemps(0);
238 239
239 ChromeRenderViewHostTestHarness::SetUp(); 240 ChromeRenderViewHostTestHarness::SetUp();
240 InfoBarService::CreateForWebContents(web_contents()); 241 InfoBarService::CreateForWebContents(web_contents());
241 TranslateTabHelper::CreateForWebContents(web_contents()); 242 TranslateTabHelper::CreateForWebContents(web_contents());
242 243
243 notification_registrar_.Add(this, 244 notification_registrar_.Add(this,
244 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, 245 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
245 content::Source<InfoBarService>(infobar_service())); 246 content::Source<InfoBarService>(infobar_service()));
246 } 247 }
247 248
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 // Reload should bring back the infobar if the page succeds 760 // Reload should bring back the infobar if the page succeds
760 ReloadAndWait(true); 761 ReloadAndWait(true);
761 EXPECT_TRUE(GetTranslateInfoBar() != NULL); 762 EXPECT_TRUE(GetTranslateInfoBar() != NULL);
762 763
763 // Close the infobar. 764 // Close the infobar.
764 EXPECT_TRUE(CloseTranslateInfoBar()); 765 EXPECT_TRUE(CloseTranslateInfoBar());
765 766
766 // And not show it if the reload fails 767 // And not show it if the reload fails
767 ReloadAndWait(false); 768 ReloadAndWait(false);
768 EXPECT_EQ(NULL, GetTranslateInfoBar()); 769 EXPECT_EQ(NULL, GetTranslateInfoBar());
770
771 // Set reload attempts to a high value, we will not see the infobar
772 // immediatly.
773 TranslateManager::GetInstance()->set_translate_max_reload_attemps(100);
774 ReloadAndWait(true);
775 EXPECT_TRUE(GetTranslateInfoBar() == NULL);
769 } 776 }
770 777
771 // 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
772 // location bar brings back the infobar. 779 // location bar brings back the infobar.
773 TEST_F(TranslateManagerBrowserTest, ReloadFromLocationBar) { 780 TEST_F(TranslateManagerBrowserTest, ReloadFromLocationBar) {
774 GURL url("http://www.google.fr"); 781 GURL url("http://www.google.fr");
775 782
776 // Simulate navigating to a page and getting its language. 783 // Simulate navigating to a page and getting its language.
777 SimulateNavigation(url, "fr", true); 784 SimulateNavigation(url, "fr", true);
778 785
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, MAYBE_TranslateSessionRestore) { 1522 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, MAYBE_TranslateSessionRestore) {
1516 WebContents* current_web_contents = 1523 WebContents* current_web_contents =
1517 browser()->tab_strip_model()->GetActiveWebContents(); 1524 browser()->tab_strip_model()->GetActiveWebContents();
1518 content::Source<WebContents> source(current_web_contents); 1525 content::Source<WebContents> source(current_web_contents);
1519 1526
1520 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> 1527 ui_test_utils::WindowedNotificationObserverWithDetails<std::string>
1521 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 1528 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
1522 source); 1529 source);
1523 fr_language_detected_signal.Wait(); 1530 fr_language_detected_signal.Wait();
1524 } 1531 }
OLDNEW
« no previous file with comments | « chrome/browser/translate/translate_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698