Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 11 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 12 #include "chrome/browser/media/media_stream_capture_indicator.h" | 12 #include "chrome/browser/media/media_stream_capture_indicator.h" |
| 13 #include "chrome/browser/memory/tab_manager.h" | 13 #include "chrome/browser/memory/tab_manager.h" |
| 14 #include "chrome/browser/memory/tab_manager_web_contents_data.h" | 14 #include "chrome/browser/memory/tab_manager_web_contents_data.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
| 17 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 17 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 19 #include "chrome/common/chrome_features.h" | 19 #include "chrome/common/chrome_features.h" |
| 20 #include "chrome/common/chrome_switches.h" | |
| 20 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 21 #include "chrome/test/base/in_process_browser_test.h" | 22 #include "chrome/test/base/in_process_browser_test.h" |
| 22 #include "chrome/test/base/interactive_test_utils.h" | 23 #include "chrome/test/base/interactive_test_utils.h" |
| 23 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 24 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
| 25 #include "content/public/common/content_switches.h" | 26 #include "content/public/common/content_switches.h" |
| 26 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
| 27 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 28 | 29 |
| 29 using content::OpenURLParams; | 30 using content::OpenURLParams; |
| 30 | 31 |
| 31 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) | 32 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) |
| 32 | 33 |
| 33 namespace memory { | 34 namespace memory { |
| 34 | 35 |
| 35 class TabManagerTest : public InProcessBrowserTest { | 36 class TabManagerTest : public InProcessBrowserTest { |
| 36 public: | 37 public: |
| 37 // Tab discarding is enabled by default on CrOS. On other platforms, force it | 38 // Tab discarding is enabled by default on CrOS. On other platforms, force it |
| 38 // by turning on the corresponding experiment as some tests assume this | 39 // by turning on the corresponding experiment as some tests assume this |
| 39 // behavior it turned on. | 40 // behavior it turned on. |
| 40 void SetUpCommandLine(base::CommandLine* command_line) override { | 41 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 41 #if !defined(OS_LINUX) | 42 #if !defined(OS_LINUX) |
| 42 command_line->AppendSwitchASCII(switches::kEnableFeatures, | 43 command_line->AppendSwitchASCII(switches::kEnableFeatures, |
| 43 features::kAutomaticTabDiscarding.name); | 44 features::kAutomaticTabDiscarding.name); |
| 44 #endif | 45 #endif |
| 46 command_line->AppendSwitchASCII(switches::kPurgeAndSuspendTime, "1"); | |
|
Georges Khalil
2016/05/10 18:58:58
Do we need this here?
hajimehoshi
2016/05/11 07:23:31
No, Done.
| |
| 45 } | 47 } |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 IN_PROC_BROWSER_TEST_F(TabManagerTest, TabManagerBasics) { | 50 IN_PROC_BROWSER_TEST_F(TabManagerTest, TabManagerBasics) { |
| 49 using content::WindowedNotificationObserver; | 51 using content::WindowedNotificationObserver; |
| 50 TabManager* tab_manager = g_browser_process->GetTabManager(); | 52 TabManager* tab_manager = g_browser_process->GetTabManager(); |
| 51 ASSERT_TRUE(tab_manager); | 53 ASSERT_TRUE(tab_manager); |
| 52 EXPECT_FALSE(tab_manager->recent_tab_discard()); | 54 EXPECT_FALSE(tab_manager->recent_tab_discard()); |
| 53 | 55 |
| 54 // Disable the protection of recent tabs. | 56 // Disable the protection of recent tabs. |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 | 390 |
| 389 // Remove the video stream. | 391 // Remove the video stream. |
| 390 video_stream_ui.reset(); | 392 video_stream_ui.reset(); |
| 391 | 393 |
| 392 // Should be able to discard the background tab now. | 394 // Should be able to discard the background tab now. |
| 393 EXPECT_TRUE(tab_manager->DiscardTabImpl()); | 395 EXPECT_TRUE(tab_manager->DiscardTabImpl()); |
| 394 } | 396 } |
| 395 | 397 |
| 396 } // namespace memory | 398 } // namespace memory |
| 397 | 399 |
| 398 #endif // OS_WIN || OS_CHROMEOS | 400 #endif // OS_WIN || OS_MAXOSX || OS_LINUX |
| OLD | NEW |