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

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

Issue 2462513002: Add Resume logic of Purge+Suspend to TabManager. (Closed)
Patch Set: Fixed 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/memory/tab_manager_web_contents_data.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_web_contents_data.h" 5 #include "chrome/browser/memory/tab_manager_web_contents_data.h"
6 6
7 #include "base/test/histogram_tester.h" 7 #include "base/test/histogram_tester.h"
8 #include "base/test/simple_test_tick_clock.h" 8 #include "base/test/simple_test_tick_clock.h"
9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 EXPECT_EQ(1, 201 EXPECT_EQ(1,
202 histograms.GetTotalCountsForPrefix(kHistogramName).begin()->second); 202 histograms.GetTotalCountsForPrefix(kHistogramName).begin()->second);
203 203
204 histograms.ExpectBucketCount(kHistogramName, 12000, 1); 204 histograms.ExpectBucketCount(kHistogramName, 12000, 1);
205 } 205 }
206 206
207 TEST_F(TabManagerWebContentsDataTest, PurgeAndSuspendState) { 207 TEST_F(TabManagerWebContentsDataTest, PurgeAndSuspendState) {
208 EXPECT_EQ(TabManager::RUNNING, tab_data()->GetPurgeAndSuspendState()); 208 EXPECT_EQ(TabManager::RUNNING, tab_data()->GetPurgeAndSuspendState());
209 base::TimeTicks last_modified = tab_data()->LastPurgeAndSuspendModifiedTime(); 209 base::TimeTicks last_modified = tab_data()->LastPurgeAndSuspendModifiedTime();
210 test_clock().Advance(base::TimeDelta::FromSeconds(5));
210 tab_data()->SetPurgeAndSuspendState(TabManager::SUSPENDED); 211 tab_data()->SetPurgeAndSuspendState(TabManager::SUSPENDED);
211 EXPECT_EQ(TabManager::SUSPENDED, tab_data()->GetPurgeAndSuspendState()); 212 EXPECT_EQ(TabManager::SUSPENDED, tab_data()->GetPurgeAndSuspendState());
212 EXPECT_GT(tab_data()->LastPurgeAndSuspendModifiedTime(), last_modified); 213 EXPECT_GT(tab_data()->LastPurgeAndSuspendModifiedTime(), last_modified);
213 214
214 last_modified = tab_data()->LastPurgeAndSuspendModifiedTime(); 215 last_modified = tab_data()->LastPurgeAndSuspendModifiedTime();
216 test_clock().Advance(base::TimeDelta::FromSeconds(5));
215 tab_data()->SetPurgeAndSuspendState(TabManager::RESUMED); 217 tab_data()->SetPurgeAndSuspendState(TabManager::RESUMED);
216 EXPECT_EQ(TabManager::RESUMED, tab_data()->GetPurgeAndSuspendState()); 218 EXPECT_EQ(TabManager::RESUMED, tab_data()->GetPurgeAndSuspendState());
217 EXPECT_GE(tab_data()->LastPurgeAndSuspendModifiedTime(), last_modified); 219 EXPECT_GT(tab_data()->LastPurgeAndSuspendModifiedTime(), last_modified);
218 220
219 last_modified = tab_data()->LastPurgeAndSuspendModifiedTime(); 221 last_modified = tab_data()->LastPurgeAndSuspendModifiedTime();
222 test_clock().Advance(base::TimeDelta::FromSeconds(5));
220 tab_data()->SetPurgeAndSuspendState(TabManager::RUNNING); 223 tab_data()->SetPurgeAndSuspendState(TabManager::RUNNING);
221 EXPECT_EQ(TabManager::RUNNING, tab_data()->GetPurgeAndSuspendState()); 224 EXPECT_EQ(TabManager::RUNNING, tab_data()->GetPurgeAndSuspendState());
222 EXPECT_GE(tab_data()->LastPurgeAndSuspendModifiedTime(), last_modified); 225 EXPECT_GT(tab_data()->LastPurgeAndSuspendModifiedTime(), last_modified);
223 } 226 }
224 227
225 } // namespace memory 228 } // namespace memory
OLDNEW
« no previous file with comments | « chrome/browser/memory/tab_manager_web_contents_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698