| 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" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 load2.Wait(); | 72 load2.Wait(); |
| 73 | 73 |
| 74 WindowedNotificationObserver load3( | 74 WindowedNotificationObserver load3( |
| 75 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 75 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 76 content::NotificationService::AllSources()); | 76 content::NotificationService::AllSources()); |
| 77 OpenURLParams open3(GURL(chrome::kChromeUITermsURL), content::Referrer(), | 77 OpenURLParams open3(GURL(chrome::kChromeUITermsURL), content::Referrer(), |
| 78 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_TYPED, false); | 78 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_TYPED, false); |
| 79 browser()->OpenURL(open3); | 79 browser()->OpenURL(open3); |
| 80 load3.Wait(); | 80 load3.Wait(); |
| 81 | 81 |
| 82 auto tsm = browser()->tab_strip_model(); | 82 auto* tsm = browser()->tab_strip_model(); |
| 83 EXPECT_EQ(3, tsm->count()); | 83 EXPECT_EQ(3, tsm->count()); |
| 84 | 84 |
| 85 // Navigate the current (third) tab to a different URL, so we can test | 85 // Navigate the current (third) tab to a different URL, so we can test |
| 86 // back/forward later. | 86 // back/forward later. |
| 87 WindowedNotificationObserver load4( | 87 WindowedNotificationObserver load4( |
| 88 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 88 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 89 content::NotificationService::AllSources()); | 89 content::NotificationService::AllSources()); |
| 90 OpenURLParams open4(GURL(chrome::kChromeUIVersionURL), content::Referrer(), | 90 OpenURLParams open4(GURL(chrome::kChromeUIVersionURL), content::Referrer(), |
| 91 CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false); | 91 CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false); |
| 92 browser()->OpenURL(open4); | 92 browser()->OpenURL(open4); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 IN_PROC_BROWSER_TEST_F(TabManagerTest, ProtectRecentlyUsedTabs) { | 301 IN_PROC_BROWSER_TEST_F(TabManagerTest, ProtectRecentlyUsedTabs) { |
| 302 // TODO(georgesak): Retrieve this value from tab_manager.h once it becomes a | 302 // TODO(georgesak): Retrieve this value from tab_manager.h once it becomes a |
| 303 // constant (as of now, it gets set through variations). | 303 // constant (as of now, it gets set through variations). |
| 304 const int kProtectionTime = 5; | 304 const int kProtectionTime = 5; |
| 305 TabManager* tab_manager = g_browser_process->GetTabManager(); | 305 TabManager* tab_manager = g_browser_process->GetTabManager(); |
| 306 ASSERT_TRUE(tab_manager); | 306 ASSERT_TRUE(tab_manager); |
| 307 | 307 |
| 308 base::SimpleTestTickClock test_clock_; | 308 base::SimpleTestTickClock test_clock_; |
| 309 tab_manager->set_test_tick_clock(&test_clock_); | 309 tab_manager->set_test_tick_clock(&test_clock_); |
| 310 | 310 |
| 311 auto tsm = browser()->tab_strip_model(); | 311 auto* tsm = browser()->tab_strip_model(); |
| 312 | 312 |
| 313 // Set the minimum time of protection. | 313 // Set the minimum time of protection. |
| 314 tab_manager->minimum_protection_time_ = | 314 tab_manager->minimum_protection_time_ = |
| 315 base::TimeDelta::FromMinutes(kProtectionTime); | 315 base::TimeDelta::FromMinutes(kProtectionTime); |
| 316 | 316 |
| 317 // Open 2 tabs, the second one being in the background. | 317 // Open 2 tabs, the second one being in the background. |
| 318 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); | 318 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); |
| 319 ui_test_utils::NavigateToURLWithDisposition( | 319 ui_test_utils::NavigateToURLWithDisposition( |
| 320 browser(), GURL(chrome::kChromeUIAboutURL), NEW_BACKGROUND_TAB, | 320 browser(), GURL(chrome::kChromeUIAboutURL), NEW_BACKGROUND_TAB, |
| 321 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 321 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 361 |
| 362 // Disable the protection of recent tabs. | 362 // Disable the protection of recent tabs. |
| 363 tab_manager->minimum_protection_time_ = base::TimeDelta::FromMinutes(0); | 363 tab_manager->minimum_protection_time_ = base::TimeDelta::FromMinutes(0); |
| 364 | 364 |
| 365 // Open 2 tabs, the second one being in the background. | 365 // Open 2 tabs, the second one being in the background. |
| 366 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); | 366 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); |
| 367 ui_test_utils::NavigateToURLWithDisposition( | 367 ui_test_utils::NavigateToURLWithDisposition( |
| 368 browser(), GURL(chrome::kChromeUIAboutURL), NEW_BACKGROUND_TAB, | 368 browser(), GURL(chrome::kChromeUIAboutURL), NEW_BACKGROUND_TAB, |
| 369 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 369 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 370 | 370 |
| 371 auto tab = browser()->tab_strip_model()->GetWebContentsAt(1); | 371 auto* tab = browser()->tab_strip_model()->GetWebContentsAt(1); |
| 372 | 372 |
| 373 // Simulate that a video stream is now being captured. | 373 // Simulate that a video stream is now being captured. |
| 374 content::MediaStreamDevice fake_media_device( | 374 content::MediaStreamDevice fake_media_device( |
| 375 content::MEDIA_DEVICE_VIDEO_CAPTURE, "fake_media_device", | 375 content::MEDIA_DEVICE_VIDEO_CAPTURE, "fake_media_device", |
| 376 "fake_media_device"); | 376 "fake_media_device"); |
| 377 content::MediaStreamDevices video_devices(1, fake_media_device); | 377 content::MediaStreamDevices video_devices(1, fake_media_device); |
| 378 MediaCaptureDevicesDispatcher* dispatcher = | 378 MediaCaptureDevicesDispatcher* dispatcher = |
| 379 MediaCaptureDevicesDispatcher::GetInstance(); | 379 MediaCaptureDevicesDispatcher::GetInstance(); |
| 380 dispatcher->SetTestVideoCaptureDevices(video_devices); | 380 dispatcher->SetTestVideoCaptureDevices(video_devices); |
| 381 std::unique_ptr<content::MediaStreamUI> video_stream_ui = | 381 std::unique_ptr<content::MediaStreamUI> video_stream_ui = |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 tab_manager->SetTabAutoDiscardableState(tsm->GetWebContentsAt(0), true); | 429 tab_manager->SetTabAutoDiscardableState(tsm->GetWebContentsAt(0), true); |
| 430 | 430 |
| 431 // Now it should be able to discard the tab. | 431 // Now it should be able to discard the tab. |
| 432 EXPECT_TRUE(tab_manager->DiscardTabImpl()); | 432 EXPECT_TRUE(tab_manager->DiscardTabImpl()); |
| 433 EXPECT_TRUE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(0))); | 433 EXPECT_TRUE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(0))); |
| 434 } | 434 } |
| 435 | 435 |
| 436 } // namespace memory | 436 } // namespace memory |
| 437 | 437 |
| 438 #endif // OS_WIN || OS_MAXOSX || OS_LINUX | 438 #endif // OS_WIN || OS_MAXOSX || OS_LINUX |
| OLD | NEW |