Index: chrome/browser/memory/tab_manager_delegate_chromeos_unittest.cc |
diff --git a/chrome/browser/memory/tab_manager_delegate_chromeos_unittest.cc b/chrome/browser/memory/tab_manager_delegate_chromeos_unittest.cc |
index 8d10119c877e32eeedee61d2573ad3bd9aea5697..7b6572fc370fd1c5bb90a3553e3f80db96f211ff 100644 |
--- a/chrome/browser/memory/tab_manager_delegate_chromeos_unittest.cc |
+++ b/chrome/browser/memory/tab_manager_delegate_chromeos_unittest.cc |
@@ -233,6 +233,12 @@ TEST_F(TabManagerDelegateTest, SetOomScoreAdj) { |
3, 30, "service", arc::mojom::ProcessState::SERVICE, kNotFocused, 500); |
arc_processes.emplace_back(4, 40, "visible2", arc::mojom::ProcessState::TOP, |
kNotFocused, 150); |
+ arc_processes.emplace_back(5, 50, "persistent", |
+ arc::mojom::ProcessState::PERSISTENT, kNotFocused, |
+ 600); |
+ arc_processes.emplace_back(6, 60, "persistent_ui", |
+ arc::mojom::ProcessState::PERSISTENT_UI, |
+ kNotFocused, 700); |
TabStats tab1, tab2, tab3, tab4, tab5; |
tab1.is_pinned = true; |
@@ -252,20 +258,29 @@ TEST_F(TabManagerDelegateTest, SetOomScoreAdj) { |
tab5.renderer_handle = 12; |
TabStatsList tab_list = {tab1, tab2, tab3, tab4, tab5}; |
- // Sorted order: |
- // app "focused" pid: 10 |
- // app "visible1" pid: 20 |
- // app "visible2" pid: 40 |
- // tab3 pid: 12 |
- // tab4 pid: 12 |
- // tab1 pid: 11 |
- // tab5 pid: 12 |
- // tab2 pid: 11 |
- // app "service" pid: 30 |
+ // Sorted order (by GetSortedCandidates): |
+ // app "focused" pid: 10 |
+ // app "persistent" pid: 50 |
+ // app "persistent_ui" pid: 60 |
+ // app "visible1" pid: 20 |
+ // app "visible2" pid: 40 |
+ // tab3 pid: 12 |
+ // tab4 pid: 12 |
+ // tab1 pid: 11 |
+ // tab5 pid: 12 |
+ // tab2 pid: 11 |
+ // app "service" pid: 30 |
tab_manager_delegate.AdjustOomPrioritiesImpl(tab_list, arc_processes); |
auto& oom_score_map = tab_manager_delegate.oom_score_map_; |
- EXPECT_EQ(6U, oom_score_map.size()); |
+ // 6 PIDs for apps + 2 PIDs for tabs. |
+ EXPECT_EQ(6U + 2U, oom_score_map.size()); |
+ |
+ // Non-killable part. AdjustOomPrioritiesImpl() does make a focused app/tab |
+ // kernel-killable, but does not do that for PERSISTENT and PERSISTENT_UI |
+ // apps. |
+ EXPECT_EQ(TabManagerDelegate::kLowestOomScore, oom_score_map[50]); |
+ EXPECT_EQ(TabManagerDelegate::kLowestOomScore, oom_score_map[60]); |
// Higher priority part. |
EXPECT_EQ(300, oom_score_map[10]); |
@@ -368,6 +383,9 @@ TEST_F(TabManagerDelegateTest, KillMultipleProcesses) { |
arc_processes.emplace_back(5, 50, "not-visible", |
arc::mojom::ProcessState::IMPORTANT_BACKGROUND, |
kNotFocused, 300); |
+ arc_processes.emplace_back(6, 60, "persistent", |
+ arc::mojom::ProcessState::PERSISTENT, kNotFocused, |
+ 400); |
TabStats tab1, tab2, tab3, tab4, tab5; |
tab1.is_pinned = true; |
@@ -392,8 +410,9 @@ TEST_F(TabManagerDelegateTest, KillMultipleProcesses) { |
tab5.tab_contents_id = 5; |
TabStatsList tab_list = {tab1, tab2, tab3, tab4, tab5}; |
- // Sorted order: |
+ // Sorted order (by GetSortedCandidates): |
// app "focused" pid: 10 nspid 1 |
+ // app "persistent" pid: 60 nspid 6 |
// app "visible1" pid: 20 nspid 2 |
// app "visible2" pid: 40 nspid 4 |
// tab3 pid: 12 tab_contents_id 3 |
@@ -410,6 +429,7 @@ TEST_F(TabManagerDelegateTest, KillMultipleProcesses) { |
memory_stat->SetProcessPss(11, 200000); |
memory_stat->SetProcessPss(12, 30000); |
// Should not be used. |
+ memory_stat->SetProcessPss(60, 500000); |
memory_stat->SetProcessPss(40, 50000); |
memory_stat->SetProcessPss(20, 30000); |
memory_stat->SetProcessPss(10, 100000); |