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

Side by Side Diff: chrome/browser/chromeos/memory/oom_priority_manager_unittest.cc

Issue 1145233002: Revert of Change WebContents::last_active_time_ to Time instead of Timeticks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 17 matching lines...) Expand all
28 kReallyOld, 28 kReallyOld,
29 kOldButPinned, 29 kOldButPinned,
30 kReloadableUI, 30 kReloadableUI,
31 }; 31 };
32 } // namespace 32 } // namespace
33 33
34 // Tests the sorting comparator so that we know it's producing the 34 // Tests the sorting comparator so that we know it's producing the
35 // desired order. 35 // desired order.
36 TEST_F(OomPriorityManagerTest, Comparator) { 36 TEST_F(OomPriorityManagerTest, Comparator) {
37 chromeos::OomPriorityManager::TabStatsList test_list; 37 chromeos::OomPriorityManager::TabStatsList test_list;
38 const base::Time now = base::Time::Now(); 38 const base::TimeTicks now = base::TimeTicks::Now();
39 39
40 // Add kSelected last to verify we are sorting the array. 40 // Add kSelected last to verify we are sorting the array.
41 41
42 { 42 {
43 OomPriorityManager::TabStats stats; 43 OomPriorityManager::TabStats stats;
44 stats.last_active = now;
45 stats.is_pinned = true; 44 stats.is_pinned = true;
46 stats.renderer_handle = kPinned; 45 stats.renderer_handle = kPinned;
47 stats.child_process_host_id = kPinned; 46 stats.child_process_host_id = kPinned;
48 test_list.push_back(stats); 47 test_list.push_back(stats);
49 } 48 }
50 49
51 { 50 {
52 OomPriorityManager::TabStats stats; 51 OomPriorityManager::TabStats stats;
53 stats.last_active = now;
54 stats.is_app = true; 52 stats.is_app = true;
55 stats.renderer_handle = kApp; 53 stats.renderer_handle = kApp;
56 stats.child_process_host_id = kApp; 54 stats.child_process_host_id = kApp;
57 test_list.push_back(stats); 55 test_list.push_back(stats);
58 } 56 }
59 57
60 { 58 {
61 OomPriorityManager::TabStats stats; 59 OomPriorityManager::TabStats stats;
62 stats.last_active = now;
63 stats.is_playing_audio = true; 60 stats.is_playing_audio = true;
64 stats.renderer_handle = kPlayingAudio; 61 stats.renderer_handle = kPlayingAudio;
65 stats.child_process_host_id = kPlayingAudio; 62 stats.child_process_host_id = kPlayingAudio;
66 test_list.push_back(stats); 63 test_list.push_back(stats);
67 } 64 }
68 65
69 { 66 {
70 OomPriorityManager::TabStats stats; 67 OomPriorityManager::TabStats stats;
71 stats.last_active = now - base::TimeDelta::FromSeconds(10); 68 stats.last_active = now - base::TimeDelta::FromSeconds(10);
72 stats.renderer_handle = kRecent; 69 stats.renderer_handle = kRecent;
(...skipping 21 matching lines...) Expand all
94 OomPriorityManager::TabStats stats; 91 OomPriorityManager::TabStats stats;
95 stats.is_pinned = true; 92 stats.is_pinned = true;
96 stats.last_active = now - base::TimeDelta::FromDays(365); 93 stats.last_active = now - base::TimeDelta::FromDays(365);
97 stats.renderer_handle = kOldButPinned; 94 stats.renderer_handle = kOldButPinned;
98 stats.child_process_host_id = kOldButPinned; 95 stats.child_process_host_id = kOldButPinned;
99 test_list.push_back(stats); 96 test_list.push_back(stats);
100 } 97 }
101 98
102 { 99 {
103 OomPriorityManager::TabStats stats; 100 OomPriorityManager::TabStats stats;
104 stats.last_active = now;
105 stats.is_reloadable_ui = true; 101 stats.is_reloadable_ui = true;
106 stats.renderer_handle = kReloadableUI; 102 stats.renderer_handle = kReloadableUI;
107 stats.child_process_host_id = kReloadableUI; 103 stats.child_process_host_id = kReloadableUI;
108 test_list.push_back(stats); 104 test_list.push_back(stats);
109 } 105 }
110 106
111 // This entry sorts to the front, so by adding it last we verify that 107 // This entry sorts to the front, so by adding it last we verify that
112 // we are actually sorting the array. 108 // we are actually sorting the array.
113 { 109 {
114 OomPriorityManager::TabStats stats; 110 OomPriorityManager::TabStats stats;
115 stats.last_active = now;
116 stats.is_selected = true; 111 stats.is_selected = true;
117 stats.renderer_handle = kSelected; 112 stats.renderer_handle = kSelected;
118 stats.child_process_host_id = kSelected; 113 stats.child_process_host_id = kSelected;
119 test_list.push_back(stats); 114 test_list.push_back(stats);
120 } 115 }
121 116
122 std::sort(test_list.begin(), 117 std::sort(test_list.begin(),
123 test_list.end(), 118 test_list.end(),
124 OomPriorityManager::CompareTabStats); 119 OomPriorityManager::CompareTabStats);
125 120
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 process_id_pairs = 212 process_id_pairs =
218 OomPriorityManager::GetChildProcessInfos(same_process_list); 213 OomPriorityManager::GetChildProcessInfos(same_process_list);
219 EXPECT_EQ(2u, process_id_pairs.size()); 214 EXPECT_EQ(2u, process_id_pairs.size());
220 EXPECT_EQ(100, process_id_pairs[0].first); 215 EXPECT_EQ(100, process_id_pairs[0].first);
221 EXPECT_EQ(101, process_id_pairs[0].second); 216 EXPECT_EQ(101, process_id_pairs[0].second);
222 EXPECT_EQ(200, process_id_pairs[1].first); 217 EXPECT_EQ(200, process_id_pairs[1].first);
223 EXPECT_EQ(201, process_id_pairs[1].second); 218 EXPECT_EQ(201, process_id_pairs[1].second);
224 } 219 }
225 220
226 } // namespace chromeos 221 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/memory/oom_priority_manager.h ('k') | components/devtools_discovery/basic_target_descriptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698