| 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 ca5621d86d9ad00f8b2337383b8260039857394a..579ba31ed021bb970b13e7d6101dceefa4e046f6 100644
|
| --- a/chrome/browser/memory/tab_manager_browsertest.cc
|
| +++ b/chrome/browser/memory/tab_manager_browsertest.cc
|
| @@ -393,6 +393,46 @@ IN_PROC_BROWSER_TEST_F(TabManagerTest, ProtectVideoTabs) {
|
| EXPECT_TRUE(tab_manager->DiscardTabImpl());
|
| }
|
|
|
| +IN_PROC_BROWSER_TEST_F(TabManagerTest, AutoDiscardable) {
|
| + using content::WindowedNotificationObserver;
|
| + TabManager* tab_manager = g_browser_process->GetTabManager();
|
| +
|
| + // Disable the protection of recent tabs.
|
| + tab_manager->minimum_protection_time_ = 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(),
|
| + CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false);
|
| + browser()->OpenURL(open1);
|
| + load1.Wait();
|
| +
|
| + WindowedNotificationObserver load2(
|
| + content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| + content::NotificationService::AllSources());
|
| + OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(),
|
| + NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_TYPED, false);
|
| + browser()->OpenURL(open2);
|
| + load2.Wait();
|
| +
|
| + // Set the auto-discardable state of the first tab to false.
|
| + auto tsm = browser()->tab_strip_model();
|
| + ASSERT_EQ(2, tsm->count());
|
| + tab_manager->SetTabAutoDiscardableState(tsm->GetWebContentsAt(0), false);
|
| +
|
| + // Shouldn't discard the tab, since auto-discardable is deactivated.
|
| + EXPECT_FALSE(tab_manager->DiscardTabImpl());
|
| +
|
| + // Reset auto-discardable state to true.
|
| + tab_manager->SetTabAutoDiscardableState(tsm->GetWebContentsAt(0), true);
|
| +
|
| + // Now it should be able to discard the tab.
|
| + EXPECT_TRUE(tab_manager->DiscardTabImpl());
|
| + EXPECT_TRUE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(0)));
|
| +}
|
| +
|
| } // namespace memory
|
|
|
| #endif // OS_WIN || OS_MAXOSX || OS_LINUX
|
|
|