| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 FailedReload(); | 201 FailedReload(); |
| 202 | 202 |
| 203 // Ensures it is really handled a reload. | 203 // Ensures it is really handled a reload. |
| 204 const content::LoadCommittedDetails& nav_details = | 204 const content::LoadCommittedDetails& nav_details = |
| 205 nav_observer.get_load_commited_details(); | 205 nav_observer.get_load_commited_details(); |
| 206 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. | 206 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. |
| 207 EXPECT_EQ(content::NAVIGATION_TYPE_EXISTING_PAGE, nav_details.type); | 207 EXPECT_EQ(content::NAVIGATION_TYPE_EXISTING_PAGE, nav_details.type); |
| 208 | 208 |
| 209 // The TranslateManager class processes the navigation entry committed | 209 // The TranslateManager class processes the navigation entry committed |
| 210 // notification in a posted task; process that task. | 210 // notification in a posted task; process that task. |
| 211 MessageLoop::current()->RunUntilIdle(); | 211 base::MessageLoop::current()->RunUntilIdle(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 virtual void Observe(int type, | 214 virtual void Observe(int type, |
| 215 const content::NotificationSource& source, | 215 const content::NotificationSource& source, |
| 216 const content::NotificationDetails& details) { | 216 const content::NotificationDetails& details) { |
| 217 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); | 217 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); |
| 218 removed_infobars_.insert( | 218 removed_infobars_.insert( |
| 219 content::Details<InfoBarRemovedDetails>(details)->first); | 219 content::Details<InfoBarRemovedDetails>(details)->first); |
| 220 } | 220 } |
| 221 | 221 |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 | 789 |
| 790 // Test that we are really getting a same page navigation, the test would be | 790 // Test that we are really getting a same page navigation, the test would be |
| 791 // useless if it was not the case. | 791 // useless if it was not the case. |
| 792 const content::LoadCommittedDetails& nav_details = | 792 const content::LoadCommittedDetails& nav_details = |
| 793 nav_observer.get_load_commited_details(); | 793 nav_observer.get_load_commited_details(); |
| 794 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. | 794 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. |
| 795 EXPECT_EQ(content::NAVIGATION_TYPE_SAME_PAGE, nav_details.type); | 795 EXPECT_EQ(content::NAVIGATION_TYPE_SAME_PAGE, nav_details.type); |
| 796 | 796 |
| 797 // The TranslateManager class processes the navigation entry committed | 797 // The TranslateManager class processes the navigation entry committed |
| 798 // notification in a posted task; process that task. | 798 // notification in a posted task; process that task. |
| 799 MessageLoop::current()->RunUntilIdle(); | 799 base::MessageLoop::current()->RunUntilIdle(); |
| 800 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 800 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
| 801 } | 801 } |
| 802 | 802 |
| 803 // Tests that a closed translate infobar does not reappear when navigating | 803 // Tests that a closed translate infobar does not reappear when navigating |
| 804 // in-page. | 804 // in-page. |
| 805 TEST_F(TranslateManagerBrowserTest, CloseInfoBarInPageNavigation) { | 805 TEST_F(TranslateManagerBrowserTest, CloseInfoBarInPageNavigation) { |
| 806 // Simulate navigating to a page and getting its language. | 806 // Simulate navigating to a page and getting its language. |
| 807 SimulateNavigation(GURL("http://www.google.fr"), "fr", true); | 807 SimulateNavigation(GURL("http://www.google.fr"), "fr", true); |
| 808 | 808 |
| 809 // Close the infobar. | 809 // Close the infobar. |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 ASSERT_TRUE(infobar != NULL); | 1435 ASSERT_TRUE(infobar != NULL); |
| 1436 process()->sink().ClearMessages(); | 1436 process()->sink().ClearMessages(); |
| 1437 infobar->Translate(); | 1437 infobar->Translate(); |
| 1438 SimulateTranslateScriptURLFetch(true); | 1438 SimulateTranslateScriptURLFetch(true); |
| 1439 RenderViewHostTester::TestOnMessageReceived( | 1439 RenderViewHostTester::TestOnMessageReceived( |
| 1440 rvh(), | 1440 rvh(), |
| 1441 ChromeViewHostMsg_PageTranslated( | 1441 ChromeViewHostMsg_PageTranslated( |
| 1442 0, 0, "fr", "en", TranslateErrors::NONE)); | 1442 0, 0, "fr", "en", TranslateErrors::NONE)); |
| 1443 | 1443 |
| 1444 // A task should have been posted to clear the script, run it. | 1444 // A task should have been posted to clear the script, run it. |
| 1445 MessageLoop::current()->RunUntilIdle(); | 1445 base::MessageLoop::current()->RunUntilIdle(); |
| 1446 | 1446 |
| 1447 // Do another navigation and translation. | 1447 // Do another navigation and translation. |
| 1448 SimulateNavigation(GURL("http://www.google.es"), "es", true); | 1448 SimulateNavigation(GURL("http://www.google.es"), "es", true); |
| 1449 infobar = GetTranslateInfoBar(); | 1449 infobar = GetTranslateInfoBar(); |
| 1450 ASSERT_TRUE(infobar != NULL); | 1450 ASSERT_TRUE(infobar != NULL); |
| 1451 process()->sink().ClearMessages(); | 1451 process()->sink().ClearMessages(); |
| 1452 infobar->Translate(); | 1452 infobar->Translate(); |
| 1453 // If we don't simulate the URL fetch, the TranslateManager should be waiting | 1453 // If we don't simulate the URL fetch, the TranslateManager should be waiting |
| 1454 // for the script and no message should have been sent to the renderer. | 1454 // for the script and no message should have been sent to the renderer. |
| 1455 EXPECT_TRUE( | 1455 EXPECT_TRUE( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, MAYBE_TranslateSessionRestore) { | 1515 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, MAYBE_TranslateSessionRestore) { |
| 1516 WebContents* current_web_contents = | 1516 WebContents* current_web_contents = |
| 1517 browser()->tab_strip_model()->GetActiveWebContents(); | 1517 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1518 content::Source<WebContents> source(current_web_contents); | 1518 content::Source<WebContents> source(current_web_contents); |
| 1519 | 1519 |
| 1520 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> | 1520 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> |
| 1521 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1521 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
| 1522 source); | 1522 source); |
| 1523 fr_language_detected_signal.Wait(); | 1523 fr_language_detected_signal.Wait(); |
| 1524 } | 1524 } |
| OLD | NEW |