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

Side by Side Diff: chrome/browser/tab_restore_uitest.cc

Issue 329040: Take 2 at this. The only change between this and the first is to add the GetT... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #if defined(OS_WIN) 8 #if defined(OS_WIN)
9 #include "base/win_util.h" 9 #include "base/win_util.h"
10 #endif 10 #endif
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 ASSERT_TRUE(new_tab.get()); 219 ASSERT_TRUE(new_tab.get());
220 // Make sure we're at url. 220 // Make sure we're at url.
221 new_tab->NavigateToURL(url1_); 221 new_tab->NavigateToURL(url1_);
222 // Close the tab. 222 // Close the tab.
223 new_tab->Close(true); 223 new_tab->Close(true);
224 new_tab = NULL; 224 new_tab = NULL;
225 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count)); 225 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
226 EXPECT_EQ(starting_tab_count + 2, tab_count); 226 EXPECT_EQ(starting_tab_count + 2, tab_count);
227 227
228 // Create a new browser. 228 // Create a new browser.
229 ASSERT_TRUE(automation()->OpenNewBrowserWindow(false)); 229 ASSERT_TRUE(automation()->OpenNewBrowserWindow(BrowserProxy::TYPE_NORMAL,
230 false));
230 int window_count; 231 int window_count;
231 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); 232 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
232 EXPECT_EQ(2, window_count); 233 EXPECT_EQ(2, window_count);
233 234
234 CheckActiveWindow(automation()->GetBrowserWindow(1)); 235 CheckActiveWindow(automation()->GetBrowserWindow(1));
235 236
236 // Restore tab into original browser. 237 // Restore tab into original browser.
237 RestoreTab(0, closed_tab_index); 238 RestoreTab(0, closed_tab_index);
238 239
239 // And make sure everything looks right. 240 // And make sure everything looks right.
(...skipping 21 matching lines...) Expand all
261 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count)); 262 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
262 } 263 }
263 264
264 // Navigate to url1 then url2. 265 // Navigate to url1 then url2.
265 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0)); 266 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(0));
266 ASSERT_TRUE(tab_proxy.get()); 267 ASSERT_TRUE(tab_proxy.get());
267 tab_proxy->NavigateToURL(url1_); 268 tab_proxy->NavigateToURL(url1_);
268 tab_proxy->NavigateToURL(url2_); 269 tab_proxy->NavigateToURL(url2_);
269 270
270 // Create a new browser. 271 // Create a new browser.
271 ASSERT_TRUE(automation()->OpenNewBrowserWindow(false)); 272 ASSERT_TRUE(automation()->OpenNewBrowserWindow(BrowserProxy::TYPE_NORMAL,
273 false));
272 int window_count; 274 int window_count;
273 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); 275 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
274 EXPECT_EQ(2, window_count); 276 EXPECT_EQ(2, window_count);
275 CheckActiveWindow(automation()->GetBrowserWindow(1)); 277 CheckActiveWindow(automation()->GetBrowserWindow(1));
276 278
277 // Close the final tab in the first browser. 279 // Close the final tab in the first browser.
278 EXPECT_TRUE(tab_proxy->Close(true)); 280 EXPECT_TRUE(tab_proxy->Close(true));
279 ASSERT_TRUE(automation()->WaitForWindowCountToBecome( 281 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(
280 1, action_max_timeout_ms())); 282 1, action_max_timeout_ms()));
281 283
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 ASSERT_TRUE(new_tab.get()); 353 ASSERT_TRUE(new_tab.get());
352 // Make sure we're at url. 354 // Make sure we're at url.
353 new_tab->NavigateToURL(url1_); 355 new_tab->NavigateToURL(url1_);
354 // Close the tab. 356 // Close the tab.
355 new_tab->Close(true); 357 new_tab->Close(true);
356 new_tab = NULL; 358 new_tab = NULL;
357 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count)); 359 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count));
358 EXPECT_EQ(starting_tab_count + 2, tab_count); 360 EXPECT_EQ(starting_tab_count + 2, tab_count);
359 361
360 // Create a new browser. 362 // Create a new browser.
361 ASSERT_TRUE(automation()->OpenNewBrowserWindow(false)); 363 ASSERT_TRUE(automation()->OpenNewBrowserWindow(BrowserProxy::TYPE_NORMAL,
364 false));
362 int window_count; 365 int window_count;
363 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); 366 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
364 EXPECT_EQ(2, window_count); 367 EXPECT_EQ(2, window_count);
365 CheckActiveWindow(automation()->GetBrowserWindow(1)); 368 CheckActiveWindow(automation()->GetBrowserWindow(1));
366 369
367 // Close the first browser. 370 // Close the first browser.
368 bool application_closing; 371 bool application_closing;
369 EXPECT_TRUE(CloseBrowser(browser_proxy.get(), &application_closing)); 372 EXPECT_TRUE(CloseBrowser(browser_proxy.get(), &application_closing));
370 EXPECT_FALSE(application_closing); 373 EXPECT_FALSE(application_closing);
371 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); 374 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
(...skipping 27 matching lines...) Expand all
399 int starting_tab_count; 402 int starting_tab_count;
400 ASSERT_TRUE(browser_proxy->GetTabCount(&starting_tab_count)); 403 ASSERT_TRUE(browser_proxy->GetTabCount(&starting_tab_count));
401 int tab_count = AddSomeTabs(browser_proxy.get(), 2); 404 int tab_count = AddSomeTabs(browser_proxy.get(), 2);
402 405
403 // Navigate the rightmost one to url2_ for easier identification. 406 // Navigate the rightmost one to url2_ for easier identification.
404 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(tab_count - 1)); 407 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(tab_count - 1));
405 ASSERT_TRUE(tab_proxy.get()); 408 ASSERT_TRUE(tab_proxy.get());
406 tab_proxy->NavigateToURL(url2_); 409 tab_proxy->NavigateToURL(url2_);
407 410
408 // Create a new browser. 411 // Create a new browser.
409 ASSERT_TRUE(automation()->OpenNewBrowserWindow(false)); 412 ASSERT_TRUE(automation()->OpenNewBrowserWindow(BrowserProxy::TYPE_NORMAL,
413 false));
410 int window_count; 414 int window_count;
411 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); 415 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
412 EXPECT_EQ(2, window_count); 416 EXPECT_EQ(2, window_count);
413 CheckActiveWindow(automation()->GetBrowserWindow(1)); 417 CheckActiveWindow(automation()->GetBrowserWindow(1));
414 418
415 // Close all but one tab in the first browser, left to right. 419 // Close all but one tab in the first browser, left to right.
416 while (tab_count > 1) { 420 while (tab_count > 1) {
417 scoped_refptr<TabProxy> tab_to_close(browser_proxy->GetTab(0)); 421 scoped_refptr<TabProxy> tab_to_close(browser_proxy->GetTab(0));
418 ASSERT_TRUE(tab_to_close.get()); 422 ASSERT_TRUE(tab_to_close.get());
419 tab_to_close->Close(true); 423 tab_to_close->Close(true);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 // page ID of the renderer should have been updated when we restored the tab. 545 // page ID of the renderer should have been updated when we restored the tab.
542 tab->NavigateToURL(http_url2); 546 tab->NavigateToURL(http_url2);
543 EXPECT_FALSE(tab->GoForward()); 547 EXPECT_FALSE(tab->GoForward());
544 EXPECT_EQ(http_url2, GetActiveTabURL()); 548 EXPECT_EQ(http_url2, GetActiveTabURL());
545 } 549 }
546 550
547 TEST_F(TabRestoreUITest, RestoreWindow) { 551 TEST_F(TabRestoreUITest, RestoreWindow) {
548 // Create a new window. 552 // Create a new window.
549 int window_count; 553 int window_count;
550 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); 554 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
551 ASSERT_TRUE(automation()->OpenNewBrowserWindow(false)); 555 ASSERT_TRUE(automation()->OpenNewBrowserWindow(BrowserProxy::TYPE_NORMAL,
556 false));
552 int new_window_count = 0; 557 int new_window_count = 0;
553 ASSERT_TRUE(automation()->GetBrowserWindowCount(&new_window_count)); 558 ASSERT_TRUE(automation()->GetBrowserWindowCount(&new_window_count));
554 EXPECT_EQ(++window_count, new_window_count); 559 EXPECT_EQ(++window_count, new_window_count);
555 560
556 // Create two more tabs, one with url1, the other url2. 561 // Create two more tabs, one with url1, the other url2.
557 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); 562 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
558 int initial_tab_count; 563 int initial_tab_count;
559 ASSERT_TRUE(browser_proxy->GetTabCount(&initial_tab_count)); 564 ASSERT_TRUE(browser_proxy->GetTabCount(&initial_tab_count));
560 browser_proxy->AppendTab(url1_); 565 browser_proxy->AppendTab(url1_);
561 ASSERT_TRUE(browser_proxy->WaitForTabCountToBecome(initial_tab_count + 1, 566 ASSERT_TRUE(browser_proxy->WaitForTabCountToBecome(initial_tab_count + 1,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 GURL url; 600 GURL url;
596 ASSERT_TRUE(restored_tab_proxy->GetCurrentURL(&url)); 601 ASSERT_TRUE(restored_tab_proxy->GetCurrentURL(&url));
597 EXPECT_TRUE(url == url1_); 602 EXPECT_TRUE(url == url1_);
598 603
599 restored_tab_proxy = browser_proxy->GetTab(initial_tab_count + 1); 604 restored_tab_proxy = browser_proxy->GetTab(initial_tab_count + 1);
600 ASSERT_TRUE(restored_tab_proxy.get()); 605 ASSERT_TRUE(restored_tab_proxy.get());
601 ASSERT_TRUE(restored_tab_proxy->WaitForTabToBeRestored(action_timeout_ms())); 606 ASSERT_TRUE(restored_tab_proxy->WaitForTabToBeRestored(action_timeout_ms()));
602 ASSERT_TRUE(restored_tab_proxy->GetCurrentURL(&url)); 607 ASSERT_TRUE(restored_tab_proxy->GetCurrentURL(&url));
603 EXPECT_TRUE(url == url2_); 608 EXPECT_TRUE(url == url2_);
604 } 609 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_service_unittest.cc ('k') | chrome/test/automated_ui_tests/automated_ui_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698