| OLD | NEW |
| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_commands.h" | 13 #include "chrome/browser/ui/browser_commands.h" |
| 14 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
| 15 #include "chrome/browser/ui/browser_tabstrip.h" | 15 #include "chrome/browser/ui/browser_tabstrip.h" |
| 16 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 16 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 20 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
| 21 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
| 22 #include "content/public/browser/navigation_controller.h" | 22 #include "content/public/browser/navigation_controller.h" |
| 23 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 24 #include "content/public/browser/notification_source.h" | 24 #include "content/public/browser/notification_source.h" |
| 25 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
| 26 #include "content/public/browser/page_navigator.h" | 26 #include "content/public/browser/page_navigator.h" |
| 27 #include "content/public/browser/render_view_host.h" | 27 #include "content/public/browser/render_view_host.h" |
| 28 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 29 #include "content/public/test/browser_test_utils.h" |
| 29 #include "net/base/net_util.h" | 30 #include "net/base/net_util.h" |
| 30 #include "net/test/embedded_test_server/embedded_test_server.h" | 31 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 31 #include "third_party/WebKit/public/web/WebFindOptions.h" | 32 #include "third_party/WebKit/public/web/WebFindOptions.h" |
| 32 #include "url/gurl.h" | 33 #include "url/gurl.h" |
| 33 | 34 |
| 34 class TabRestoreTest : public InProcessBrowserTest { | 35 class TabRestoreTest : public InProcessBrowserTest { |
| 35 public: | 36 public: |
| 36 TabRestoreTest() : active_browser_list_(NULL) { | 37 TabRestoreTest() : active_browser_list_(NULL) { |
| 37 url1_ = ui_test_utils::GetTestUrl( | 38 url1_ = ui_test_utils::GetTestUrl( |
| 38 base::FilePath().AppendASCII("session_history"), | 39 base::FilePath().AppendASCII("session_history"), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 63 ui_test_utils::NavigateToURLWithDisposition( | 64 ui_test_utils::NavigateToURLWithDisposition( |
| 64 browser, url1_, NEW_FOREGROUND_TAB, | 65 browser, url1_, NEW_FOREGROUND_TAB, |
| 65 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 66 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 66 } | 67 } |
| 67 int tab_count = browser->tab_strip_model()->count(); | 68 int tab_count = browser->tab_strip_model()->count(); |
| 68 EXPECT_EQ(starting_tab_count + how_many, tab_count); | 69 EXPECT_EQ(starting_tab_count + how_many, tab_count); |
| 69 return tab_count; | 70 return tab_count; |
| 70 } | 71 } |
| 71 | 72 |
| 72 void CloseTab(int index) { | 73 void CloseTab(int index) { |
| 73 content::WindowedNotificationObserver tab_close_observer( | 74 content::WebContentsDestroyedWatcher destroyed_watcher( |
| 74 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 75 browser()->tab_strip_model()->GetWebContentsAt(index)); |
| 75 content::NotificationService::AllSources()); | |
| 76 browser()->tab_strip_model()->CloseWebContentsAt( | 76 browser()->tab_strip_model()->CloseWebContentsAt( |
| 77 index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); | 77 index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); |
| 78 tab_close_observer.Wait(); | 78 destroyed_watcher.Wait(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Uses the undo-close-tab accelerator to undo a close-tab or close-window | 81 // Uses the undo-close-tab accelerator to undo a close-tab or close-window |
| 82 // operation. The newly restored tab is expected to appear in the | 82 // operation. The newly restored tab is expected to appear in the |
| 83 // window at index |expected_window_index|, at the |expected_tabstrip_index|, | 83 // window at index |expected_window_index|, at the |expected_tabstrip_index|, |
| 84 // and to be active. If |expected_window_index| is equal to the number of | 84 // and to be active. If |expected_window_index| is equal to the number of |
| 85 // current windows, the restored tab is expected to be created in a new | 85 // current windows, the restored tab is expected to be created in a new |
| 86 // window (since the index is 0-based). | 86 // window (since the index is 0-based). |
| 87 void RestoreTab(int expected_window_index, | 87 void RestoreTab(int expected_window_index, |
| 88 int expected_tabstrip_index) { | 88 int expected_tabstrip_index) { |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 EnsureTabFinishedRestoring(tab); | 575 EnsureTabFinishedRestoring(tab); |
| 576 ASSERT_EQ(http_url, tab->GetURL()); | 576 ASSERT_EQ(http_url, tab->GetURL()); |
| 577 | 577 |
| 578 // Go back, and see if content is as expected. | 578 // Go back, and see if content is as expected. |
| 579 GoBack(browser()); | 579 GoBack(browser()); |
| 580 EXPECT_GT( | 580 EXPECT_GT( |
| 581 ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL, | 581 ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL, |
| 582 NULL), | 582 NULL), |
| 583 0); | 583 0); |
| 584 } | 584 } |
| OLD | NEW |