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

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

Issue 10079023: Move notifications used only in chrome/ out of content/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: six! Created 8 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 | Annotate | Revision Log
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/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 "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 57 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
58 } 58 }
59 int tab_count = browser->tab_count(); 59 int tab_count = browser->tab_count();
60 EXPECT_EQ(starting_tab_count + how_many, tab_count); 60 EXPECT_EQ(starting_tab_count + how_many, tab_count);
61 return tab_count; 61 return tab_count;
62 } 62 }
63 63
64 void CloseTab(int index) { 64 void CloseTab(int index) {
65 content::WebContents* new_tab = browser()->GetWebContentsAt(index); 65 content::WebContents* new_tab = browser()->GetWebContentsAt(index);
66 ui_test_utils::WindowedNotificationObserver tab_close_observer( 66 ui_test_utils::WindowedNotificationObserver tab_close_observer(
67 content::NOTIFICATION_TAB_CLOSED, 67 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
68 content::NotificationService::AllSources()); 68 content::NotificationService::AllSources());
69 browser()->CloseTabContents(new_tab); 69 browser()->CloseTabContents(new_tab);
70 tab_close_observer.Wait(); 70 tab_close_observer.Wait();
71 } 71 }
72 72
73 // Uses the undo-close-tab accelerator to undo a close-tab or close-window 73 // Uses the undo-close-tab accelerator to undo a close-tab or close-window
74 // operation. The newly restored tab is expected to appear in the 74 // operation. The newly restored tab is expected to appear in the
75 // window at index |expected_window_index|, at the |expected_tabstrip_index|, 75 // window at index |expected_window_index|, at the |expected_tabstrip_index|,
76 // and to be active. If |expected_window_index| is equal to the number of 76 // and to be active. If |expected_window_index| is equal to the number of
77 // current windows, the restored tab is expected to be created in a new 77 // current windows, the restored tab is expected to be created in a new
78 // window (since the index is 0-based). 78 // window (since the index is 0-based).
79 void RestoreTab(int expected_window_index, 79 void RestoreTab(int expected_window_index,
80 int expected_tabstrip_index) { 80 int expected_tabstrip_index) {
81 int window_count = static_cast<int>(BrowserList::size()); 81 int window_count = static_cast<int>(BrowserList::size());
82 ASSERT_GT(window_count, 0); 82 ASSERT_GT(window_count, 0);
83 83
84 bool expect_new_window = (expected_window_index == window_count); 84 bool expect_new_window = (expected_window_index == window_count);
85 85
86 Browser* browser; 86 Browser* browser;
87 if (expect_new_window) { 87 if (expect_new_window) {
88 browser = *(BrowserList::begin()); 88 browser = *(BrowserList::begin());
89 } else { 89 } else {
90 browser = GetBrowser(expected_window_index); 90 browser = GetBrowser(expected_window_index);
91 } 91 }
92 int tab_count = browser->tab_count(); 92 int tab_count = browser->tab_count();
93 ASSERT_GT(tab_count, 0); 93 ASSERT_GT(tab_count, 0);
94 94
95 // Restore the tab. 95 // Restore the tab.
96 ui_test_utils::WindowedNotificationObserver tab_added_observer( 96 ui_test_utils::WindowedNotificationObserver tab_added_observer(
97 content::NOTIFICATION_TAB_PARENTED, 97 chrome::NOTIFICATION_TAB_PARENTED,
98 content::NotificationService::AllSources()); 98 content::NotificationService::AllSources());
99 ui_test_utils::WindowedNotificationObserver tab_loaded_observer( 99 ui_test_utils::WindowedNotificationObserver tab_loaded_observer(
100 content::NOTIFICATION_LOAD_STOP, 100 content::NOTIFICATION_LOAD_STOP,
101 content::NotificationService::AllSources()); 101 content::NotificationService::AllSources());
102 browser->RestoreTab(); 102 browser->RestoreTab();
103 tab_added_observer.Wait(); 103 tab_added_observer.Wait();
104 tab_loaded_observer.Wait(); 104 tab_loaded_observer.Wait();
105 105
106 if (expect_new_window) { 106 if (expect_new_window) {
107 int new_window_count = static_cast<int>(BrowserList::size()); 107 int new_window_count = static_cast<int>(BrowserList::size());
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 TabContentsWrapper* tab = browser()->GetTabContentsWrapperAt(1); 533 TabContentsWrapper* tab = browser()->GetTabContentsWrapperAt(1);
534 EnsureTabFinishedRestoring(tab->web_contents()); 534 EnsureTabFinishedRestoring(tab->web_contents());
535 ASSERT_EQ(http_url, tab->web_contents()->GetURL()); 535 ASSERT_EQ(http_url, tab->web_contents()->GetURL());
536 536
537 // Go back, and see if content is as expected. 537 // Go back, and see if content is as expected.
538 GoBack(browser()); 538 GoBack(browser());
539 EXPECT_GT( 539 EXPECT_GT(
540 ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL), 540 ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL),
541 0); 541 0);
542 } 542 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698