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

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

Powered by Google App Engine
This is Rietveld 408576698