| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
| 11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 12 #include "chrome/test/automation/tab_proxy.h" | 12 #include "chrome/test/automation/tab_proxy.h" |
| 13 #include "chrome/test/automation/browser_proxy.h" | 13 #include "chrome/test/automation/browser_proxy.h" |
| 14 #include "chrome/test/automation/window_proxy.h" | 14 #include "chrome/test/automation/window_proxy.h" |
| 15 #include "chrome/test/ui/ui_test.h" | 15 #include "chrome/test/ui/ui_test.h" |
| 16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 17 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
| 18 #include "net/test/test_server.h" | 18 #include "net/test/test_server.h" |
| 19 | 19 |
| 20 // http://code.google.com/p/chromium/issues/detail?id=14774 | 20 // http://code.google.com/p/chromium/issues/detail?id=14774 |
| 21 #if (defined(OS_WIN) || defined(OS_CHROMEOS)) && !defined(NDEBUG) | 21 #if (defined(OS_WIN) || defined(OS_CHROMEOS)) && !defined(NDEBUG) |
| 22 #define MAYBE_BasicRestoreFromClosedWindow DISABLED_BasicRestoreFromClosedWindow | 22 #define MAYBE_BasicRestoreFromClosedWindow DISABLED_BasicRestoreFromClosedWindow |
| 23 #else | 23 #else |
| 24 #define MAYBE_BasicRestoreFromClosedWindow BasicRestoreFromClosedWindow | 24 #define MAYBE_BasicRestoreFromClosedWindow BasicRestoreFromClosedWindow |
| 25 #endif | 25 #endif |
| 26 | 26 |
| 27 // http://crbug.com/ | 27 // http://crbug.com/48911 |
| 28 #if defined(OS_CHROMEOS) && !defined(NDEBUG) | 28 #if defined(OS_CHROMEOS) && !defined(NDEBUG) |
| 29 #define MAYBE_RestoreWindowAndTab DISABLED_RestoreWindowAndTab | 29 #define MAYBE_RestoreWindowAndTab DISABLED_RestoreWindowAndTab |
| 30 #define MAYBE_RestoreWindow DISABLED_RestoreWindow | 30 #define MAYBE_RestoreWindow DISABLED_RestoreWindow |
| 31 #define MAYBE_RestoreToDifferentWindow DISABLED_RestoreToDifferentWindow |
| 32 #define MAYBE_RestoreIntoSameWindow DISABLED_RestoreIntoSameWindow |
| 31 #else | 33 #else |
| 32 #define MAYBE_RestoreWindowAndTab RestoreWindowAndTab | 34 #define MAYBE_RestoreWindowAndTab RestoreWindowAndTab |
| 33 #define MAYBE_RestoreWindow RestoreWindow | 35 #define MAYBE_RestoreWindow RestoreWindow |
| 36 #define MAYBE_RestoreToDifferentWindow RestoreToDifferentWindow |
| 37 #define MAYBE_RestoreIntoSameWindow RestoreIntoSameWindow |
| 34 #endif | 38 #endif |
| 35 | 39 |
| 36 class TabRestoreUITest : public UITest { | 40 class TabRestoreUITest : public UITest { |
| 37 public: | 41 public: |
| 38 TabRestoreUITest() : UITest() { | 42 TabRestoreUITest() : UITest() { |
| 39 FilePath path_prefix(test_data_directory_); | 43 FilePath path_prefix(test_data_directory_); |
| 40 path_prefix = path_prefix.AppendASCII("session_history"); | 44 path_prefix = path_prefix.AppendASCII("session_history"); |
| 41 url1_ = net::FilePathToFileURL(path_prefix.AppendASCII("bot1.html")); | 45 url1_ = net::FilePathToFileURL(path_prefix.AppendASCII("bot1.html")); |
| 42 url2_ = net::FilePathToFileURL(path_prefix.AppendASCII("bot2.html")); | 46 url2_ = net::FilePathToFileURL(path_prefix.AppendASCII("bot2.html")); |
| 43 } | 47 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 204 |
| 201 // And make sure everything looks right. | 205 // And make sure everything looks right. |
| 202 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count)); | 206 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count)); |
| 203 EXPECT_EQ(starting_tab_count + 3, tab_count); | 207 EXPECT_EQ(starting_tab_count + 3, tab_count); |
| 204 EXPECT_EQ(closed_tab_index, GetActiveTabIndex()); | 208 EXPECT_EQ(closed_tab_index, GetActiveTabIndex()); |
| 205 EXPECT_EQ(url1_, GetActiveTabURL()); | 209 EXPECT_EQ(url1_, GetActiveTabURL()); |
| 206 } | 210 } |
| 207 | 211 |
| 208 // Close a tab, switch windows, then restore the tab. The tab should be in its | 212 // Close a tab, switch windows, then restore the tab. The tab should be in its |
| 209 // original window and position, and active. | 213 // original window and position, and active. |
| 210 // This test is flaky. See http://crbug.com/54894 | 214 TEST_F(TabRestoreUITest, MAYBE_RestoreToDifferentWindow) { |
| 211 TEST_F(TabRestoreUITest, FLAKY_RestoreToDifferentWindow) { | |
| 212 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); | 215 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
| 213 ASSERT_TRUE(browser_proxy.get()); | 216 ASSERT_TRUE(browser_proxy.get()); |
| 214 | 217 |
| 215 // This call is virtually guaranteed to pass, assuming that Chromium is the | 218 // This call is virtually guaranteed to pass, assuming that Chromium is the |
| 216 // active application, which will establish a baseline for later calls to | 219 // active application, which will establish a baseline for later calls to |
| 217 // CheckActiveWindow(). See comments in that function. | 220 // CheckActiveWindow(). See comments in that function. |
| 218 CheckActiveWindow(browser_proxy.get()); | 221 CheckActiveWindow(browser_proxy.get()); |
| 219 | 222 |
| 220 int starting_tab_count; | 223 int starting_tab_count; |
| 221 ASSERT_TRUE(browser_proxy->GetTabCount(&starting_tab_count)); | 224 ASSERT_TRUE(browser_proxy->GetTabCount(&starting_tab_count)); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 // Restore the closed tab. | 392 // Restore the closed tab. |
| 390 RestoreTab(1, closed_tab_index); | 393 RestoreTab(1, closed_tab_index); |
| 391 CheckActiveWindow(browser_proxy.get()); | 394 CheckActiveWindow(browser_proxy.get()); |
| 392 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count)); | 395 ASSERT_TRUE(browser_proxy->GetTabCount(&tab_count)); |
| 393 EXPECT_EQ(starting_tab_count + 3, tab_count); | 396 EXPECT_EQ(starting_tab_count + 3, tab_count); |
| 394 EXPECT_EQ(url1_, GetActiveTabURL(1)); | 397 EXPECT_EQ(url1_, GetActiveTabURL(1)); |
| 395 } | 398 } |
| 396 | 399 |
| 397 // Open a window with two tabs, close both (closing the window), then restore | 400 // Open a window with two tabs, close both (closing the window), then restore |
| 398 // both. Make sure both restored tabs are in the same window. | 401 // both. Make sure both restored tabs are in the same window. |
| 399 // http://crbug.com/39925 | 402 TEST_F(TabRestoreUITest, MAYBE_RestoreIntoSameWindow) { |
| 400 TEST_F(TabRestoreUITest, FLAKY_RestoreIntoSameWindow) { | |
| 401 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); | 403 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
| 402 ASSERT_TRUE(browser_proxy.get()); | 404 ASSERT_TRUE(browser_proxy.get()); |
| 403 CheckActiveWindow(browser_proxy.get()); | 405 CheckActiveWindow(browser_proxy.get()); |
| 404 | 406 |
| 405 int starting_tab_count; | 407 int starting_tab_count; |
| 406 ASSERT_TRUE(browser_proxy->GetTabCount(&starting_tab_count)); | 408 ASSERT_TRUE(browser_proxy->GetTabCount(&starting_tab_count)); |
| 407 int tab_count = AddSomeTabs(browser_proxy.get(), 2); | 409 int tab_count = AddSomeTabs(browser_proxy.get(), 2); |
| 408 | 410 |
| 409 // Navigate the rightmost one to url2_ for easier identification. | 411 // Navigate the rightmost one to url2_ for easier identification. |
| 410 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(tab_count - 1)); | 412 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetTab(tab_count - 1)); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 ASSERT_TRUE(tab->WaitForTabToBeRestored(TestTimeouts::action_timeout_ms())); | 674 ASSERT_TRUE(tab->WaitForTabToBeRestored(TestTimeouts::action_timeout_ms())); |
| 673 GURL url; | 675 GURL url; |
| 674 ASSERT_TRUE(tab->GetCurrentURL(&url)); | 676 ASSERT_TRUE(tab->GetCurrentURL(&url)); |
| 675 ASSERT_EQ(http_url, url); | 677 ASSERT_EQ(http_url, url); |
| 676 | 678 |
| 677 // Go back, and see if content is as expected. | 679 // Go back, and see if content is as expected. |
| 678 ASSERT_TRUE(tab->GoBack()); | 680 ASSERT_TRUE(tab->GoBack()); |
| 679 EXPECT_TRUE(tab->FindInPage(std::wstring(L"webkit"), FWD, IGNORE_CASE, false, | 681 EXPECT_TRUE(tab->FindInPage(std::wstring(L"webkit"), FWD, IGNORE_CASE, false, |
| 680 NULL)); | 682 NULL)); |
| 681 } | 683 } |
| OLD | NEW |