Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1576)

Unified Diff: chrome/browser/memory/tab_manager_browsertest.cc

Issue 2167843004: Discardable property support on TabManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include AutoDiscardable check on CanDiscard plus tests Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/memory/tab_manager.cc ('k') | chrome/browser/memory/tab_manager_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/browser/memory/tab_manager.cc ('k') | chrome/browser/memory/tab_manager_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698