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

Side by Side Diff: chrome/browser/memory/tab_manager_delegate_chromeos_unittest.cc

Issue 2571763003: Reduce FakeArcBridgeService usage. (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/memory/tab_manager_delegate_chromeos.h" 5 #include "chrome/browser/memory/tab_manager_delegate_chromeos.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/test/ash_test_base.h" 13 #include "ash/test/ash_test_base.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/process/process_handle.h" 17 #include "base/process/process_handle.h"
18 #include "chrome/browser/chromeos/arc/process/arc_process.h" 18 #include "chrome/browser/chromeos/arc/process/arc_process.h"
19 #include "chrome/browser/memory/tab_manager.h" 19 #include "chrome/browser/memory/tab_manager.h"
20 #include "chrome/browser/memory/tab_stats.h" 20 #include "chrome/browser/memory/tab_stats.h"
21 #include "chrome/common/url_constants.h" 21 #include "chrome/common/url_constants.h"
22 #include "chromeos/dbus/fake_debug_daemon_client.h" 22 #include "chromeos/dbus/fake_debug_daemon_client.h"
23 #include "components/arc/common/process.mojom.h" 23 #include "components/arc/common/process.mojom.h"
24 #include "components/arc/test/fake_arc_bridge_service.h"
25 #include "components/exo/shell_surface.h" 24 #include "components/exo/shell_surface.h"
26 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
27 #include "ui/aura/window.h" 26 #include "ui/aura/window.h"
28 #include "ui/wm/public/activation_client.h" 27 #include "ui/wm/public/activation_client.h"
29 #include "url/gurl.h" 28 #include "url/gurl.h"
30 29
31 namespace memory { 30 namespace memory {
32 31
33 using TabManagerDelegateTest = testing::Test; 32 using TabManagerDelegateTest = testing::Test;
34 33
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 process_pss_[pid] = pss; 162 process_pss_[pid] = pss;
164 } 163 }
165 164
166 private: 165 private:
167 int target_memory_to_free_kb_; 166 int target_memory_to_free_kb_;
168 std::map<base::ProcessHandle, int> process_pss_; 167 std::map<base::ProcessHandle, int> process_pss_;
169 }; 168 };
170 169
171 TEST_F(TabManagerDelegateTest, SetOomScoreAdj) { 170 TEST_F(TabManagerDelegateTest, SetOomScoreAdj) {
172 base::MessageLoop message_loop; 171 base::MessageLoop message_loop;
173 arc::FakeArcBridgeService fake_arc_bridge_service;
174 MockTabManagerDelegate tab_manager_delegate; 172 MockTabManagerDelegate tab_manager_delegate;
175 173
176 std::vector<arc::ArcProcess> arc_processes; 174 std::vector<arc::ArcProcess> arc_processes;
177 arc_processes.emplace_back(1, 10, "focused", arc::mojom::ProcessState::TOP, 175 arc_processes.emplace_back(1, 10, "focused", arc::mojom::ProcessState::TOP,
178 kIsFocused, 100); 176 kIsFocused, 100);
179 arc_processes.emplace_back(2, 20, "visible1", arc::mojom::ProcessState::TOP, 177 arc_processes.emplace_back(2, 20, "visible1", arc::mojom::ProcessState::TOP,
180 kNotFocused, 200); 178 kNotFocused, 200);
181 arc_processes.emplace_back( 179 arc_processes.emplace_back(
182 3, 30, "service", arc::mojom::ProcessState::SERVICE, kNotFocused, 500); 180 3, 30, "service", arc::mojom::ProcessState::SERVICE, kNotFocused, 500);
183 arc_processes.emplace_back(4, 40, "visible2", arc::mojom::ProcessState::TOP, 181 arc_processes.emplace_back(4, 40, "visible2", arc::mojom::ProcessState::TOP,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 EXPECT_EQ(344, oom_score_map[20]); 219 EXPECT_EQ(344, oom_score_map[20]);
222 EXPECT_EQ(388, oom_score_map[40]); 220 EXPECT_EQ(388, oom_score_map[40]);
223 EXPECT_EQ(431, oom_score_map[12]); 221 EXPECT_EQ(431, oom_score_map[12]);
224 EXPECT_EQ(475, oom_score_map[11]); 222 EXPECT_EQ(475, oom_score_map[11]);
225 223
226 // Lower priority part. 224 // Lower priority part.
227 EXPECT_EQ(650, oom_score_map[30]); 225 EXPECT_EQ(650, oom_score_map[30]);
228 } 226 }
229 227
230 TEST_F(TabManagerDelegateTest, KillMultipleProcesses) { 228 TEST_F(TabManagerDelegateTest, KillMultipleProcesses) {
231 arc::FakeArcBridgeService fake_arc_bridge_service;
232
233 // Not owned. 229 // Not owned.
234 MockMemoryStat* memory_stat = new MockMemoryStat(); 230 MockMemoryStat* memory_stat = new MockMemoryStat();
235 231
236 // Instantiate the mock instance. 232 // Instantiate the mock instance.
237 MockTabManagerDelegate tab_manager_delegate(memory_stat); 233 MockTabManagerDelegate tab_manager_delegate(memory_stat);
238 234
239 std::vector<arc::ArcProcess> arc_processes; 235 std::vector<arc::ArcProcess> arc_processes;
240 arc_processes.emplace_back(1, 10, "focused", arc::mojom::ProcessState::TOP, 236 arc_processes.emplace_back(1, 10, "focused", arc::mojom::ProcessState::TOP,
241 kIsFocused, 100); 237 kIsFocused, 100);
242 arc_processes.emplace_back(2, 20, "visible1", arc::mojom::ProcessState::TOP, 238 arc_processes.emplace_back(2, 20, "visible1", arc::mojom::ProcessState::TOP,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // Killed tabs and their content id. 296 // Killed tabs and their content id.
301 // Note that process with pid 11 is counted twice. But so far I don't have a 297 // Note that process with pid 11 is counted twice. But so far I don't have a
302 // good way to estimate the memory freed if multiple tabs share one process. 298 // good way to estimate the memory freed if multiple tabs share one process.
303 EXPECT_EQ(3U, killed_tabs.size()); 299 EXPECT_EQ(3U, killed_tabs.size());
304 EXPECT_EQ(2, killed_tabs[0]); 300 EXPECT_EQ(2, killed_tabs[0]);
305 EXPECT_EQ(5, killed_tabs[1]); 301 EXPECT_EQ(5, killed_tabs[1]);
306 EXPECT_EQ(1, killed_tabs[2]); 302 EXPECT_EQ(1, killed_tabs[2]);
307 } 303 }
308 304
309 } // namespace memory 305 } // namespace memory
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/policy/arc_policy_bridge_unittest.cc ('k') | components/arc/arc_bridge_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698