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

Side by Side Diff: chrome/browser/ui/views/find_bar_host_interactive_uitest.cc

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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/process_util.h" 5 #include "base/process_util.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_commands.h" 9 #include "chrome/browser/ui/browser_commands.h"
10 #include "chrome/browser/ui/browser_tabstrip.h"
10 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 11 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
11 #include "chrome/browser/ui/find_bar/find_notification_details.h" 12 #include "chrome/browser/ui/find_bar/find_notification_details.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/browser/ui/view_ids.h" 14 #include "chrome/browser/ui/view_ids.h"
14 #include "chrome/browser/ui/views/find_bar_host.h" 15 #include "chrome/browser/ui/views/find_bar_host.h"
15 #include "chrome/browser/ui/views/frame/browser_view.h" 16 #include "chrome/browser/ui/views/frame/browser_view.h"
16 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
18 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
19 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_CrashEscHandlers) { 80 IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_CrashEscHandlers) {
80 ASSERT_TRUE(test_server()->Start()); 81 ASSERT_TRUE(test_server()->Start());
81 82
82 // First we navigate to our test page (tab A). 83 // First we navigate to our test page (tab A).
83 GURL url = test_server()->GetURL(kSimplePage); 84 GURL url = test_server()->GetURL(kSimplePage);
84 ui_test_utils::NavigateToURL(browser(), url); 85 ui_test_utils::NavigateToURL(browser(), url);
85 86
86 chrome::Find(browser()); 87 chrome::Find(browser());
87 88
88 // Open another tab (tab B). 89 // Open another tab (tab B).
89 browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); 90 chrome::AddSelectedTabWithURL(browser(), url, content::PAGE_TRANSITION_TYPED);
90 91
91 chrome::Find(browser()); 92 chrome::Find(browser());
92 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 93 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
93 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 94 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
94 95
95 // Select tab A. 96 // Select tab A.
96 browser()->ActivateTabAt(0, true); 97 chrome::ActivateTabAt(browser(), 0, true);
97 98
98 // Close tab B. 99 // Close tab B.
99 browser()->CloseTabContents(browser()->GetWebContentsAt(1)); 100 chrome::CloseWebContents(browser(), chrome::GetWebContentsAt(browser(), 1));
100 101
101 // Click on the location bar so that Find box loses focus. 102 // Click on the location bar so that Find box loses focus.
102 ASSERT_NO_FATAL_FAILURE(ui_test_utils::ClickOnView(browser(), 103 ASSERT_NO_FATAL_FAILURE(ui_test_utils::ClickOnView(browser(),
103 VIEW_ID_LOCATION_BAR)); 104 VIEW_ID_LOCATION_BAR));
104 // Check the location bar is focused. 105 // Check the location bar is focused.
105 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 106 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
106 location_bar_focus_view_id_)); 107 location_bar_focus_view_id_));
107 108
108 // This used to crash until bug 1303709 was fixed. 109 // This used to crash until bug 1303709 was fixed.
109 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 110 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
(...skipping 20 matching lines...) Expand all
130 FindBarController::kKeepResultsInFindBox); 131 FindBarController::kKeepResultsInFindBox);
131 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 132 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
132 location_bar_focus_view_id_)); 133 location_bar_focus_view_id_));
133 134
134 // Focus the location bar, find something on the page, close the find box, 135 // Focus the location bar, find something on the page, close the find box,
135 // focus should go to the page. 136 // focus should go to the page.
136 chrome::FocusLocationBar(browser()); 137 chrome::FocusLocationBar(browser());
137 chrome::Find(browser()); 138 chrome::Find(browser());
138 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 139 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
139 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 140 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
140 ui_test_utils::FindInPage(browser()->GetActiveTabContents(), 141 ui_test_utils::FindInPage(chrome::GetActiveTabContents(browser()),
141 ASCIIToUTF16("a"), true, false, NULL); 142 ASCIIToUTF16("a"), true, false, NULL);
142 browser()->GetFindBarController()->EndFindSession( 143 browser()->GetFindBarController()->EndFindSession(
143 FindBarController::kKeepSelectionOnPage, 144 FindBarController::kKeepSelectionOnPage,
144 FindBarController::kKeepResultsInFindBox); 145 FindBarController::kKeepResultsInFindBox);
145 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); 146 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
146 147
147 // Focus the location bar, open and close the find box, focus should return to 148 // Focus the location bar, open and close the find box, focus should return to
148 // the location bar (same as before, just checking that http://crbug.com/23599 149 // the location bar (same as before, just checking that http://crbug.com/23599
149 // is fixed). 150 // is fixed).
150 chrome::FocusLocationBar(browser()); 151 chrome::FocusLocationBar(browser());
(...skipping 22 matching lines...) Expand all
173 ui_test_utils::NavigateToURL(browser(), url); 174 ui_test_utils::NavigateToURL(browser(), url);
174 175
175 chrome::Find(browser()); 176 chrome::Find(browser());
176 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 177 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
177 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 178 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
178 179
179 FindBarTesting* find_bar = 180 FindBarTesting* find_bar =
180 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); 181 browser()->GetFindBarController()->find_bar()->GetFindBarTesting();
181 182
182 // Search for 'a'. 183 // Search for 'a'.
183 ui_test_utils::FindInPage(browser()->GetActiveTabContents(), 184 ui_test_utils::FindInPage(chrome::GetActiveTabContents(browser()),
184 ASCIIToUTF16("a"), true, false, NULL); 185 ASCIIToUTF16("a"), true, false, NULL);
185 EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText()); 186 EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText());
186 187
187 // Open another tab (tab B). 188 // Open another tab (tab B).
188 ui_test_utils::WindowedNotificationObserver observer( 189 ui_test_utils::WindowedNotificationObserver observer(
189 content::NOTIFICATION_LOAD_STOP, 190 content::NOTIFICATION_LOAD_STOP,
190 content::NotificationService::AllSources()); 191 content::NotificationService::AllSources());
191 browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); 192 chrome::AddSelectedTabWithURL(browser(), url, content::PAGE_TRANSITION_TYPED);
192 observer.Wait(); 193 observer.Wait();
193 194
194 // Make sure Find box is open. 195 // Make sure Find box is open.
195 chrome::Find(browser()); 196 chrome::Find(browser());
196 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 197 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
197 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 198 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
198 199
199 // Search for 'b'. 200 // Search for 'b'.
200 ui_test_utils::FindInPage(browser()->GetActiveTabContents(), 201 ui_test_utils::FindInPage(chrome::GetActiveTabContents(browser()),
201 ASCIIToUTF16("b"), true, false, NULL); 202 ASCIIToUTF16("b"), true, false, NULL);
202 EXPECT_TRUE(ASCIIToUTF16("b") == find_bar->GetFindSelectedText()); 203 EXPECT_TRUE(ASCIIToUTF16("b") == find_bar->GetFindSelectedText());
203 204
204 // Set focus away from the Find bar (to the Location bar). 205 // Set focus away from the Find bar (to the Location bar).
205 chrome::FocusLocationBar(browser()); 206 chrome::FocusLocationBar(browser());
206 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 207 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
207 location_bar_focus_view_id_)); 208 location_bar_focus_view_id_));
208 209
209 // Select tab A. Find bar should get focus. 210 // Select tab A. Find bar should get focus.
210 browser()->ActivateTabAt(0, true); 211 chrome::ActivateTabAt(browser(), 0, true);
211 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 212 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
212 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 213 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
213 EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText()); 214 EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText());
214 215
215 // Select tab B. Location bar should get focus. 216 // Select tab B. Location bar should get focus.
216 browser()->ActivateTabAt(1, true); 217 chrome::ActivateTabAt(browser(), 1, true);
217 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 218 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
218 location_bar_focus_view_id_)); 219 location_bar_focus_view_id_));
219 } 220 }
220 221
221 // This tests that whenever you clear values from the Find box and close it that 222 // This tests that whenever you clear values from the Find box and close it that
222 // it respects that and doesn't show you the last search, as reported in bug: 223 // it respects that and doesn't show you the last search, as reported in bug:
223 // http://crbug.com/40121. 224 // http://crbug.com/40121.
224 IN_PROC_BROWSER_TEST_F(FindInPageTest, PrepopulateRespectBlank) { 225 IN_PROC_BROWSER_TEST_F(FindInPageTest, PrepopulateRespectBlank) {
225 #if defined(OS_MACOSX) 226 #if defined(OS_MACOSX)
226 // FindInPage on Mac doesn't use prepopulated values. Search there is global. 227 // FindInPage on Mac doesn't use prepopulated values. Search there is global.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 string16 str; 354 string16 str;
354 views::ViewsDelegate::views_delegate->GetClipboard()-> 355 views::ViewsDelegate::views_delegate->GetClipboard()->
355 ReadText(ui::Clipboard::BUFFER_STANDARD, &str); 356 ReadText(ui::Clipboard::BUFFER_STANDARD, &str);
356 357
357 // Make sure the text is copied successfully. 358 // Make sure the text is copied successfully.
358 EXPECT_EQ(ASCIIToUTF16("a"), str); 359 EXPECT_EQ(ASCIIToUTF16("a"), str);
359 360
360 // Press Ctrl-V to paste the content back, it should start finding even if the 361 // Press Ctrl-V to paste the content back, it should start finding even if the
361 // content is not changed. 362 // content is not changed.
362 content::Source<WebContents> notification_source( 363 content::Source<WebContents> notification_source(
363 browser()->GetActiveWebContents()); 364 chrome::GetActiveWebContents(browser()));
364 ui_test_utils::WindowedNotificationObserverWithDetails 365 ui_test_utils::WindowedNotificationObserverWithDetails
365 <FindNotificationDetails> observer( 366 <FindNotificationDetails> observer(
366 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, notification_source); 367 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, notification_source);
367 368
368 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 369 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
369 browser(), ui::VKEY_V, true, false, false, false)); 370 browser(), ui::VKEY_V, true, false, false, false));
370 371
371 ASSERT_NO_FATAL_FAILURE(observer.Wait()); 372 ASSERT_NO_FATAL_FAILURE(observer.Wait());
372 FindNotificationDetails details; 373 FindNotificationDetails details;
373 ASSERT_TRUE(observer.GetDetailsFor(notification_source.map_key(), &details)); 374 ASSERT_TRUE(observer.GetDetailsFor(notification_source.map_key(), &details));
374 EXPECT_TRUE(details.number_of_matches() > 0); 375 EXPECT_TRUE(details.number_of_matches() > 0);
375 } 376 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/constrained_window_views_browsertest.cc ('k') | chrome/browser/ui/views/frame/browser_frame_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698