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

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

Issue 2704443006: Make time_to_first_suspension's default 1800sec (Closed)
Patch Set: Fixed. Created 3 years, 10 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 "chrome/browser/memory/tab_manager.h" 5 #include "chrome/browser/memory/tab_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 674
675 TEST_F(TabManagerTest, NextPurgeAndSuspendState) { 675 TEST_F(TabManagerTest, NextPurgeAndSuspendState) {
676 TabManager tab_manager; 676 TabManager tab_manager;
677 TabStripDummyDelegate delegate; 677 TabStripDummyDelegate delegate;
678 TabStripModel tabstrip(&delegate, profile()); 678 TabStripModel tabstrip(&delegate, profile());
679 tabstrip.AddObserver(&tab_manager); 679 tabstrip.AddObserver(&tab_manager);
680 680
681 WebContents* test_contents = CreateWebContents(); 681 WebContents* test_contents = CreateWebContents();
682 tabstrip.AppendWebContents(test_contents, false); 682 tabstrip.AppendWebContents(test_contents, false);
683 683
684 base::TimeDelta threshold = base::TimeDelta::FromSeconds(180); 684 // Use default time-to-first-suspension seconds defined in TabManager.
685 base::TimeDelta threshold = base::TimeDelta::FromSeconds(
686 TabManager::kDefaultTimeToFirstPurgeInSeconds);
685 base::SimpleTestTickClock test_clock; 687 base::SimpleTestTickClock test_clock;
686 688
687 tab_manager.GetWebContentsData(test_contents) 689 tab_manager.GetWebContentsData(test_contents)
688 ->SetPurgeAndSuspendState(TabManager::RUNNING); 690 ->SetPurgeAndSuspendState(TabManager::RUNNING);
689 tab_manager.GetWebContentsData(test_contents) 691 tab_manager.GetWebContentsData(test_contents)
690 ->SetLastPurgeAndSuspendModifiedTimeForTesting(test_clock.NowTicks()); 692 ->SetLastPurgeAndSuspendModifiedTimeForTesting(test_clock.NowTicks());
691 693
692 test_clock.Advance(base::TimeDelta::FromSeconds(180)); 694 // Wait 30 minutes. Should be still RUNNING.
Wez 2017/02/22 01:25:10 nit: Comment style is to prefer complete sentences
tasak 2017/02/22 04:18:46 Done.
695 test_clock.Advance(base::TimeDelta::FromMinutes(30));
693 EXPECT_EQ(TabManager::RUNNING, 696 EXPECT_EQ(TabManager::RUNNING,
694 tab_manager.GetNextPurgeAndSuspendState( 697 tab_manager.GetNextPurgeAndSuspendState(
695 test_contents, test_clock.NowTicks(), threshold)); 698 test_contents, test_clock.NowTicks(), threshold));
696 699
700 // > 30 minutes. Should be still SUSPENDED.
Wez 2017/02/22 01:25:10 Do you mean "Should _now_ be SUSPENDED."?
tasak 2017/02/22 04:18:46 Yes, thanks. Done.
697 test_clock.Advance(base::TimeDelta::FromSeconds(1)); 701 test_clock.Advance(base::TimeDelta::FromSeconds(1));
698 EXPECT_EQ(TabManager::SUSPENDED, 702 EXPECT_EQ(TabManager::SUSPENDED,
699 tab_manager.GetNextPurgeAndSuspendState( 703 tab_manager.GetNextPurgeAndSuspendState(
700 test_contents, test_clock.NowTicks(), threshold)); 704 test_contents, test_clock.NowTicks(), threshold));
701 705
702 tab_manager.GetWebContentsData(test_contents) 706 tab_manager.GetWebContentsData(test_contents)
703 ->SetPurgeAndSuspendState(TabManager::SUSPENDED); 707 ->SetPurgeAndSuspendState(TabManager::SUSPENDED);
704 tab_manager.GetWebContentsData(test_contents) 708 tab_manager.GetWebContentsData(test_contents)
705 ->SetLastPurgeAndSuspendModifiedTimeForTesting(test_clock.NowTicks()); 709 ->SetLastPurgeAndSuspendModifiedTimeForTesting(test_clock.NowTicks());
706 710
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 tabstrip.ActivateTabAt(0, true /* user_gesture */); 774 tabstrip.ActivateTabAt(0, true /* user_gesture */);
771 EXPECT_EQ(TabManager::RUNNING, 775 EXPECT_EQ(TabManager::RUNNING,
772 tab_manager.GetWebContentsData(tab1)->GetPurgeAndSuspendState()); 776 tab_manager.GetWebContentsData(tab1)->GetPurgeAndSuspendState());
773 777
774 // Clean up the tabstrip. 778 // Clean up the tabstrip.
775 tabstrip.CloseAllTabs(); 779 tabstrip.CloseAllTabs();
776 EXPECT_TRUE(tabstrip.empty()); 780 EXPECT_TRUE(tabstrip.empty());
777 } 781 }
778 782
779 } // namespace memory 783 } // namespace memory
OLDNEW
« chrome/browser/memory/tab_manager.h ('K') | « chrome/browser/memory/tab_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698