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

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

Issue 1777583003: [TabManager] Disable memory pressure notifications to foreground renderers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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') | no next file » | 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 08f2e8f83cff6882b80aa2cff7b97d2bf30f5b1b..9becd485d9e5b0aab3dcd096b2780c4be87f489c 100644
--- a/chrome/browser/memory/tab_manager_unittest.cc
+++ b/chrome/browser/memory/tab_manager_unittest.cc
@@ -475,13 +475,21 @@ TEST_F(TabManagerTest, ChildProcessNotifications) {
&TabManagerTest::NotifyRendererProcess, base::Unretained(this));
// Create two dummy tabs.
+ auto tab0 = CreateWebContents();
auto tab1 = CreateWebContents();
auto tab2 = CreateWebContents();
- tabstrip.AppendWebContents(tab1, true); // Foreground tab.
- tabstrip.AppendWebContents(tab2, false); // Opened in background.
+ tabstrip.AppendWebContents(tab0, true); // Foreground tab.
+ tabstrip.AppendWebContents(tab1, false); // Background tab.
+ tabstrip.AppendWebContents(tab2, false); // Background tab.
const content::RenderProcessHost* renderer1 = tab1->GetRenderProcessHost();
const content::RenderProcessHost* renderer2 = tab2->GetRenderProcessHost();
+ // Make sure that tab2 has a lower priority than tab1 by its access time.
+ test_clock.Advance(base::TimeDelta::FromMilliseconds(1));
+ tab2->SetLastActiveTime(test_clock.NowTicks());
+ test_clock.Advance(base::TimeDelta::FromMilliseconds(1));
+ tab1->SetLastActiveTime(test_clock.NowTicks());
+
// Expect that the tab manager has not yet encountered memory pressure.
EXPECT_FALSE(tm.under_memory_pressure_);
EXPECT_EQ(0u, tm.notified_renderers_.size());
@@ -499,7 +507,7 @@ TEST_F(TabManagerTest, ChildProcessNotifications) {
// START OF MEMORY PRESSURE
// Simulate a memory pressure situation that persists. This should cause a
- // task to be scheduled.
+ // task to be scheduled, and a background renderer to be notified.
tm.get_current_pressure_level_ = base::Bind(
&ReturnSpecifiedPressure, base::Unretained(&level));
EXPECT_CALL(mock_task_runner, PostDelayedTask(
« no previous file with comments | « chrome/browser/memory/tab_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698