Chromium Code Reviews| 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..e0b8a1671b28fb38ee1d15a5f512597122e91008 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); |
|
Georges Khalil
2016/07/22 17:43:08
Let's use the new function?
Anderson Silva
2016/07/22 18:29:25
The new function is in another ongoing CL (http://
|
| + |
| + // 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 disactivated. |
| + 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 |