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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again 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 | Annotate | Revision Log
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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 FailedReload(); 204 FailedReload();
205 205
206 // Ensures it is really handled a reload. 206 // Ensures it is really handled a reload.
207 const content::LoadCommittedDetails& nav_details = 207 const content::LoadCommittedDetails& nav_details =
208 nav_observer.get_load_commited_details(); 208 nav_observer.get_load_commited_details();
209 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. 209 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation.
210 EXPECT_EQ(content::NAVIGATION_TYPE_EXISTING_PAGE, nav_details.type); 210 EXPECT_EQ(content::NAVIGATION_TYPE_EXISTING_PAGE, nav_details.type);
211 211
212 // The TranslateManager class processes the navigation entry committed 212 // The TranslateManager class processes the navigation entry committed
213 // notification in a posted task; process that task. 213 // notification in a posted task; process that task.
214 MessageLoop::current()->RunUntilIdle(); 214 base::MessageLoop::current()->RunUntilIdle();
215 } 215 }
216 216
217 virtual void Observe(int type, 217 virtual void Observe(int type,
218 const content::NotificationSource& source, 218 const content::NotificationSource& source,
219 const content::NotificationDetails& details) { 219 const content::NotificationDetails& details) {
220 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); 220 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type);
221 removed_infobars_.insert( 221 removed_infobars_.insert(
222 content::Details<InfoBarRemovedDetails>(details)->first); 222 content::Details<InfoBarRemovedDetails>(details)->first);
223 } 223 }
224 224
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 799
800 // Test that we are really getting a same page navigation, the test would be 800 // Test that we are really getting a same page navigation, the test would be
801 // useless if it was not the case. 801 // useless if it was not the case.
802 const content::LoadCommittedDetails& nav_details = 802 const content::LoadCommittedDetails& nav_details =
803 nav_observer.get_load_commited_details(); 803 nav_observer.get_load_commited_details();
804 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. 804 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation.
805 EXPECT_EQ(content::NAVIGATION_TYPE_SAME_PAGE, nav_details.type); 805 EXPECT_EQ(content::NAVIGATION_TYPE_SAME_PAGE, nav_details.type);
806 806
807 // The TranslateManager class processes the navigation entry committed 807 // The TranslateManager class processes the navigation entry committed
808 // notification in a posted task; process that task. 808 // notification in a posted task; process that task.
809 MessageLoop::current()->RunUntilIdle(); 809 base::MessageLoop::current()->RunUntilIdle();
810 EXPECT_TRUE(GetTranslateInfoBar() != NULL); 810 EXPECT_TRUE(GetTranslateInfoBar() != NULL);
811 } 811 }
812 812
813 // Tests that a closed translate infobar does not reappear when navigating 813 // Tests that a closed translate infobar does not reappear when navigating
814 // in-page. 814 // in-page.
815 TEST_F(TranslateManagerBrowserTest, CloseInfoBarInPageNavigation) { 815 TEST_F(TranslateManagerBrowserTest, CloseInfoBarInPageNavigation) {
816 // Simulate navigating to a page and getting its language. 816 // Simulate navigating to a page and getting its language.
817 SimulateNavigation(GURL("http://www.google.fr"), "fr", true); 817 SimulateNavigation(GURL("http://www.google.fr"), "fr", true);
818 818
819 // Close the infobar. 819 // Close the infobar.
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 ASSERT_TRUE(infobar != NULL); 1445 ASSERT_TRUE(infobar != NULL);
1446 process()->sink().ClearMessages(); 1446 process()->sink().ClearMessages();
1447 infobar->Translate(); 1447 infobar->Translate();
1448 SimulateTranslateScriptURLFetch(true); 1448 SimulateTranslateScriptURLFetch(true);
1449 RenderViewHostTester::TestOnMessageReceived( 1449 RenderViewHostTester::TestOnMessageReceived(
1450 rvh(), 1450 rvh(),
1451 ChromeViewHostMsg_PageTranslated( 1451 ChromeViewHostMsg_PageTranslated(
1452 0, 0, "fr", "en", TranslateErrors::NONE)); 1452 0, 0, "fr", "en", TranslateErrors::NONE));
1453 1453
1454 // A task should have been posted to clear the script, run it. 1454 // A task should have been posted to clear the script, run it.
1455 MessageLoop::current()->RunUntilIdle(); 1455 base::MessageLoop::current()->RunUntilIdle();
1456 1456
1457 // Do another navigation and translation. 1457 // Do another navigation and translation.
1458 SimulateNavigation(GURL("http://www.google.es"), "es", true); 1458 SimulateNavigation(GURL("http://www.google.es"), "es", true);
1459 infobar = GetTranslateInfoBar(); 1459 infobar = GetTranslateInfoBar();
1460 ASSERT_TRUE(infobar != NULL); 1460 ASSERT_TRUE(infobar != NULL);
1461 process()->sink().ClearMessages(); 1461 process()->sink().ClearMessages();
1462 infobar->Translate(); 1462 infobar->Translate();
1463 // If we don't simulate the URL fetch, the TranslateManager should be waiting 1463 // If we don't simulate the URL fetch, the TranslateManager should be waiting
1464 // for the script and no message should have been sent to the renderer. 1464 // for the script and no message should have been sent to the renderer.
1465 EXPECT_TRUE( 1465 EXPECT_TRUE(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 WebContents* current_web_contents = 1527 WebContents* current_web_contents =
1528 browser()->tab_strip_model()->GetActiveWebContents(); 1528 browser()->tab_strip_model()->GetActiveWebContents();
1529 content::Source<WebContents> source(current_web_contents); 1529 content::Source<WebContents> source(current_web_contents);
1530 1530
1531 ui_test_utils::WindowedNotificationObserverWithDetails< 1531 ui_test_utils::WindowedNotificationObserverWithDetails<
1532 LanguageDetectionDetails> 1532 LanguageDetectionDetails>
1533 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 1533 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
1534 source); 1534 source);
1535 fr_language_detected_signal.Wait(); 1535 fr_language_detected_signal.Wait();
1536 } 1536 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698