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

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

Issue 2248873002: Convert WindowOpenDisposition to an enum class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 3 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 "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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 // Disable the protection of recent tabs. 53 // Disable the protection of recent tabs.
54 tab_manager->set_minimum_protection_time_for_tests( 54 tab_manager->set_minimum_protection_time_for_tests(
55 base::TimeDelta::FromMinutes(0)); 55 base::TimeDelta::FromMinutes(0));
56 56
57 // Get three tabs open. 57 // Get three tabs open.
58 WindowedNotificationObserver load1( 58 WindowedNotificationObserver load1(
59 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 59 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
60 content::NotificationService::AllSources()); 60 content::NotificationService::AllSources());
61 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(), 61 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(),
62 CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false); 62 WindowOpenDisposition::CURRENT_TAB,
63 ui::PAGE_TRANSITION_TYPED, false);
63 browser()->OpenURL(open1); 64 browser()->OpenURL(open1);
64 load1.Wait(); 65 load1.Wait();
65 66
66 WindowedNotificationObserver load2( 67 WindowedNotificationObserver load2(
67 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 68 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
68 content::NotificationService::AllSources()); 69 content::NotificationService::AllSources());
69 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(), 70 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(),
70 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_TYPED, false); 71 WindowOpenDisposition::NEW_FOREGROUND_TAB,
72 ui::PAGE_TRANSITION_TYPED, false);
71 browser()->OpenURL(open2); 73 browser()->OpenURL(open2);
72 load2.Wait(); 74 load2.Wait();
73 75
74 WindowedNotificationObserver load3( 76 WindowedNotificationObserver load3(
75 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 77 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
76 content::NotificationService::AllSources()); 78 content::NotificationService::AllSources());
77 OpenURLParams open3(GURL(chrome::kChromeUITermsURL), content::Referrer(), 79 OpenURLParams open3(GURL(chrome::kChromeUITermsURL), content::Referrer(),
78 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_TYPED, false); 80 WindowOpenDisposition::NEW_FOREGROUND_TAB,
81 ui::PAGE_TRANSITION_TYPED, false);
79 browser()->OpenURL(open3); 82 browser()->OpenURL(open3);
80 load3.Wait(); 83 load3.Wait();
81 84
82 auto* tsm = browser()->tab_strip_model(); 85 auto* tsm = browser()->tab_strip_model();
83 EXPECT_EQ(3, tsm->count()); 86 EXPECT_EQ(3, tsm->count());
84 87
85 // Navigate the current (third) tab to a different URL, so we can test 88 // Navigate the current (third) tab to a different URL, so we can test
86 // back/forward later. 89 // back/forward later.
87 WindowedNotificationObserver load4( 90 WindowedNotificationObserver load4(
88 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 91 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
89 content::NotificationService::AllSources()); 92 content::NotificationService::AllSources());
90 OpenURLParams open4(GURL(chrome::kChromeUIVersionURL), content::Referrer(), 93 OpenURLParams open4(GURL(chrome::kChromeUIVersionURL), content::Referrer(),
91 CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false); 94 WindowOpenDisposition::CURRENT_TAB,
95 ui::PAGE_TRANSITION_TYPED, false);
92 browser()->OpenURL(open4); 96 browser()->OpenURL(open4);
93 load4.Wait(); 97 load4.Wait();
94 98
95 // Navigate the third tab again, such that we have three navigation entries. 99 // Navigate the third tab again, such that we have three navigation entries.
96 WindowedNotificationObserver load5( 100 WindowedNotificationObserver load5(
97 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 101 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
98 content::NotificationService::AllSources()); 102 content::NotificationService::AllSources());
99 OpenURLParams open5(GURL("chrome://dns"), content::Referrer(), CURRENT_TAB, 103 OpenURLParams open5(GURL("chrome://dns"), content::Referrer(),
104 WindowOpenDisposition::CURRENT_TAB,
100 ui::PAGE_TRANSITION_TYPED, false); 105 ui::PAGE_TRANSITION_TYPED, false);
101 browser()->OpenURL(open5); 106 browser()->OpenURL(open5);
102 load5.Wait(); 107 load5.Wait();
103 108
104 EXPECT_EQ(3, tsm->count()); 109 EXPECT_EQ(3, tsm->count());
105 110
106 // Discard a tab. It should kill the first tab, since it was the oldest 111 // Discard a tab. It should kill the first tab, since it was the oldest
107 // and was not selected. 112 // and was not selected.
108 EXPECT_TRUE(tab_manager->DiscardTabImpl()); 113 EXPECT_TRUE(tab_manager->DiscardTabImpl());
109 EXPECT_EQ(3, tsm->count()); 114 EXPECT_EQ(3, tsm->count());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(1))); 166 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(1)));
162 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(2))); 167 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(2)));
163 168
164 // Navigate the third tab back twice. We used to crash here due to 169 // Navigate the third tab back twice. We used to crash here due to
165 // crbug.com/121373. 170 // crbug.com/121373.
166 EXPECT_TRUE(chrome::CanGoBack(browser())); 171 EXPECT_TRUE(chrome::CanGoBack(browser()));
167 EXPECT_FALSE(chrome::CanGoForward(browser())); 172 EXPECT_FALSE(chrome::CanGoForward(browser()));
168 WindowedNotificationObserver back1( 173 WindowedNotificationObserver back1(
169 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 174 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
170 content::NotificationService::AllSources()); 175 content::NotificationService::AllSources());
171 chrome::GoBack(browser(), CURRENT_TAB); 176 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB);
172 back1.Wait(); 177 back1.Wait();
173 EXPECT_TRUE(chrome::CanGoBack(browser())); 178 EXPECT_TRUE(chrome::CanGoBack(browser()));
174 EXPECT_TRUE(chrome::CanGoForward(browser())); 179 EXPECT_TRUE(chrome::CanGoForward(browser()));
175 WindowedNotificationObserver back2( 180 WindowedNotificationObserver back2(
176 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 181 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
177 content::NotificationService::AllSources()); 182 content::NotificationService::AllSources());
178 chrome::GoBack(browser(), CURRENT_TAB); 183 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB);
179 back2.Wait(); 184 back2.Wait();
180 EXPECT_FALSE(chrome::CanGoBack(browser())); 185 EXPECT_FALSE(chrome::CanGoBack(browser()));
181 EXPECT_TRUE(chrome::CanGoForward(browser())); 186 EXPECT_TRUE(chrome::CanGoForward(browser()));
182 } 187 }
183 188
184 // On Linux, memory pressure listener is not implemented yet. 189 // On Linux, memory pressure listener is not implemented yet.
185 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) 190 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
186 191
187 // Test that the MemoryPressureListener event is properly triggering a tab 192 // Test that the MemoryPressureListener event is properly triggering a tab
188 // discard upon |MEMORY_PRESSURE_LEVEL_CRITICAL| event. 193 // discard upon |MEMORY_PRESSURE_LEVEL_CRITICAL| event.
189 IN_PROC_BROWSER_TEST_F(TabManagerTest, OomPressureListener) { 194 IN_PROC_BROWSER_TEST_F(TabManagerTest, OomPressureListener) {
190 TabManager* tab_manager = g_browser_process->GetTabManager(); 195 TabManager* tab_manager = g_browser_process->GetTabManager();
191 196
192 // Disable the protection of recent tabs. 197 // Disable the protection of recent tabs.
193 tab_manager->set_minimum_protection_time_for_tests( 198 tab_manager->set_minimum_protection_time_for_tests(
194 base::TimeDelta::FromMinutes(0)); 199 base::TimeDelta::FromMinutes(0));
195 200
196 // Get three tabs open. 201 // Get three tabs open.
197 content::WindowedNotificationObserver load1( 202 content::WindowedNotificationObserver load1(
198 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 203 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
199 content::NotificationService::AllSources()); 204 content::NotificationService::AllSources());
200 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(), 205 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(),
201 CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false); 206 WindowOpenDisposition::CURRENT_TAB,
207 ui::PAGE_TRANSITION_TYPED, false);
202 browser()->OpenURL(open1); 208 browser()->OpenURL(open1);
203 load1.Wait(); 209 load1.Wait();
204 210
205 content::WindowedNotificationObserver load2( 211 content::WindowedNotificationObserver load2(
206 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 212 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
207 content::NotificationService::AllSources()); 213 content::NotificationService::AllSources());
208 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(), 214 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(),
209 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_TYPED, false); 215 WindowOpenDisposition::NEW_FOREGROUND_TAB,
216 ui::PAGE_TRANSITION_TYPED, false);
210 browser()->OpenURL(open2); 217 browser()->OpenURL(open2);
211 load2.Wait(); 218 load2.Wait();
212 EXPECT_FALSE(tab_manager->recent_tab_discard()); 219 EXPECT_FALSE(tab_manager->recent_tab_discard());
213 220
214 // Nothing should happen with a moderate memory pressure event. 221 // Nothing should happen with a moderate memory pressure event.
215 base::MemoryPressureListener::NotifyMemoryPressure( 222 base::MemoryPressureListener::NotifyMemoryPressure(
216 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE); 223 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE);
217 EXPECT_FALSE(tab_manager->recent_tab_discard()); 224 EXPECT_FALSE(tab_manager->recent_tab_discard());
218 225
219 // A critical memory pressure event should discard a tab. 226 // A critical memory pressure event should discard a tab.
(...skipping 22 matching lines...) Expand all
242 // Disable the protection of recent tabs. 249 // Disable the protection of recent tabs.
243 tab_manager->set_minimum_protection_time_for_tests( 250 tab_manager->set_minimum_protection_time_for_tests(
244 base::TimeDelta::FromMinutes(0)); 251 base::TimeDelta::FromMinutes(0));
245 252
246 // Open two tabs. Wait for the foreground one to load but do not wait for the 253 // Open two tabs. Wait for the foreground one to load but do not wait for the
247 // background one. 254 // background one.
248 content::WindowedNotificationObserver load1( 255 content::WindowedNotificationObserver load1(
249 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 256 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
250 content::NotificationService::AllSources()); 257 content::NotificationService::AllSources());
251 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(), 258 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(),
252 CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false); 259 WindowOpenDisposition::CURRENT_TAB,
260 ui::PAGE_TRANSITION_TYPED, false);
253 browser()->OpenURL(open1); 261 browser()->OpenURL(open1);
254 load1.Wait(); 262 load1.Wait();
255 263
256 content::WindowedNotificationObserver load2( 264 content::WindowedNotificationObserver load2(
257 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 265 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
258 content::NotificationService::AllSources()); 266 content::NotificationService::AllSources());
259 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(), 267 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(),
260 NEW_BACKGROUND_TAB, ui::PAGE_TRANSITION_TYPED, false); 268 WindowOpenDisposition::NEW_BACKGROUND_TAB,
269 ui::PAGE_TRANSITION_TYPED, false);
261 browser()->OpenURL(open2); 270 browser()->OpenURL(open2);
262 271
263 ASSERT_EQ(2, browser()->tab_strip_model()->count()); 272 ASSERT_EQ(2, browser()->tab_strip_model()->count());
264 273
265 // This shouldn't be able to discard a tab as the background tab has not yet 274 // This shouldn't be able to discard a tab as the background tab has not yet
266 // started loading (its URL is not committed). 275 // started loading (its URL is not committed).
267 EXPECT_FALSE(tab_manager->DiscardTabImpl()); 276 EXPECT_FALSE(tab_manager->DiscardTabImpl());
268 277
269 // Wait for the background tab to load which then allows it to be discarded. 278 // Wait for the background tab to load which then allows it to be discarded.
270 load2.Wait(); 279 load2.Wait();
271 EXPECT_TRUE(tab_manager->DiscardTabImpl()); 280 EXPECT_TRUE(tab_manager->DiscardTabImpl());
272 } 281 }
273 282
274 // Makes sure that PDF pages are protected. 283 // Makes sure that PDF pages are protected.
275 IN_PROC_BROWSER_TEST_F(TabManagerTest, ProtectPDFPages) { 284 IN_PROC_BROWSER_TEST_F(TabManagerTest, ProtectPDFPages) {
276 TabManager* tab_manager = g_browser_process->GetTabManager(); 285 TabManager* tab_manager = g_browser_process->GetTabManager();
277 286
278 // Start the embedded test server so we can get served the required PDF page. 287 // Start the embedded test server so we can get served the required PDF page.
279 ASSERT_TRUE(embedded_test_server()->InitializeAndListen()); 288 ASSERT_TRUE(embedded_test_server()->InitializeAndListen());
280 embedded_test_server()->StartAcceptingConnections(); 289 embedded_test_server()->StartAcceptingConnections();
281 290
282 // Get two tabs open, the first one being a PDF page and the second one being 291 // Get two tabs open, the first one being a PDF page and the second one being
283 // the foreground tab. 292 // the foreground tab.
284 GURL url1 = embedded_test_server()->GetURL("/pdf/test.pdf"); 293 GURL url1 = embedded_test_server()->GetURL("/pdf/test.pdf");
285 ui_test_utils::NavigateToURL(browser(), url1); 294 ui_test_utils::NavigateToURL(browser(), url1);
286 295
287 GURL url2(chrome::kChromeUIAboutURL); 296 GURL url2(chrome::kChromeUIAboutURL);
288 ui_test_utils::NavigateToURLWithDisposition( 297 ui_test_utils::NavigateToURLWithDisposition(
289 browser(), url2, NEW_FOREGROUND_TAB, 298 browser(), url2, WindowOpenDisposition::NEW_FOREGROUND_TAB,
290 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 299 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
291 300
292 // No discarding should be possible as the only background tab is displaying a 301 // No discarding should be possible as the only background tab is displaying a
293 // PDF page, hence protected. 302 // PDF page, hence protected.
294 EXPECT_FALSE(tab_manager->DiscardTabImpl()); 303 EXPECT_FALSE(tab_manager->DiscardTabImpl());
295 } 304 }
296 305
297 // Makes sure that recently opened or used tabs are protected, depending on the 306 // Makes sure that recently opened or used tabs are protected, depending on the
298 // value of of |minimum_protection_time_|. 307 // value of of |minimum_protection_time_|.
299 // TODO(georgesak): Move this to a unit test instead (requires change to API). 308 // TODO(georgesak): Move this to a unit test instead (requires change to API).
300 IN_PROC_BROWSER_TEST_F(TabManagerTest, ProtectRecentlyUsedTabs) { 309 IN_PROC_BROWSER_TEST_F(TabManagerTest, ProtectRecentlyUsedTabs) {
301 // TODO(georgesak): Retrieve this value from tab_manager.h once it becomes a 310 // TODO(georgesak): Retrieve this value from tab_manager.h once it becomes a
302 // constant (as of now, it gets set through variations). 311 // constant (as of now, it gets set through variations).
303 const int kProtectionTime = 5; 312 const int kProtectionTime = 5;
304 TabManager* tab_manager = g_browser_process->GetTabManager(); 313 TabManager* tab_manager = g_browser_process->GetTabManager();
305 314
306 base::SimpleTestTickClock test_clock_; 315 base::SimpleTestTickClock test_clock_;
307 tab_manager->set_test_tick_clock(&test_clock_); 316 tab_manager->set_test_tick_clock(&test_clock_);
308 317
309 auto* tsm = browser()->tab_strip_model(); 318 auto* tsm = browser()->tab_strip_model();
310 319
311 // Set the minimum time of protection. 320 // Set the minimum time of protection.
312 tab_manager->set_minimum_protection_time_for_tests( 321 tab_manager->set_minimum_protection_time_for_tests(
313 base::TimeDelta::FromMinutes(kProtectionTime)); 322 base::TimeDelta::FromMinutes(kProtectionTime));
314 323
315 // Open 2 tabs, the second one being in the background. 324 // Open 2 tabs, the second one being in the background.
316 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); 325 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL));
317 ui_test_utils::NavigateToURLWithDisposition( 326 ui_test_utils::NavigateToURLWithDisposition(
318 browser(), GURL(chrome::kChromeUIAboutURL), NEW_BACKGROUND_TAB, 327 browser(), GURL(chrome::kChromeUIAboutURL),
328 WindowOpenDisposition::NEW_BACKGROUND_TAB,
319 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 329 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
320 EXPECT_EQ(2, tsm->count()); 330 EXPECT_EQ(2, tsm->count());
321 331
322 // Advance the clock for less than the protection time. 332 // Advance the clock for less than the protection time.
323 test_clock_.Advance(base::TimeDelta::FromMinutes(kProtectionTime / 2)); 333 test_clock_.Advance(base::TimeDelta::FromMinutes(kProtectionTime / 2));
324 334
325 // Should not be able to discard a tab. 335 // Should not be able to discard a tab.
326 ASSERT_FALSE(tab_manager->DiscardTabImpl()); 336 ASSERT_FALSE(tab_manager->DiscardTabImpl());
327 337
328 // Advance the clock for more than the protection time. 338 // Advance the clock for more than the protection time.
(...skipping 27 matching lines...) Expand all
356 IN_PROC_BROWSER_TEST_F(TabManagerTest, ProtectVideoTabs) { 366 IN_PROC_BROWSER_TEST_F(TabManagerTest, ProtectVideoTabs) {
357 TabManager* tab_manager = g_browser_process->GetTabManager(); 367 TabManager* tab_manager = g_browser_process->GetTabManager();
358 368
359 // Disable the protection of recent tabs. 369 // Disable the protection of recent tabs.
360 tab_manager->set_minimum_protection_time_for_tests( 370 tab_manager->set_minimum_protection_time_for_tests(
361 base::TimeDelta::FromMinutes(0)); 371 base::TimeDelta::FromMinutes(0));
362 372
363 // Open 2 tabs, the second one being in the background. 373 // Open 2 tabs, the second one being in the background.
364 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); 374 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL));
365 ui_test_utils::NavigateToURLWithDisposition( 375 ui_test_utils::NavigateToURLWithDisposition(
366 browser(), GURL(chrome::kChromeUIAboutURL), NEW_BACKGROUND_TAB, 376 browser(), GURL(chrome::kChromeUIAboutURL),
377 WindowOpenDisposition::NEW_BACKGROUND_TAB,
367 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 378 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
368 379
369 auto* tab = browser()->tab_strip_model()->GetWebContentsAt(1); 380 auto* tab = browser()->tab_strip_model()->GetWebContentsAt(1);
370 381
371 // Simulate that a video stream is now being captured. 382 // Simulate that a video stream is now being captured.
372 content::MediaStreamDevice fake_media_device( 383 content::MediaStreamDevice fake_media_device(
373 content::MEDIA_DEVICE_VIDEO_CAPTURE, "fake_media_device", 384 content::MEDIA_DEVICE_VIDEO_CAPTURE, "fake_media_device",
374 "fake_media_device"); 385 "fake_media_device");
375 content::MediaStreamDevices video_devices(1, fake_media_device); 386 content::MediaStreamDevices video_devices(1, fake_media_device);
376 MediaCaptureDevicesDispatcher* dispatcher = 387 MediaCaptureDevicesDispatcher* dispatcher =
(...skipping 20 matching lines...) Expand all
397 408
398 // Disable the protection of recent tabs. 409 // Disable the protection of recent tabs.
399 tab_manager->set_minimum_protection_time_for_tests( 410 tab_manager->set_minimum_protection_time_for_tests(
400 base::TimeDelta::FromMinutes(0)); 411 base::TimeDelta::FromMinutes(0));
401 412
402 // Get two tabs open. 413 // Get two tabs open.
403 WindowedNotificationObserver load1( 414 WindowedNotificationObserver load1(
404 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 415 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
405 content::NotificationService::AllSources()); 416 content::NotificationService::AllSources());
406 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(), 417 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(),
407 CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false); 418 WindowOpenDisposition::CURRENT_TAB,
419 ui::PAGE_TRANSITION_TYPED, false);
408 browser()->OpenURL(open1); 420 browser()->OpenURL(open1);
409 load1.Wait(); 421 load1.Wait();
410 422
411 WindowedNotificationObserver load2( 423 WindowedNotificationObserver load2(
412 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 424 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
413 content::NotificationService::AllSources()); 425 content::NotificationService::AllSources());
414 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(), 426 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(),
415 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_TYPED, false); 427 WindowOpenDisposition::NEW_FOREGROUND_TAB,
428 ui::PAGE_TRANSITION_TYPED, false);
416 browser()->OpenURL(open2); 429 browser()->OpenURL(open2);
417 load2.Wait(); 430 load2.Wait();
418 431
419 // Set the auto-discardable state of the first tab to false. 432 // Set the auto-discardable state of the first tab to false.
420 auto tsm = browser()->tab_strip_model(); 433 auto tsm = browser()->tab_strip_model();
421 ASSERT_EQ(2, tsm->count()); 434 ASSERT_EQ(2, tsm->count());
422 tab_manager->SetTabAutoDiscardableState(tsm->GetWebContentsAt(0), false); 435 tab_manager->SetTabAutoDiscardableState(tsm->GetWebContentsAt(0), false);
423 436
424 // Shouldn't discard the tab, since auto-discardable is deactivated. 437 // Shouldn't discard the tab, since auto-discardable is deactivated.
425 EXPECT_FALSE(tab_manager->DiscardTabImpl()); 438 EXPECT_FALSE(tab_manager->DiscardTabImpl());
426 439
427 // Reset auto-discardable state to true. 440 // Reset auto-discardable state to true.
428 tab_manager->SetTabAutoDiscardableState(tsm->GetWebContentsAt(0), true); 441 tab_manager->SetTabAutoDiscardableState(tsm->GetWebContentsAt(0), true);
429 442
430 // Now it should be able to discard the tab. 443 // Now it should be able to discard the tab.
431 EXPECT_TRUE(tab_manager->DiscardTabImpl()); 444 EXPECT_TRUE(tab_manager->DiscardTabImpl());
432 EXPECT_TRUE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(0))); 445 EXPECT_TRUE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(0)));
433 } 446 }
434 447
435 } // namespace memory 448 } // namespace memory
436 449
437 #endif // OS_WIN || OS_MAXOSX || OS_LINUX 450 #endif // OS_WIN || OS_MAXOSX || OS_LINUX
OLDNEW
« no previous file with comments | « chrome/browser/media/defer_background_media_browsertest.cc ('k') | chrome/browser/memory/tab_manager_observer_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698