OLD | NEW |
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 Reload(); | 198 Reload(); |
199 | 199 |
200 // Ensures it is really handled a reload. | 200 // Ensures it is really handled a reload. |
201 const content::LoadCommittedDetails& nav_details = | 201 const content::LoadCommittedDetails& nav_details = |
202 nav_observer.get_load_commited_details(); | 202 nav_observer.get_load_commited_details(); |
203 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. | 203 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. |
204 EXPECT_EQ(content::NAVIGATION_TYPE_EXISTING_PAGE, nav_details.type); | 204 EXPECT_EQ(content::NAVIGATION_TYPE_EXISTING_PAGE, nav_details.type); |
205 | 205 |
206 // The TranslateManager class processes the navigation entry committed | 206 // The TranslateManager class processes the navigation entry committed |
207 // notification in a posted task; process that task. | 207 // notification in a posted task; process that task. |
208 MessageLoop::current()->RunAllPending(); | 208 MessageLoop::current()->RunUntilIdle(); |
209 } | 209 } |
210 | 210 |
211 virtual void Observe(int type, | 211 virtual void Observe(int type, |
212 const content::NotificationSource& source, | 212 const content::NotificationSource& source, |
213 const content::NotificationDetails& details) { | 213 const content::NotificationDetails& details) { |
214 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); | 214 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); |
215 removed_infobars_.insert( | 215 removed_infobars_.insert( |
216 content::Details<InfoBarRemovedDetails>(details)->first); | 216 content::Details<InfoBarRemovedDetails>(details)->first); |
217 } | 217 } |
218 | 218 |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 | 806 |
807 // Test that we are really getting a same page navigation, the test would be | 807 // Test that we are really getting a same page navigation, the test would be |
808 // useless if it was not the case. | 808 // useless if it was not the case. |
809 const content::LoadCommittedDetails& nav_details = | 809 const content::LoadCommittedDetails& nav_details = |
810 nav_observer.get_load_commited_details(); | 810 nav_observer.get_load_commited_details(); |
811 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. | 811 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. |
812 EXPECT_EQ(content::NAVIGATION_TYPE_SAME_PAGE, nav_details.type); | 812 EXPECT_EQ(content::NAVIGATION_TYPE_SAME_PAGE, nav_details.type); |
813 | 813 |
814 // The TranslateManager class processes the navigation entry committed | 814 // The TranslateManager class processes the navigation entry committed |
815 // notification in a posted task; process that task. | 815 // notification in a posted task; process that task. |
816 MessageLoop::current()->RunAllPending(); | 816 MessageLoop::current()->RunUntilIdle(); |
817 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 817 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
818 } | 818 } |
819 | 819 |
820 // Tests that a closed translate infobar does not reappear when navigating | 820 // Tests that a closed translate infobar does not reappear when navigating |
821 // in-page. | 821 // in-page. |
822 TEST_F(TranslateManagerTest, CloseInfoBarInPageNavigation) { | 822 TEST_F(TranslateManagerTest, CloseInfoBarInPageNavigation) { |
823 // Simulate navigating to a page and getting its language. | 823 // Simulate navigating to a page and getting its language. |
824 SimulateNavigation(GURL("http://www.google.fr"), "fr", true); | 824 SimulateNavigation(GURL("http://www.google.fr"), "fr", true); |
825 | 825 |
826 // Close the infobar. | 826 // Close the infobar. |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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()->RunAllPending(); | 1457 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 | 1513 |
1514 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, TranslateSessionRestore) { | 1514 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, TranslateSessionRestore) { |
1515 WebContents* current_web_contents = chrome::GetActiveWebContents(browser()); | 1515 WebContents* current_web_contents = chrome::GetActiveWebContents(browser()); |
1516 content::Source<WebContents> source(current_web_contents); | 1516 content::Source<WebContents> source(current_web_contents); |
1517 | 1517 |
1518 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> | 1518 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> |
1519 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1519 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
1520 source); | 1520 source); |
1521 fr_language_detected_signal.Wait(); | 1521 fr_language_detected_signal.Wait(); |
1522 } | 1522 } |
OLD | NEW |