| Index: chrome/browser/memory/tab_manager_browsertest.cc
|
| diff --git a/chrome/browser/memory/tab_manager_browsertest.cc b/chrome/browser/memory/tab_manager_browsertest.cc
|
| index e991a32e9617e0e6d55e6a1bdfea5835f66ffafa..6796f4948433639ad378b80b65142d34360f4d39 100644
|
| --- a/chrome/browser/memory/tab_manager_browsertest.cc
|
| +++ b/chrome/browser/memory/tab_manager_browsertest.cc
|
| @@ -24,6 +24,7 @@
|
| #include "content/public/browser/notification_types.h"
|
| #include "content/public/browser/render_process_host.h"
|
| #include "content/public/common/content_switches.h"
|
| +#include "content/public/test/test_navigation_observer.h"
|
| #include "content/public/test/test_utils.h"
|
| #include "url/gurl.h"
|
|
|
| @@ -46,31 +47,22 @@ IN_PROC_BROWSER_TEST_F(TabManagerTest, TabManagerBasics) {
|
| base::TimeDelta::FromMinutes(0));
|
|
|
| // Get three tabs open.
|
| - WindowedNotificationObserver load1(
|
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| - content::NotificationService::AllSources());
|
| OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(),
|
| WindowOpenDisposition::CURRENT_TAB,
|
| ui::PAGE_TRANSITION_TYPED, false);
|
| - browser()->OpenURL(open1);
|
| + content::TestNavigationObserver load1(browser()->OpenURL(open1));
|
| load1.Wait();
|
|
|
| - WindowedNotificationObserver load2(
|
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| - content::NotificationService::AllSources());
|
| OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(),
|
| WindowOpenDisposition::NEW_FOREGROUND_TAB,
|
| ui::PAGE_TRANSITION_TYPED, false);
|
| - browser()->OpenURL(open2);
|
| + content::TestNavigationObserver load2(browser()->OpenURL(open2));
|
| load2.Wait();
|
|
|
| - WindowedNotificationObserver load3(
|
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| - content::NotificationService::AllSources());
|
| OpenURLParams open3(GURL(chrome::kChromeUITermsURL), content::Referrer(),
|
| WindowOpenDisposition::NEW_FOREGROUND_TAB,
|
| ui::PAGE_TRANSITION_TYPED, false);
|
| - browser()->OpenURL(open3);
|
| + content::TestNavigationObserver load3(browser()->OpenURL(open3));
|
| load3.Wait();
|
|
|
| auto* tsm = browser()->tab_strip_model();
|
| @@ -78,23 +70,17 @@ IN_PROC_BROWSER_TEST_F(TabManagerTest, TabManagerBasics) {
|
|
|
| // Navigate the current (third) tab to a different URL, so we can test
|
| // back/forward later.
|
| - WindowedNotificationObserver load4(
|
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| - content::NotificationService::AllSources());
|
| OpenURLParams open4(GURL(chrome::kChromeUIVersionURL), content::Referrer(),
|
| WindowOpenDisposition::CURRENT_TAB,
|
| ui::PAGE_TRANSITION_TYPED, false);
|
| - browser()->OpenURL(open4);
|
| + content::TestNavigationObserver load4(browser()->OpenURL(open4));
|
| load4.Wait();
|
|
|
| // Navigate the third tab again, such that we have three navigation entries.
|
| - WindowedNotificationObserver load5(
|
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| - content::NotificationService::AllSources());
|
| OpenURLParams open5(GURL("chrome://dns"), content::Referrer(),
|
| WindowOpenDisposition::CURRENT_TAB,
|
| ui::PAGE_TRANSITION_TYPED, false);
|
| - browser()->OpenURL(open5);
|
| + content::TestNavigationObserver load5(browser()->OpenURL(open5));
|
| load5.Wait();
|
|
|
| EXPECT_EQ(3, tsm->count());
|
| @@ -133,9 +119,8 @@ IN_PROC_BROWSER_TEST_F(TabManagerTest, TabManagerBasics) {
|
| browser()->GetFindBarController();
|
|
|
| // Select the first tab. It should reload.
|
| - WindowedNotificationObserver reload1(
|
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| - content::NotificationService::AllSources());
|
| + content::TestNavigationObserver reload1(
|
| + browser()->tab_strip_model()->GetWebContentsAt(0));
|
| chrome::SelectNumberedTab(browser(), 0);
|
| reload1.Wait();
|
| // Make sure the FindBarController gets the right WebContents.
|
| @@ -147,9 +132,8 @@ IN_PROC_BROWSER_TEST_F(TabManagerTest, TabManagerBasics) {
|
| EXPECT_TRUE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(2)));
|
|
|
| // Select the third tab. It should reload.
|
| - WindowedNotificationObserver reload2(
|
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| - content::NotificationService::AllSources());
|
| + content::TestNavigationObserver reload2(
|
| + browser()->tab_strip_model()->GetWebContentsAt(2));
|
| chrome::SelectNumberedTab(browser(), 2);
|
| reload2.Wait();
|
| EXPECT_EQ(2, tsm->active_index());
|
| @@ -161,16 +145,14 @@ IN_PROC_BROWSER_TEST_F(TabManagerTest, TabManagerBasics) {
|
| // crbug.com/121373.
|
| EXPECT_TRUE(chrome::CanGoBack(browser()));
|
| EXPECT_FALSE(chrome::CanGoForward(browser()));
|
| - WindowedNotificationObserver back1(
|
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| - content::NotificationService::AllSources());
|
| + content::TestNavigationObserver back1(
|
| + browser()->tab_strip_model()->GetActiveWebContents());
|
| chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB);
|
| back1.Wait();
|
| EXPECT_TRUE(chrome::CanGoBack(browser()));
|
| EXPECT_TRUE(chrome::CanGoForward(browser()));
|
| - WindowedNotificationObserver back2(
|
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| - content::NotificationService::AllSources());
|
| + content::TestNavigationObserver back2(
|
| + browser()->tab_strip_model()->GetActiveWebContents());
|
| chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB);
|
| back2.Wait();
|
| EXPECT_FALSE(chrome::CanGoBack(browser()));
|
| @@ -190,22 +172,16 @@ IN_PROC_BROWSER_TEST_F(TabManagerTest, OomPressureListener) {
|
| base::TimeDelta::FromMinutes(0));
|
|
|
| // Get three tabs open.
|
| - content::WindowedNotificationObserver load1(
|
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| - content::NotificationService::AllSources());
|
| OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(),
|
| WindowOpenDisposition::CURRENT_TAB,
|
| ui::PAGE_TRANSITION_TYPED, false);
|
| - browser()->OpenURL(open1);
|
| + content::TestNavigationObserver load1(browser()->OpenURL(open1));
|
| load1.Wait();
|
|
|
| - content::WindowedNotificationObserver load2(
|
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| - content::NotificationService::AllSources());
|
| OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(),
|
| WindowOpenDisposition::NEW_FOREGROUND_TAB,
|
| ui::PAGE_TRANSITION_TYPED, false);
|
| - browser()->OpenURL(open2);
|
| + content::TestNavigationObserver load2(browser()->OpenURL(open2));
|
| load2.Wait();
|
| EXPECT_FALSE(tab_manager->recent_tab_discard());
|
|
|
| @@ -243,22 +219,16 @@ IN_PROC_BROWSER_TEST_F(TabManagerTest, InvalidOrEmptyURL) {
|
|
|
| // Open two tabs. Wait for the foreground one to load but do not wait for the
|
| // background one.
|
| - content::WindowedNotificationObserver load1(
|
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| - content::NotificationService::AllSources());
|
| OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(),
|
| WindowOpenDisposition::CURRENT_TAB,
|
| ui::PAGE_TRANSITION_TYPED, false);
|
| - browser()->OpenURL(open1);
|
| + content::TestNavigationObserver load1(browser()->OpenURL(open1));
|
| load1.Wait();
|
|
|
| - content::WindowedNotificationObserver load2(
|
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| - content::NotificationService::AllSources());
|
| OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(),
|
| WindowOpenDisposition::NEW_BACKGROUND_TAB,
|
| ui::PAGE_TRANSITION_TYPED, false);
|
| - browser()->OpenURL(open2);
|
| + content::TestNavigationObserver load2(browser()->OpenURL(open2));
|
|
|
| ASSERT_EQ(2, browser()->tab_strip_model()->count());
|
|
|
| @@ -437,22 +407,16 @@ IN_PROC_BROWSER_TEST_F(TabManagerTest, AutoDiscardable) {
|
| base::TimeDelta::FromMinutes(0));
|
|
|
| // Get two tabs open.
|
| - WindowedNotificationObserver load1(
|
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| - content::NotificationService::AllSources());
|
| OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(),
|
| WindowOpenDisposition::CURRENT_TAB,
|
| ui::PAGE_TRANSITION_TYPED, false);
|
| - browser()->OpenURL(open1);
|
| + content::TestNavigationObserver load1(browser()->OpenURL(open1));
|
| load1.Wait();
|
|
|
| - WindowedNotificationObserver load2(
|
| - content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| - content::NotificationService::AllSources());
|
| OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(),
|
| WindowOpenDisposition::NEW_FOREGROUND_TAB,
|
| ui::PAGE_TRANSITION_TYPED, false);
|
| - browser()->OpenURL(open2);
|
| + content::TestNavigationObserver load2(browser()->OpenURL(open2));
|
| load2.Wait();
|
|
|
| // Set the auto-discardable state of the first tab to false.
|
|
|