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

Side by Side Diff: chrome/browser/sessions/session_restore_uitest.cc

Issue 1547003: [GTTF] Miscellanous UI tests cleanups: (Closed)
Patch Set: updated Created 10 years, 8 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/session_history_uitest.cc ('k') | chrome/browser/tab_restore_uitest.cc » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/app/chrome_dll_resource.h" 9 #include "chrome/app/chrome_dll_resource.h"
10 #include "chrome/browser/defaults.h" 10 #include "chrome/browser/defaults.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 int tab_count; 66 int tab_count;
67 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count)); 67 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
68 ASSERT_EQ(1, tab_count); 68 ASSERT_EQ(1, tab_count);
69 69
70 int active_tab_index; 70 int active_tab_index;
71 ASSERT_TRUE(browser_proxy->GetActiveTabIndex(&active_tab_index)); 71 ASSERT_TRUE(browser_proxy->GetActiveTabIndex(&active_tab_index));
72 ASSERT_EQ(0, active_tab_index); 72 ASSERT_EQ(0, active_tab_index);
73 73
74 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetActiveTab()); 74 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetActiveTab());
75 ASSERT_TRUE(tab_proxy.get()); 75 ASSERT_TRUE(tab_proxy.get());
76 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); 76 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_max_timeout_ms()));
77 77
78 ASSERT_TRUE(tab_proxy->GetCurrentURL(url)); 78 ASSERT_TRUE(tab_proxy->GetCurrentURL(url));
79 } 79 }
80 80
81 GURL url1_; 81 GURL url1_;
82 GURL url2_; 82 GURL url2_;
83 GURL url3_; 83 GURL url3_;
84 84
85 private: 85 private:
86 DISALLOW_COPY_AND_ASSIGN(SessionRestoreUITest); 86 DISALLOW_COPY_AND_ASSIGN(SessionRestoreUITest);
87 }; 87 };
88 88
89 TEST_F(SessionRestoreUITest, Basic) { 89 TEST_F(SessionRestoreUITest, Basic) {
90 NavigateToURL(url1_); 90 NavigateToURL(url1_);
91 NavigateToURL(url2_); 91 NavigateToURL(url2_);
92 92
93 QuitBrowserAndRestore(1); 93 QuitBrowserAndRestore(1);
94 94
95 // NOTE: Don't use GetActiveWindow here, when run with the screen locked 95 // NOTE: Don't use GetActiveWindow here, when run with the screen locked
96 // active windows returns NULL. 96 // active windows returns NULL.
97 int window_count; 97 int window_count;
98 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); 98 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
99 ASSERT_EQ(1, window_count); 99 ASSERT_EQ(1, window_count);
100 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); 100 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
101 ASSERT_TRUE(browser_proxy.get()); 101 ASSERT_TRUE(browser_proxy.get());
102 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0)); 102 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0));
103 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); 103 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_max_timeout_ms()));
104 104
105 ASSERT_EQ(url2_, GetActiveTabURL()); 105 ASSERT_EQ(url2_, GetActiveTabURL());
106 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_proxy->GoBack()); 106 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_proxy->GoBack());
107 ASSERT_EQ(url1_, GetActiveTabURL()); 107 ASSERT_EQ(url1_, GetActiveTabURL());
108 } 108 }
109 109
110 TEST_F(SessionRestoreUITest, RestoresForwardAndBackwardNavs) { 110 TEST_F(SessionRestoreUITest, RestoresForwardAndBackwardNavs) {
111 NavigateToURL(url1_); 111 NavigateToURL(url1_);
112 NavigateToURL(url2_); 112 NavigateToURL(url2_);
113 NavigateToURL(url3_); 113 NavigateToURL(url3_);
114 114
115 scoped_refptr<TabProxy> active_tab(GetActiveTab()); 115 scoped_refptr<TabProxy> active_tab(GetActiveTab());
116 ASSERT_TRUE(active_tab.get()); 116 ASSERT_TRUE(active_tab.get());
117 ASSERT_TRUE(active_tab->GoBack()); 117 ASSERT_TRUE(active_tab->GoBack());
118 118
119 QuitBrowserAndRestore(1); 119 QuitBrowserAndRestore(1);
120 120
121 // NOTE: Don't use GetActiveWindow here, when run with the screen locked 121 // NOTE: Don't use GetActiveWindow here, when run with the screen locked
122 // active windows returns NULL. 122 // active windows returns NULL.
123 int window_count; 123 int window_count;
124 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); 124 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
125 ASSERT_EQ(1, window_count); 125 ASSERT_EQ(1, window_count);
126 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); 126 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
127 ASSERT_TRUE(browser_proxy.get()); 127 ASSERT_TRUE(browser_proxy.get());
128 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0)); 128 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0));
129 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); 129 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_max_timeout_ms()));
130 130
131 ASSERT_TRUE(GetActiveTabURL() == url2_); 131 ASSERT_TRUE(GetActiveTabURL() == url2_);
132 ASSERT_TRUE(tab_proxy->GoForward()); 132 ASSERT_TRUE(tab_proxy->GoForward());
133 ASSERT_TRUE(GetActiveTabURL() == url3_); 133 ASSERT_TRUE(GetActiveTabURL() == url3_);
134 ASSERT_TRUE(tab_proxy->GoBack()); 134 ASSERT_TRUE(tab_proxy->GoBack());
135 ASSERT_TRUE(GetActiveTabURL() == url2_); 135 ASSERT_TRUE(GetActiveTabURL() == url2_);
136 ASSERT_TRUE(tab_proxy->GoBack()); 136 ASSERT_TRUE(tab_proxy->GoBack());
137 ASSERT_TRUE(GetActiveTabURL() == url1_); 137 ASSERT_TRUE(GetActiveTabURL() == url1_);
138 } 138 }
139 139
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 int tab_count; 213 int tab_count;
214 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count)); 214 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
215 ASSERT_EQ(2, tab_count); 215 ASSERT_EQ(2, tab_count);
216 216
217 int active_tab_index; 217 int active_tab_index;
218 ASSERT_TRUE(browser_proxy->GetActiveTabIndex(&active_tab_index)); 218 ASSERT_TRUE(browser_proxy->GetActiveTabIndex(&active_tab_index));
219 ASSERT_EQ(1, active_tab_index); 219 ASSERT_EQ(1, active_tab_index);
220 220
221 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetActiveTab()); 221 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetActiveTab());
222 ASSERT_TRUE(tab_proxy.get()); 222 ASSERT_TRUE(tab_proxy.get());
223 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); 223 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_max_timeout_ms()));
224 224
225 ASSERT_TRUE(GetActiveTabURL() == url2_); 225 ASSERT_EQ(url2_, GetActiveTabURL());
226 226
227 ASSERT_TRUE(browser_proxy->ActivateTab(0)); 227 ASSERT_TRUE(browser_proxy->ActivateTab(0));
228 tab_proxy = browser_proxy->GetActiveTab(); 228 tab_proxy = browser_proxy->GetActiveTab();
229 ASSERT_TRUE(tab_proxy.get()); 229 ASSERT_TRUE(tab_proxy.get());
230 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); 230 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_max_timeout_ms()));
231 231
232 ASSERT_TRUE(GetActiveTabURL() == url1_); 232 ASSERT_EQ(url1_, GetActiveTabURL());
233 } 233 }
234 234
235 // Creates two tabs, closes one, quits and makes sure only one tab is restored. 235 // Creates two tabs, closes one, quits and makes sure only one tab is restored.
236 TEST_F(SessionRestoreUITest, ClosedTabStaysClosed) { 236 TEST_F(SessionRestoreUITest, ClosedTabStaysClosed) {
237 NavigateToURL(url1_); 237 NavigateToURL(url1_);
238 238
239 // NOTE: Don't use GetActiveWindow here, when run with the screen locked 239 // NOTE: Don't use GetActiveWindow here, when run with the screen locked
240 // active windows returns NULL. 240 // active windows returns NULL.
241 int window_count; 241 int window_count;
242 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); 242 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
243 ASSERT_EQ(1, window_count); 243 ASSERT_EQ(1, window_count);
244 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); 244 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
245 ASSERT_TRUE(browser_proxy.get()); 245 ASSERT_TRUE(browser_proxy.get());
246 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0)); 246 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0));
247 ASSERT_TRUE(tab_proxy.get()); 247 ASSERT_TRUE(tab_proxy.get());
248 248
249 ASSERT_TRUE(browser_proxy->AppendTab(url2_)); 249 ASSERT_TRUE(browser_proxy->AppendTab(url2_));
250 250
251 scoped_refptr<TabProxy> active_tab(browser_proxy->GetActiveTab()); 251 scoped_refptr<TabProxy> active_tab(browser_proxy->GetActiveTab());
252 ASSERT_TRUE(active_tab.get()); 252 ASSERT_TRUE(active_tab.get());
253 ASSERT_TRUE(active_tab->Close(true)); 253 ASSERT_TRUE(active_tab->Close(true));
254 254
255 QuitBrowserAndRestore(1); 255 QuitBrowserAndRestore(1);
256 browser_proxy = NULL; 256 browser_proxy = NULL;
257 tab_proxy = NULL; 257 tab_proxy = NULL;
258 258
259 AssertOneWindowWithOneTab(); 259 AssertOneWindowWithOneTab();
260 260
261 ASSERT_TRUE(GetActiveTabURL() == url1_); 261 ASSERT_EQ(url1_, GetActiveTabURL());
262 } 262 }
263 263
264 // Creates a tabbed browser and popup and makes sure we restore both. 264 // Creates a tabbed browser and popup and makes sure we restore both.
265 TEST_F(SessionRestoreUITest, NormalAndPopup) { 265 TEST_F(SessionRestoreUITest, NormalAndPopup) {
266 if (!browser_defaults::kRestorePopups) 266 if (!browser_defaults::kRestorePopups)
267 return; // Test only applicable if restoring popups. 267 return; // Test only applicable if restoring popups.
268 268
269 NavigateToURL(url1_); 269 NavigateToURL(url1_);
270 270
271 // Make sure we have one window. 271 // Make sure we have one window.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 // The order of whether the normal window or popup is first depends upon 317 // The order of whether the normal window or popup is first depends upon
318 // activation order, which is not necessarily consistant across runs. 318 // activation order, which is not necessarily consistant across runs.
319 if (type1 == Browser::TYPE_NORMAL) { 319 if (type1 == Browser::TYPE_NORMAL) {
320 EXPECT_EQ(type2, Browser::TYPE_POPUP); 320 EXPECT_EQ(type2, Browser::TYPE_POPUP);
321 } else { 321 } else {
322 EXPECT_EQ(type1, Browser::TYPE_POPUP); 322 EXPECT_EQ(type1, Browser::TYPE_POPUP);
323 EXPECT_EQ(type2, Browser::TYPE_NORMAL); 323 EXPECT_EQ(type2, Browser::TYPE_NORMAL);
324 } 324 }
325 } 325 }
326 326
327 #if defined(OS_WIN)
328 // Creates a browser, goes incognito, closes browser, launches and make sure 327 // Creates a browser, goes incognito, closes browser, launches and make sure
329 // we don't restore. 328 // we don't restore.
330 // 329 //
331 // Flaky, http://crbug.com/39490. 330 // Flaky, http://crbug.com/39490.
332 TEST_F(SessionRestoreUITest, FLAKY_DontRestoreWhileIncognito) { 331 TEST_F(SessionRestoreUITest, FLAKY_DontRestoreWhileIncognito) {
333 NavigateToURL(url1_); 332 NavigateToURL(url1_);
334 333
335 // Make sure we have one window. 334 // Make sure we have one window.
336 int initial_window_count; 335 int initial_window_count;
337 ASSERT_TRUE(automation()->GetBrowserWindowCount(&initial_window_count)); 336 ASSERT_TRUE(automation()->GetBrowserWindowCount(&initial_window_count));
(...skipping 21 matching lines...) Expand all
359 LaunchBrowser(launch_arguments_, false); 358 LaunchBrowser(launch_arguments_, false);
360 359
361 // A new window should appear; 360 // A new window should appear;
362 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2)); 361 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2));
363 362
364 // And it shouldn't have url1_ in it. 363 // And it shouldn't have url1_ in it.
365 browser_proxy = automation()->GetBrowserWindow(1); 364 browser_proxy = automation()->GetBrowserWindow(1);
366 ASSERT_TRUE(browser_proxy.get()); 365 ASSERT_TRUE(browser_proxy.get());
367 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0)); 366 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0));
368 ASSERT_TRUE(tab_proxy.get()); 367 ASSERT_TRUE(tab_proxy.get());
369 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); 368 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_max_timeout_ms()));
370 GURL url; 369 GURL url;
371 ASSERT_TRUE(tab_proxy->GetCurrentURL(&url)); 370 ASSERT_TRUE(tab_proxy->GetCurrentURL(&url));
372 ASSERT_TRUE(url != url1_); 371 ASSERT_TRUE(url != url1_);
373 } 372 }
374 373
375 // Creates two windows, closes one, restores, make sure only one window open. 374 // Creates two windows, closes one, restores, make sure only one window open.
376 TEST_F(SessionRestoreUITest, TwoWindowsCloseOneRestoreOnlyOne) { 375 TEST_F(SessionRestoreUITest, TwoWindowsCloseOneRestoreOnlyOne) {
377 NavigateToURL(url1_); 376 NavigateToURL(url1_);
378 377
379 // Make sure we have one window. 378 // Make sure we have one window.
380 int window_count; 379 int window_count;
381 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); 380 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
382 ASSERT_EQ(1, window_count); 381 ASSERT_EQ(1, window_count);
383 382
384 // Open a second window. 383 // Open a second window.
385 ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, 384 ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL,
386 true)); 385 true));
387 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); 386 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
388 ASSERT_EQ(2, window_count); 387 ASSERT_EQ(2, window_count);
389 388
390 // Close it. 389 // Close it.
391 CloseWindow(1, 2); 390 CloseWindow(1, 2);
392 391
393 // Restart and make sure we have only one window with one tab and the url 392 // Restart and make sure we have only one window with one tab and the url
394 // is url1_. 393 // is url1_.
395 QuitBrowserAndRestore(1); 394 QuitBrowserAndRestore(1);
396 395
397 AssertOneWindowWithOneTab(); 396 AssertOneWindowWithOneTab();
398 397
399 ASSERT_TRUE(GetActiveTabURL() == url1_); 398 ASSERT_EQ(url1_, GetActiveTabURL());
400 } 399 }
401 400
402 // Launches an app window, closes tabbed browser, launches and makes sure 401 // Launches an app window, closes tabbed browser, launches and makes sure
403 // we restore the tabbed browser url. 402 // we restore the tabbed browser url.
404 TEST_F(SessionRestoreUITest, 403 TEST_F(SessionRestoreUITest,
405 FLAKY_RestoreAfterClosingTabbedBrowserWithAppAndLaunching) { 404 FLAKY_RestoreAfterClosingTabbedBrowserWithAppAndLaunching) {
406 NavigateToURL(url1_); 405 NavigateToURL(url1_);
407 406
408 // Launch an app. 407 // Launch an app.
409 408
(...skipping 13 matching lines...) Expand all
423 422
424 // Restore the session, which should bring back the first window with url1_. 423 // Restore the session, which should bring back the first window with url1_.
425 // First restore the settings so we can connect to the browser. 424 // First restore the settings so we can connect to the browser.
426 include_testing_id_ = include_testing_id_orig; 425 include_testing_id_ = include_testing_id_orig;
427 use_existing_browser_ = use_existing_browser_orig; 426 use_existing_browser_ = use_existing_browser_orig;
428 // Restore the session with 1 tab. 427 // Restore the session with 1 tab.
429 QuitBrowserAndRestore(1); 428 QuitBrowserAndRestore(1);
430 429
431 AssertOneWindowWithOneTab(); 430 AssertOneWindowWithOneTab();
432 431
433 ASSERT_TRUE(GetActiveTabURL() == url1_); 432 ASSERT_EQ(url1_, GetActiveTabURL());
434 } 433 }
435 434
436 // Make sure after a restore the number of processes matches that of the number 435 // Make sure after a restore the number of processes matches that of the number
437 // of processes running before the restore. This creates a new tab so that 436 // of processes running before the restore. This creates a new tab so that
438 // we should have two new tabs running. (This test will pass in both 437 // we should have two new tabs running. (This test will pass in both
439 // process-per-site and process-per-site-instance, because we treat the new tab 438 // process-per-site and process-per-site-instance, because we treat the new tab
440 // as a special case in process-per-site-instance so that it only ever uses one 439 // as a special case in process-per-site-instance so that it only ever uses one
441 // process.) 440 // process.)
442 TEST_F(SessionRestoreUITest, ShareProcessesOnRestore) { 441 TEST_F(SessionRestoreUITest, ShareProcessesOnRestore) {
443 if (in_process_renderer()) { 442 if (in_process_renderer()) {
(...skipping 22 matching lines...) Expand all
466 465
467 // Wait for each tab to finish being restored, then make sure the process 466 // Wait for each tab to finish being restored, then make sure the process
468 // count matches. 467 // count matches.
469 browser_proxy = automation()->GetBrowserWindow(0); 468 browser_proxy = automation()->GetBrowserWindow(0);
470 ASSERT_TRUE(browser_proxy.get() != NULL); 469 ASSERT_TRUE(browser_proxy.get() != NULL);
471 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count)); 470 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
472 ASSERT_EQ(expected_tab_count, tab_count); 471 ASSERT_EQ(expected_tab_count, tab_count);
473 472
474 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(tab_count - 2)); 473 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(tab_count - 2));
475 ASSERT_TRUE(tab_proxy.get() != NULL); 474 ASSERT_TRUE(tab_proxy.get() != NULL);
476 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); 475 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_max_timeout_ms()));
477 tab_proxy = browser_proxy->GetTab(tab_count - 1); 476 tab_proxy = browser_proxy->GetTab(tab_count - 1);
478 ASSERT_TRUE(tab_proxy.get() != NULL); 477 ASSERT_TRUE(tab_proxy.get() != NULL);
479 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); 478 ASSERT_TRUE(tab_proxy->WaitForTabToBeRestored(action_max_timeout_ms()));
480 479
481 ASSERT_EQ(expected_process_count, GetBrowserProcessCount()); 480 ASSERT_EQ(expected_process_count, GetBrowserProcessCount());
482 } 481 }
483 #endif
484 482
485 } // namespace 483 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/session_history_uitest.cc ('k') | chrome/browser/tab_restore_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698