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

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

Issue 5553002: Fix Find regression where text is not selected once you... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/keyboard_codes.h" 5 #include "app/keyboard_codes.h"
6 #include "base/process_util.h" 6 #include "base/process_util.h"
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/tab_contents/tab_contents.h" 10 #include "chrome/browser/tab_contents/tab_contents.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 browser()->FocusLocationBar(); 167 browser()->FocusLocationBar();
168 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR)); 168 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
169 browser()->GetFindBarController()->Show(); 169 browser()->GetFindBarController()->Show();
170 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), 170 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
171 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 171 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
172 browser()->GetFindBarController()->EndFindSession( 172 browser()->GetFindBarController()->EndFindSession(
173 FindBarController::kKeepSelection); 173 FindBarController::kKeepSelection);
174 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR)); 174 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
175 } 175 }
176 176
177 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestoreOnTabSwitch) {
178 base::TimeTicks start_time = base::TimeTicks::Now();
179 Checkpoint("Starting test server", start_time);
180
181 ASSERT_TRUE(test_server()->Start());
182
183 // First we navigate to our test page (tab A).
184 GURL url = test_server()->GetURL(kSimplePage);
185 ui_test_utils::NavigateToURL(browser(), url);
186
187 Checkpoint("Calling Find", start_time);
188
189 browser()->Find();
190 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
191 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
192
193 Checkpoint("GetFindBarTesting", start_time);
194
195 FindBarTesting* find_bar =
196 browser()->GetFindBarController()->find_bar()->GetFindBarTesting();
197
198 Checkpoint("Search for 'a'", start_time);
199
200 // Search for 'a'.
201 ui_test_utils::FindInPage(browser()->GetSelectedTabContents(),
202 ASCIIToUTF16("a"), true, false, NULL);
203 EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText());
204
205 Checkpoint("Open tab B", start_time);
206
207 // Open another tab (tab B).
208 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED);
209 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
210
211 Checkpoint("Open find", start_time);
212
213 // Make sure Find box is open.
214 browser()->Find();
215 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
216 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
217
218 Checkpoint("Search for 'b'", start_time);
219
220 // Search for 'b'.
221 ui_test_utils::FindInPage(browser()->GetSelectedTabContents(),
222 ASCIIToUTF16("b"), true, false, NULL);
223 EXPECT_TRUE(ASCIIToUTF16("b") == find_bar->GetFindSelectedText());
224
225 Checkpoint("Focus location bar", start_time);
226
227 // Set focus away from the Find bar (to the Location bar).
228 browser()->FocusLocationBar();
229 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
230
231 Checkpoint("Select tab A", start_time);
232
233 // Select tab A. Find bar should get focus.
234 browser()->SelectTabContentsAt(0, true);
235 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
236 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
237 EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText());
238
239 Checkpoint("Select tab B", start_time);
240
241 // Select tab B. Location bar should get focus.
242 browser()->SelectTabContentsAt(1, true);
243 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
244
245 Checkpoint("Test done", start_time);
246 }
247
177 // This tests that whenever you clear values from the Find box and close it that 248 // This tests that whenever you clear values from the Find box and close it that
178 // it respects that and doesn't show you the last search, as reported in bug: 249 // it respects that and doesn't show you the last search, as reported in bug:
179 // http://crbug.com/40121. 250 // http://crbug.com/40121.
180 IN_PROC_BROWSER_TEST_F(FindInPageTest, PrepopulateRespectBlank) { 251 IN_PROC_BROWSER_TEST_F(FindInPageTest, PrepopulateRespectBlank) {
181 #if defined(OS_MACOSX) 252 #if defined(OS_MACOSX)
182 // FindInPage on Mac doesn't use prepopulated values. Search there is global. 253 // FindInPage on Mac doesn't use prepopulated values. Search there is global.
183 return; 254 return;
184 #endif 255 #endif
185 256
186 base::TimeTicks start_time = base::TimeTicks::Now(); 257 base::TimeTicks start_time = base::TimeTicks::Now();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 314 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
244 browser(), app::VKEY_F3, false, false, false, false)); 315 browser(), app::VKEY_F3, false, false, false, false));
245 316
246 // After the Find box has been reopened, it should still have no prepopulate 317 // After the Find box has been reopened, it should still have no prepopulate
247 // value. 318 // value.
248 Checkpoint("GetFindBarText", start_time); 319 Checkpoint("GetFindBarText", start_time);
249 EXPECT_EQ(string16(), GetFindBarText()); 320 EXPECT_EQ(string16(), GetFindBarText());
250 321
251 Checkpoint("Test completed", start_time); 322 Checkpoint("Test completed", start_time);
252 } 323 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698