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

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

Issue 2556393002: Fix TabManagerTest.TabManagerBasics flakiness with PlzNavigate. (Closed)
Patch Set: Created 4 years 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 | « no previous file | no next file » | 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"
11 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" 11 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
12 #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h" 12 #include "chrome/browser/media/webrtc/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/url_constants.h" 20 #include "chrome/common/url_constants.h"
21 #include "chrome/test/base/in_process_browser_test.h" 21 #include "chrome/test/base/in_process_browser_test.h"
22 #include "chrome/test/base/interactive_test_utils.h" 22 #include "chrome/test/base/interactive_test_utils.h"
23 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/notification_types.h" 24 #include "content/public/browser/notification_types.h"
25 #include "content/public/browser/render_process_host.h" 25 #include "content/public/browser/render_process_host.h"
26 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
27 #include "content/public/test/test_navigation_observer.h"
27 #include "content/public/test/test_utils.h" 28 #include "content/public/test/test_utils.h"
28 #include "url/gurl.h" 29 #include "url/gurl.h"
29 30
30 using content::OpenURLParams; 31 using content::OpenURLParams;
31 32
32 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) 33 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
33 34
34 namespace memory { 35 namespace memory {
35 36
36 class TabManagerTest : public InProcessBrowserTest { 37 class TabManagerTest : public InProcessBrowserTest {
37 }; 38 };
38 39
39 IN_PROC_BROWSER_TEST_F(TabManagerTest, TabManagerBasics) { 40 IN_PROC_BROWSER_TEST_F(TabManagerTest, TabManagerBasics) {
40 using content::WindowedNotificationObserver; 41 using content::WindowedNotificationObserver;
41 TabManager* tab_manager = g_browser_process->GetTabManager(); 42 TabManager* tab_manager = g_browser_process->GetTabManager();
42 EXPECT_FALSE(tab_manager->recent_tab_discard()); 43 EXPECT_FALSE(tab_manager->recent_tab_discard());
43 44
44 // Disable the protection of recent tabs. 45 // Disable the protection of recent tabs.
45 tab_manager->set_minimum_protection_time_for_tests( 46 tab_manager->set_minimum_protection_time_for_tests(
46 base::TimeDelta::FromMinutes(0)); 47 base::TimeDelta::FromMinutes(0));
47 48
48 // Get three tabs open. 49 // Get three tabs open.
49 WindowedNotificationObserver load1(
50 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
51 content::NotificationService::AllSources());
52 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(), 50 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(),
53 WindowOpenDisposition::CURRENT_TAB, 51 WindowOpenDisposition::CURRENT_TAB,
54 ui::PAGE_TRANSITION_TYPED, false); 52 ui::PAGE_TRANSITION_TYPED, false);
55 browser()->OpenURL(open1); 53 content::TestNavigationObserver load1(browser()->OpenURL(open1));
56 load1.Wait(); 54 load1.Wait();
57 55
58 WindowedNotificationObserver load2(
59 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
60 content::NotificationService::AllSources());
61 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(), 56 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(),
62 WindowOpenDisposition::NEW_FOREGROUND_TAB, 57 WindowOpenDisposition::NEW_FOREGROUND_TAB,
63 ui::PAGE_TRANSITION_TYPED, false); 58 ui::PAGE_TRANSITION_TYPED, false);
64 browser()->OpenURL(open2); 59 content::TestNavigationObserver load2(browser()->OpenURL(open2));
65 load2.Wait(); 60 load2.Wait();
66 61
67 WindowedNotificationObserver load3(
68 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
69 content::NotificationService::AllSources());
70 OpenURLParams open3(GURL(chrome::kChromeUITermsURL), content::Referrer(), 62 OpenURLParams open3(GURL(chrome::kChromeUITermsURL), content::Referrer(),
71 WindowOpenDisposition::NEW_FOREGROUND_TAB, 63 WindowOpenDisposition::NEW_FOREGROUND_TAB,
72 ui::PAGE_TRANSITION_TYPED, false); 64 ui::PAGE_TRANSITION_TYPED, false);
73 browser()->OpenURL(open3); 65 content::TestNavigationObserver load3(browser()->OpenURL(open3));
74 load3.Wait(); 66 load3.Wait();
75 67
76 auto* tsm = browser()->tab_strip_model(); 68 auto* tsm = browser()->tab_strip_model();
77 EXPECT_EQ(3, tsm->count()); 69 EXPECT_EQ(3, tsm->count());
78 70
79 // Navigate the current (third) tab to a different URL, so we can test 71 // Navigate the current (third) tab to a different URL, so we can test
80 // back/forward later. 72 // back/forward later.
81 WindowedNotificationObserver load4(
82 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
83 content::NotificationService::AllSources());
84 OpenURLParams open4(GURL(chrome::kChromeUIVersionURL), content::Referrer(), 73 OpenURLParams open4(GURL(chrome::kChromeUIVersionURL), content::Referrer(),
85 WindowOpenDisposition::CURRENT_TAB, 74 WindowOpenDisposition::CURRENT_TAB,
86 ui::PAGE_TRANSITION_TYPED, false); 75 ui::PAGE_TRANSITION_TYPED, false);
87 browser()->OpenURL(open4); 76 content::TestNavigationObserver load4(browser()->OpenURL(open4));
88 load4.Wait(); 77 load4.Wait();
89 78
90 // Navigate the third tab again, such that we have three navigation entries. 79 // Navigate the third tab again, such that we have three navigation entries.
91 WindowedNotificationObserver load5(
92 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
93 content::NotificationService::AllSources());
94 OpenURLParams open5(GURL("chrome://dns"), content::Referrer(), 80 OpenURLParams open5(GURL("chrome://dns"), content::Referrer(),
95 WindowOpenDisposition::CURRENT_TAB, 81 WindowOpenDisposition::CURRENT_TAB,
96 ui::PAGE_TRANSITION_TYPED, false); 82 ui::PAGE_TRANSITION_TYPED, false);
97 browser()->OpenURL(open5); 83 content::TestNavigationObserver load5(browser()->OpenURL(open5));
98 load5.Wait(); 84 load5.Wait();
99 85
100 EXPECT_EQ(3, tsm->count()); 86 EXPECT_EQ(3, tsm->count());
101 87
102 // Discard a tab. It should kill the first tab, since it was the oldest 88 // Discard a tab. It should kill the first tab, since it was the oldest
103 // and was not selected. 89 // and was not selected.
104 EXPECT_TRUE(tab_manager->DiscardTabImpl()); 90 EXPECT_TRUE(tab_manager->DiscardTabImpl());
105 EXPECT_EQ(3, tsm->count()); 91 EXPECT_EQ(3, tsm->count());
106 EXPECT_TRUE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(0))); 92 EXPECT_TRUE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(0)));
107 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(1))); 93 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(1)));
(...skipping 18 matching lines...) Expand all
126 tsm->ActivateTabAt(1, true); 112 tsm->ActivateTabAt(1, true);
127 EXPECT_EQ(1, tsm->active_index()); 113 EXPECT_EQ(1, tsm->active_index());
128 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(1))); 114 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(1)));
129 tab_manager->DiscardWebContentsAt(2, tsm); 115 tab_manager->DiscardWebContentsAt(2, tsm);
130 EXPECT_TRUE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(2))); 116 EXPECT_TRUE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(2)));
131 117
132 // Force creation of the FindBarController. 118 // Force creation of the FindBarController.
133 browser()->GetFindBarController(); 119 browser()->GetFindBarController();
134 120
135 // Select the first tab. It should reload. 121 // Select the first tab. It should reload.
136 WindowedNotificationObserver reload1( 122 content::TestNavigationObserver reload1(
137 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 123 browser()->tab_strip_model()->GetWebContentsAt(0));
138 content::NotificationService::AllSources());
139 chrome::SelectNumberedTab(browser(), 0); 124 chrome::SelectNumberedTab(browser(), 0);
140 reload1.Wait(); 125 reload1.Wait();
141 // Make sure the FindBarController gets the right WebContents. 126 // Make sure the FindBarController gets the right WebContents.
142 EXPECT_EQ(browser()->GetFindBarController()->web_contents(), 127 EXPECT_EQ(browser()->GetFindBarController()->web_contents(),
143 tsm->GetActiveWebContents()); 128 tsm->GetActiveWebContents());
144 EXPECT_EQ(0, tsm->active_index()); 129 EXPECT_EQ(0, tsm->active_index());
145 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(0))); 130 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(0)));
146 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(1))); 131 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(1)));
147 EXPECT_TRUE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(2))); 132 EXPECT_TRUE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(2)));
148 133
149 // Select the third tab. It should reload. 134 // Select the third tab. It should reload.
150 WindowedNotificationObserver reload2( 135 content::TestNavigationObserver reload2(
151 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 136 browser()->tab_strip_model()->GetWebContentsAt(2));
152 content::NotificationService::AllSources());
153 chrome::SelectNumberedTab(browser(), 2); 137 chrome::SelectNumberedTab(browser(), 2);
154 reload2.Wait(); 138 reload2.Wait();
155 EXPECT_EQ(2, tsm->active_index()); 139 EXPECT_EQ(2, tsm->active_index());
156 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(0))); 140 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(0)));
157 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(1))); 141 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(1)));
158 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(2))); 142 EXPECT_FALSE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(2)));
159 143
160 // Navigate the third tab back twice. We used to crash here due to 144 // Navigate the third tab back twice. We used to crash here due to
161 // crbug.com/121373. 145 // crbug.com/121373.
162 EXPECT_TRUE(chrome::CanGoBack(browser())); 146 EXPECT_TRUE(chrome::CanGoBack(browser()));
163 EXPECT_FALSE(chrome::CanGoForward(browser())); 147 EXPECT_FALSE(chrome::CanGoForward(browser()));
164 WindowedNotificationObserver back1( 148 content::TestNavigationObserver back1(
165 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 149 browser()->tab_strip_model()->GetActiveWebContents());
166 content::NotificationService::AllSources());
167 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB); 150 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB);
168 back1.Wait(); 151 back1.Wait();
169 EXPECT_TRUE(chrome::CanGoBack(browser())); 152 EXPECT_TRUE(chrome::CanGoBack(browser()));
170 EXPECT_TRUE(chrome::CanGoForward(browser())); 153 EXPECT_TRUE(chrome::CanGoForward(browser()));
171 WindowedNotificationObserver back2( 154 content::TestNavigationObserver back2(
172 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 155 browser()->tab_strip_model()->GetActiveWebContents());
173 content::NotificationService::AllSources());
174 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB); 156 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB);
175 back2.Wait(); 157 back2.Wait();
176 EXPECT_FALSE(chrome::CanGoBack(browser())); 158 EXPECT_FALSE(chrome::CanGoBack(browser()));
177 EXPECT_TRUE(chrome::CanGoForward(browser())); 159 EXPECT_TRUE(chrome::CanGoForward(browser()));
178 } 160 }
179 161
180 // On Linux, memory pressure listener is not implemented yet. 162 // On Linux, memory pressure listener is not implemented yet.
181 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) 163 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
182 164
183 // Test that the MemoryPressureListener event is properly triggering a tab 165 // Test that the MemoryPressureListener event is properly triggering a tab
184 // discard upon |MEMORY_PRESSURE_LEVEL_CRITICAL| event. 166 // discard upon |MEMORY_PRESSURE_LEVEL_CRITICAL| event.
185 IN_PROC_BROWSER_TEST_F(TabManagerTest, OomPressureListener) { 167 IN_PROC_BROWSER_TEST_F(TabManagerTest, OomPressureListener) {
186 TabManager* tab_manager = g_browser_process->GetTabManager(); 168 TabManager* tab_manager = g_browser_process->GetTabManager();
187 169
188 // Disable the protection of recent tabs. 170 // Disable the protection of recent tabs.
189 tab_manager->set_minimum_protection_time_for_tests( 171 tab_manager->set_minimum_protection_time_for_tests(
190 base::TimeDelta::FromMinutes(0)); 172 base::TimeDelta::FromMinutes(0));
191 173
192 // Get three tabs open. 174 // Get three tabs open.
193 content::WindowedNotificationObserver load1(
194 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
195 content::NotificationService::AllSources());
196 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(), 175 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(),
197 WindowOpenDisposition::CURRENT_TAB, 176 WindowOpenDisposition::CURRENT_TAB,
198 ui::PAGE_TRANSITION_TYPED, false); 177 ui::PAGE_TRANSITION_TYPED, false);
199 browser()->OpenURL(open1); 178 content::TestNavigationObserver load1(browser()->OpenURL(open1));
200 load1.Wait(); 179 load1.Wait();
201 180
202 content::WindowedNotificationObserver load2(
203 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
204 content::NotificationService::AllSources());
205 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(), 181 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(),
206 WindowOpenDisposition::NEW_FOREGROUND_TAB, 182 WindowOpenDisposition::NEW_FOREGROUND_TAB,
207 ui::PAGE_TRANSITION_TYPED, false); 183 ui::PAGE_TRANSITION_TYPED, false);
208 browser()->OpenURL(open2); 184 content::TestNavigationObserver load2(browser()->OpenURL(open2));
209 load2.Wait(); 185 load2.Wait();
210 EXPECT_FALSE(tab_manager->recent_tab_discard()); 186 EXPECT_FALSE(tab_manager->recent_tab_discard());
211 187
212 // Nothing should happen with a moderate memory pressure event. 188 // Nothing should happen with a moderate memory pressure event.
213 base::MemoryPressureListener::NotifyMemoryPressure( 189 base::MemoryPressureListener::NotifyMemoryPressure(
214 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE); 190 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE);
215 EXPECT_FALSE(tab_manager->recent_tab_discard()); 191 EXPECT_FALSE(tab_manager->recent_tab_discard());
216 192
217 // A critical memory pressure event should discard a tab. 193 // A critical memory pressure event should discard a tab.
218 base::MemoryPressureListener::NotifyMemoryPressure( 194 base::MemoryPressureListener::NotifyMemoryPressure(
(...skipping 17 matching lines...) Expand all
236 212
237 IN_PROC_BROWSER_TEST_F(TabManagerTest, InvalidOrEmptyURL) { 213 IN_PROC_BROWSER_TEST_F(TabManagerTest, InvalidOrEmptyURL) {
238 TabManager* tab_manager = g_browser_process->GetTabManager(); 214 TabManager* tab_manager = g_browser_process->GetTabManager();
239 215
240 // Disable the protection of recent tabs. 216 // Disable the protection of recent tabs.
241 tab_manager->set_minimum_protection_time_for_tests( 217 tab_manager->set_minimum_protection_time_for_tests(
242 base::TimeDelta::FromMinutes(0)); 218 base::TimeDelta::FromMinutes(0));
243 219
244 // Open two tabs. Wait for the foreground one to load but do not wait for the 220 // Open two tabs. Wait for the foreground one to load but do not wait for the
245 // background one. 221 // background one.
246 content::WindowedNotificationObserver load1(
247 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
248 content::NotificationService::AllSources());
249 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(), 222 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(),
250 WindowOpenDisposition::CURRENT_TAB, 223 WindowOpenDisposition::CURRENT_TAB,
251 ui::PAGE_TRANSITION_TYPED, false); 224 ui::PAGE_TRANSITION_TYPED, false);
252 browser()->OpenURL(open1); 225 content::TestNavigationObserver load1(browser()->OpenURL(open1));
253 load1.Wait(); 226 load1.Wait();
254 227
255 content::WindowedNotificationObserver load2(
256 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
257 content::NotificationService::AllSources());
258 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(), 228 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(),
259 WindowOpenDisposition::NEW_BACKGROUND_TAB, 229 WindowOpenDisposition::NEW_BACKGROUND_TAB,
260 ui::PAGE_TRANSITION_TYPED, false); 230 ui::PAGE_TRANSITION_TYPED, false);
261 browser()->OpenURL(open2); 231 content::TestNavigationObserver load2(browser()->OpenURL(open2));
262 232
263 ASSERT_EQ(2, browser()->tab_strip_model()->count()); 233 ASSERT_EQ(2, browser()->tab_strip_model()->count());
264 234
265 // This shouldn't be able to discard a tab as the background tab has not yet 235 // This shouldn't be able to discard a tab as the background tab has not yet
266 // started loading (its URL is not committed). 236 // started loading (its URL is not committed).
267 EXPECT_FALSE(tab_manager->DiscardTabImpl()); 237 EXPECT_FALSE(tab_manager->DiscardTabImpl());
268 238
269 // Wait for the background tab to load which then allows it to be discarded. 239 // Wait for the background tab to load which then allows it to be discarded.
270 load2.Wait(); 240 load2.Wait();
271 EXPECT_TRUE(tab_manager->DiscardTabImpl()); 241 EXPECT_TRUE(tab_manager->DiscardTabImpl());
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 400
431 IN_PROC_BROWSER_TEST_F(TabManagerTest, AutoDiscardable) { 401 IN_PROC_BROWSER_TEST_F(TabManagerTest, AutoDiscardable) {
432 using content::WindowedNotificationObserver; 402 using content::WindowedNotificationObserver;
433 TabManager* tab_manager = g_browser_process->GetTabManager(); 403 TabManager* tab_manager = g_browser_process->GetTabManager();
434 404
435 // Disable the protection of recent tabs. 405 // Disable the protection of recent tabs.
436 tab_manager->set_minimum_protection_time_for_tests( 406 tab_manager->set_minimum_protection_time_for_tests(
437 base::TimeDelta::FromMinutes(0)); 407 base::TimeDelta::FromMinutes(0));
438 408
439 // Get two tabs open. 409 // Get two tabs open.
440 WindowedNotificationObserver load1(
441 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
442 content::NotificationService::AllSources());
443 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(), 410 OpenURLParams open1(GURL(chrome::kChromeUIAboutURL), content::Referrer(),
444 WindowOpenDisposition::CURRENT_TAB, 411 WindowOpenDisposition::CURRENT_TAB,
445 ui::PAGE_TRANSITION_TYPED, false); 412 ui::PAGE_TRANSITION_TYPED, false);
446 browser()->OpenURL(open1); 413 content::TestNavigationObserver load1(browser()->OpenURL(open1));
447 load1.Wait(); 414 load1.Wait();
448 415
449 WindowedNotificationObserver load2(
450 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
451 content::NotificationService::AllSources());
452 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(), 416 OpenURLParams open2(GURL(chrome::kChromeUICreditsURL), content::Referrer(),
453 WindowOpenDisposition::NEW_FOREGROUND_TAB, 417 WindowOpenDisposition::NEW_FOREGROUND_TAB,
454 ui::PAGE_TRANSITION_TYPED, false); 418 ui::PAGE_TRANSITION_TYPED, false);
455 browser()->OpenURL(open2); 419 content::TestNavigationObserver load2(browser()->OpenURL(open2));
456 load2.Wait(); 420 load2.Wait();
457 421
458 // Set the auto-discardable state of the first tab to false. 422 // Set the auto-discardable state of the first tab to false.
459 auto tsm = browser()->tab_strip_model(); 423 auto tsm = browser()->tab_strip_model();
460 ASSERT_EQ(2, tsm->count()); 424 ASSERT_EQ(2, tsm->count());
461 tab_manager->SetTabAutoDiscardableState(tsm->GetWebContentsAt(0), false); 425 tab_manager->SetTabAutoDiscardableState(tsm->GetWebContentsAt(0), false);
462 426
463 // Shouldn't discard the tab, since auto-discardable is deactivated. 427 // Shouldn't discard the tab, since auto-discardable is deactivated.
464 EXPECT_FALSE(tab_manager->DiscardTabImpl()); 428 EXPECT_FALSE(tab_manager->DiscardTabImpl());
465 429
466 // Reset auto-discardable state to true. 430 // Reset auto-discardable state to true.
467 tab_manager->SetTabAutoDiscardableState(tsm->GetWebContentsAt(0), true); 431 tab_manager->SetTabAutoDiscardableState(tsm->GetWebContentsAt(0), true);
468 432
469 // Now it should be able to discard the tab. 433 // Now it should be able to discard the tab.
470 EXPECT_TRUE(tab_manager->DiscardTabImpl()); 434 EXPECT_TRUE(tab_manager->DiscardTabImpl());
471 EXPECT_TRUE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(0))); 435 EXPECT_TRUE(tab_manager->IsTabDiscarded(tsm->GetWebContentsAt(0)));
472 } 436 }
473 437
474 } // namespace memory 438 } // namespace memory
475 439
476 #endif // OS_WIN || OS_MAXOSX || OS_LINUX 440 #endif // OS_WIN || OS_MAXOSX || OS_LINUX
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698