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

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

Issue 2470073002: Revert of Add Resume logic of Purge+Suspend to TabManager. (Closed)
Patch Set: Created 4 years, 1 month 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_web_contents_data.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/memory/tab_manager_unittest.cc
diff --git a/chrome/browser/memory/tab_manager_unittest.cc b/chrome/browser/memory/tab_manager_unittest.cc
index 409d35586b06595d9749ba97449ade565103ad68..fc9210effcfb06b6e23cb66a16216b9bdc428455 100644
--- a/chrome/browser/memory/tab_manager_unittest.cc
+++ b/chrome/browser/memory/tab_manager_unittest.cc
@@ -671,108 +671,4 @@
ASSERT_TRUE(tabstrip.empty());
}
-TEST_F(TabManagerTest, NextPurgeAndSuspendState) {
- TabManager tab_manager;
- TabStripDummyDelegate delegate;
- TabStripModel tabstrip(&delegate, profile());
- tabstrip.AddObserver(&tab_manager);
-
- WebContents* test_contents = CreateWebContents();
- tabstrip.AppendWebContents(test_contents, false);
-
- base::TimeDelta threshold = base::TimeDelta::FromSeconds(180);
- base::SimpleTestTickClock test_clock;
-
- tab_manager.GetWebContentsData(test_contents)
- ->SetPurgeAndSuspendState(TabManager::RUNNING);
- tab_manager.GetWebContentsData(test_contents)
- ->SetLastPurgeAndSuspendModifiedTimeForTesting(test_clock.NowTicks());
-
- test_clock.Advance(base::TimeDelta::FromSeconds(180));
- EXPECT_EQ(TabManager::RUNNING,
- tab_manager.GetNextPurgeAndSuspendState(
- test_contents, test_clock.NowTicks(), threshold));
-
- test_clock.Advance(base::TimeDelta::FromSeconds(1));
- EXPECT_EQ(TabManager::SUSPENDED,
- tab_manager.GetNextPurgeAndSuspendState(
- test_contents, test_clock.NowTicks(), threshold));
-
- tab_manager.GetWebContentsData(test_contents)
- ->SetPurgeAndSuspendState(TabManager::SUSPENDED);
- tab_manager.GetWebContentsData(test_contents)
- ->SetLastPurgeAndSuspendModifiedTimeForTesting(test_clock.NowTicks());
-
- test_clock.Advance(base::TimeDelta::FromSeconds(120));
- EXPECT_EQ(TabManager::SUSPENDED,
- tab_manager.GetNextPurgeAndSuspendState(
- test_contents, test_clock.NowTicks(), threshold));
-
- test_clock.Advance(base::TimeDelta::FromSeconds(1));
- EXPECT_EQ(TabManager::RESUMED,
- tab_manager.GetNextPurgeAndSuspendState(
- test_contents, test_clock.NowTicks(), threshold));
-
- tab_manager.GetWebContentsData(test_contents)
- ->SetPurgeAndSuspendState(TabManager::RESUMED);
- tab_manager.GetWebContentsData(test_contents)
- ->SetLastPurgeAndSuspendModifiedTimeForTesting(test_clock.NowTicks());
-
- test_clock.Advance(base::TimeDelta::FromSeconds(10));
- EXPECT_EQ(TabManager::RESUMED,
- tab_manager.GetNextPurgeAndSuspendState(
- test_contents, test_clock.NowTicks(), threshold));
-
- test_clock.Advance(base::TimeDelta::FromSeconds(1));
- EXPECT_EQ(TabManager::SUSPENDED,
- tab_manager.GetNextPurgeAndSuspendState(
- test_contents, test_clock.NowTicks(), threshold));
-
- // Clean up the tabstrip.
- tabstrip.CloseAllTabs();
- EXPECT_TRUE(tabstrip.empty());
-}
-
-TEST_F(TabManagerTest, ActivateTabResetPurgeAndSuspendState) {
- TabManager tab_manager;
- TabStripDummyDelegate delegate;
- TabStripModel tabstrip(&delegate, profile());
- tabstrip.AddObserver(&tab_manager);
-
- WebContents* tab1 = CreateWebContents();
- WebContents* tab2 = CreateWebContents();
- tabstrip.AppendWebContents(tab1, true);
- tabstrip.AppendWebContents(tab2, false);
-
- base::SimpleTestTickClock test_clock;
-
- // Initially PurgeAndSuspend state should be RUNNING.
- EXPECT_EQ(TabManager::RUNNING,
- tab_manager.GetWebContentsData(tab2)->GetPurgeAndSuspendState());
-
- tab_manager.GetWebContentsData(tab2)->SetPurgeAndSuspendState(
- TabManager::SUSPENDED);
- tab_manager.GetWebContentsData(tab2)
- ->SetLastPurgeAndSuspendModifiedTimeForTesting(test_clock.NowTicks());
-
- // Activate tab2. Tab2's PurgeAndSuspend state should be RUNNING.
- tabstrip.ActivateTabAt(1, true /* user_gesture */);
- EXPECT_EQ(TabManager::RUNNING,
- tab_manager.GetWebContentsData(tab2)->GetPurgeAndSuspendState());
-
- tab_manager.GetWebContentsData(tab1)->SetPurgeAndSuspendState(
- TabManager::RESUMED);
- tab_manager.GetWebContentsData(tab1)
- ->SetLastPurgeAndSuspendModifiedTimeForTesting(test_clock.NowTicks());
-
- // Activate tab1. Tab1's PurgeAndSuspend state should be RUNNING.
- tabstrip.ActivateTabAt(0, true /* user_gesture */);
- EXPECT_EQ(TabManager::RUNNING,
- tab_manager.GetWebContentsData(tab1)->GetPurgeAndSuspendState());
-
- // Clean up the tabstrip.
- tabstrip.CloseAllTabs();
- EXPECT_TRUE(tabstrip.empty());
-}
-
} // namespace memory
« no previous file with comments | « chrome/browser/memory/tab_manager.cc ('k') | chrome/browser/memory/tab_manager_web_contents_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698