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

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

Issue 2167843004: Discardable property support on TabManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include AutoDiscardable check on CanDiscard plus tests Created 4 years, 5 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
« no previous file with comments | « chrome/browser/memory/tab_manager.cc ('k') | chrome/browser/memory/tab_manager_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/base_switches.h" 5 #include "base/base_switches.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/memory/memory_pressure_listener.h" 7 #include "base/memory/memory_pressure_listener.h"
8 #include "base/test/simple_test_tick_clock.h" 8 #include "base/test/simple_test_tick_clock.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 // Should not be able to discard a tab. 386 // Should not be able to discard a tab.
387 ASSERT_FALSE(tab_manager->DiscardTabImpl()); 387 ASSERT_FALSE(tab_manager->DiscardTabImpl());
388 388
389 // Remove the video stream. 389 // Remove the video stream.
390 video_stream_ui.reset(); 390 video_stream_ui.reset();
391 391
392 // Should be able to discard the background tab now. 392 // Should be able to discard the background tab now.
393 EXPECT_TRUE(tab_manager->DiscardTabImpl()); 393 EXPECT_TRUE(tab_manager->DiscardTabImpl());
394 } 394 }
395 395
396 IN_PROC_BROWSER_TEST_F(TabManagerTest, AutoDiscardable) {
397 using content::WindowedNotificationObserver;
398 TabManager* tab_manager = g_browser_process->GetTabManager();
399
400 // Disable the protection of recent tabs.
401 tab_manager->minimum_protection_time_ = base::TimeDelta::FromMinutes(0);
Georges Khalil 2016/07/22 17:43:08 Let's use the new function?
Anderson Silva 2016/07/22 18:29:25 The new function is in another ongoing CL (http://
402
403 // Get two tabs open.
404 WindowedNotificationObserver load1(
405 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
406 content::NotificationService::AllSources());
407 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(),
408 CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false);
409 browser()->OpenURL(open1);
410 load1.Wait();
411
412 WindowedNotificationObserver load2(
413 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
414 content::NotificationService::AllSources());
415 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(),
416 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_TYPED, false);
417 browser()->OpenURL(open2);
418 load2.Wait();
419
420 // Set the auto discardable state of the first tab to false.
421 auto tsm = browser()->tab_strip_model();
422 ASSERT_EQ(2, tsm->count());
423 tab_manager->SetTabAutoDiscardableState(tsm->GetWebContentsAt(0), false);
424
425 // Shouldn't discard the tab, since auto discardable is disactivated.
426 EXPECT_FALSE(tab_manager->DiscardTabImpl());
427
428 // Reset auto discardable state to true.
429 tab_manager->SetTabAutoDiscardableState(tsm->GetWebContentsAt(0), true);
430
431 // Now it should be able to discard the tab.
432 EXPECT_TRUE(tab_manager->DiscardTabImpl());
433 EXPECT_TRUE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(0)));
434 }
435
396 } // namespace memory 436 } // namespace memory
397 437
398 #endif // OS_WIN || OS_MAXOSX || OS_LINUX 438 #endif // OS_WIN || OS_MAXOSX || OS_LINUX
OLDNEW
« no previous file with comments | « chrome/browser/memory/tab_manager.cc ('k') | chrome/browser/memory/tab_manager_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698