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

Side by Side Diff: chrome/browser/ui/find_bar/find_bar_host_browsertest.cc

Issue 12315071: Revert 184352 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 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
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/omnibox/omnibox_view_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Deleted: svn:mergeinfo
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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/string16.h" 7 #include "base/string16.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/common/cancelable_request.h" 10 #include "chrome/browser/common/cancelable_request.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 131 }
132 132
133 // Platform independent FindInPage that takes |const wchar_t*| 133 // Platform independent FindInPage that takes |const wchar_t*|
134 // as an input. 134 // as an input.
135 int FindInPageWchar(WebContents* web_contents, 135 int FindInPageWchar(WebContents* web_contents,
136 const wchar_t* search_str, 136 const wchar_t* search_str,
137 bool forward, 137 bool forward,
138 bool case_sensitive, 138 bool case_sensitive,
139 int* ordinal) { 139 int* ordinal) {
140 return ui_test_utils::FindInPage( 140 return ui_test_utils::FindInPage(
141 web_contents, base::WideToUTF16(std::wstring(search_str)), 141 web_contents, WideToUTF16(std::wstring(search_str)),
142 forward, case_sensitive, ordinal, NULL); 142 forward, case_sensitive, ordinal, NULL);
143 } 143 }
144 144
145 // Calls FindInPageWchar till the find box's x position != |start_x_position|. 145 // Calls FindInPageWchar till the find box's x position != |start_x_position|.
146 // Return |start_x_position| if the find box has not moved after iterating 146 // Return |start_x_position| if the find box has not moved after iterating
147 // through all matches of |search_str|. 147 // through all matches of |search_str|.
148 int FindInPageTillBoxMoves(WebContents* web_contents, 148 int FindInPageTillBoxMoves(WebContents* web_contents,
149 int start_x_position, 149 int start_x_position,
150 const wchar_t* search_str, 150 const wchar_t* search_str,
151 int expected_matches) { 151 int expected_matches) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 313
314 GURL download_url = ui_test_utils::GetTestUrl( 314 GURL download_url = ui_test_utils::GetTestUrl(
315 base::FilePath().AppendASCII("downloads"), 315 base::FilePath().AppendASCII("downloads"),
316 base::FilePath().AppendASCII("a_zip_file.zip")); 316 base::FilePath().AppendASCII("a_zip_file.zip"));
317 ui_test_utils::DownloadURL(browser(), download_url); 317 ui_test_utils::DownloadURL(browser(), download_url);
318 318
319 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL)); 319 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL));
320 FlushHistoryService(); 320 FlushHistoryService();
321 EXPECT_EQ(1, 321 EXPECT_EQ(1,
322 FindInPageWchar(web_contents, 322 FindInPageWchar(web_contents,
323 base::ASCIIToWide(download_url.spec()).c_str(), 323 ASCIIToWide(download_url.spec()).c_str(), kFwd,
324 kFwd, kIgnoreCase, NULL)); 324 kIgnoreCase, NULL));
325 } 325 }
326 326
327 // Verify search selection coordinates. The data file used is set-up such that 327 // Verify search selection coordinates. The data file used is set-up such that
328 // the text occurs on the same line, and we verify their positions by verifying 328 // the text occurs on the same line, and we verify their positions by verifying
329 // their relative positions. 329 // their relative positions.
330 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageSpecialURLs) { 330 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageSpecialURLs) {
331 std::wstring search_string(L"\u5728\u897f\u660c\u536b\u661f\u53d1"); 331 std::wstring search_string(L"\u5728\u897f\u660c\u536b\u661f\u53d1");
332 gfx::Rect first, second, first_reverse; 332 gfx::Rect first, second, first_reverse;
333 WebContents* web_contents = 333 WebContents* web_contents =
334 browser()->tab_strip_model()->GetActiveWebContents(); 334 browser()->tab_strip_model()->GetActiveWebContents();
335 ui_test_utils::NavigateToURL(browser(), GetURL("specialchar.html")); 335 ui_test_utils::NavigateToURL(browser(), GetURL("specialchar.html"));
336 ui_test_utils::FindInPage(web_contents, base::WideToUTF16(search_string), 336 ui_test_utils::FindInPage(web_contents, WideToUTF16(search_string),
337 kFwd, kIgnoreCase, NULL, &first); 337 kFwd, kIgnoreCase, NULL, &first);
338 ui_test_utils::FindInPage(web_contents, base::WideToUTF16(search_string), 338 ui_test_utils::FindInPage(web_contents, WideToUTF16(search_string),
339 kFwd, kIgnoreCase, NULL, &second); 339 kFwd, kIgnoreCase, NULL, &second);
340 340
341 // We have search occurrence in the same row, so top-bottom coordinates should 341 // We have search occurrence in the same row, so top-bottom coordinates should
342 // be the same even for second search. 342 // be the same even for second search.
343 ASSERT_EQ(first.y(), second.y()); 343 ASSERT_EQ(first.y(), second.y());
344 ASSERT_EQ(first.bottom(), second.bottom()); 344 ASSERT_EQ(first.bottom(), second.bottom());
345 ASSERT_LT(first.x(), second.x()); 345 ASSERT_LT(first.x(), second.x());
346 ASSERT_LT(first.right(), second.right()); 346 ASSERT_LT(first.right(), second.right());
347 347
348 ui_test_utils::FindInPage( 348 ui_test_utils::FindInPage(
349 web_contents, base::WideToUTF16(search_string), kBack, kIgnoreCase, NULL, 349 web_contents, WideToUTF16(search_string), kBack, kIgnoreCase, NULL,
350 &first_reverse); 350 &first_reverse);
351 // We find next and we go back so find coordinates should be the same as 351 // We find next and we go back so find coordinates should be the same as
352 // previous ones. 352 // previous ones.
353 ASSERT_EQ(first, first_reverse); 353 ASSERT_EQ(first, first_reverse);
354 } 354 }
355 355
356 // Verifies that comments and meta data are not searchable. 356 // Verifies that comments and meta data are not searchable.
357 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, 357 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
358 CommentsAndMetaDataNotSearchable) { 358 CommentsAndMetaDataNotSearchable) {
359 WebContents* web_contents = 359 WebContents* web_contents =
360 browser()->tab_strip_model()->GetActiveWebContents(); 360 browser()->tab_strip_model()->GetActiveWebContents();
361 ui_test_utils::NavigateToURL(browser(), GetURL("specialchar.html")); 361 ui_test_utils::NavigateToURL(browser(), GetURL("specialchar.html"));
362 362
363 std::wstring search_string = 363 std::wstring search_string =
364 L"\u4e2d\u65b0\u793e\u8bb0\u8005\u5b8b" 364 L"\u4e2d\u65b0\u793e\u8bb0\u8005\u5b8b\u5409\u6cb3\u6444\u4e2d\u65b0\u7f51 ";
365 L"\u5409\u6cb3\u6444\u4e2d\u65b0\u7f51";
366 EXPECT_EQ(0, ui_test_utils::FindInPage( 365 EXPECT_EQ(0, ui_test_utils::FindInPage(
367 web_contents, base::WideToUTF16(search_string), kFwd, kIgnoreCase, NULL, 366 web_contents, WideToUTF16(search_string), kFwd, kIgnoreCase, NULL, NULL));
368 NULL));
369 } 367 }
370 368
371 // Verifies that span and lists are searchable. 369 // Verifies that span and lists are searchable.
372 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, SpanAndListsSearchable) { 370 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, SpanAndListsSearchable) {
373 WebContents* web_contents = 371 WebContents* web_contents =
374 browser()->tab_strip_model()->GetActiveWebContents(); 372 browser()->tab_strip_model()->GetActiveWebContents();
375 ui_test_utils::NavigateToURL(browser(), GetURL("FindRandomTests.html")); 373 ui_test_utils::NavigateToURL(browser(), GetURL("FindRandomTests.html"));
376 374
377 std::wstring search_string = L"has light blue eyes and my father has dark"; 375 std::wstring search_string = L"has light blue eyes and my father has dark";
378 EXPECT_EQ(1, ui_test_utils::FindInPage( 376 EXPECT_EQ(1, ui_test_utils::FindInPage(
379 web_contents, base::WideToUTF16(search_string), kFwd, kIgnoreCase, NULL, 377 web_contents, WideToUTF16(search_string), kFwd, kIgnoreCase, NULL, NULL));
380 NULL));
381 378
382 search_string = L"Google\nApple\nandroid"; 379 search_string = L"Google\nApple\nandroid";
383 EXPECT_EQ(1, ui_test_utils::FindInPage( 380 EXPECT_EQ(1, ui_test_utils::FindInPage(
384 web_contents, base::WideToUTF16(search_string), kFwd, kIgnoreCase, NULL, 381 web_contents, WideToUTF16(search_string), kFwd, kIgnoreCase, NULL, NULL));
385 NULL));
386 } 382 }
387 383
388 // Find in a very large page. 384 // Find in a very large page.
389 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, LargePage) { 385 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, LargePage) {
390 WebContents* web_contents = 386 WebContents* web_contents =
391 browser()->tab_strip_model()->GetActiveWebContents(); 387 browser()->tab_strip_model()->GetActiveWebContents();
392 ui_test_utils::NavigateToURL(browser(), GetURL("largepage.html")); 388 ui_test_utils::NavigateToURL(browser(), GetURL("largepage.html"));
393 389
394 std::wstring search_string = L"daughter of Prince"; 390 std::wstring search_string = L"daughter of Prince";
395 EXPECT_EQ(373, 391 EXPECT_EQ(373,
396 FindInPageWchar(web_contents, search_string.c_str(), 392 FindInPageWchar(web_contents, search_string.c_str(),
397 kFwd, kIgnoreCase, NULL)); 393 kFwd, kIgnoreCase, NULL));
398 } 394 }
399 395
400 // Find a very long string in a large page. 396 // Find a very long string in a large page.
401 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindLongString) { 397 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindLongString) {
402 WebContents* web_contents = 398 WebContents* web_contents =
403 browser()->tab_strip_model()->GetActiveWebContents(); 399 browser()->tab_strip_model()->GetActiveWebContents();
404 ui_test_utils::NavigateToURL(browser(), GetURL("largepage.html")); 400 ui_test_utils::NavigateToURL(browser(), GetURL("largepage.html"));
405 401
406 base::FilePath path = ui_test_utils::GetTestFilePath( 402 base::FilePath path = ui_test_utils::GetTestFilePath(
407 base::FilePath().AppendASCII("find_in_page"), 403 base::FilePath().AppendASCII("find_in_page"),
408 base::FilePath().AppendASCII("LongFind.txt")); 404 base::FilePath().AppendASCII("LongFind.txt"));
409 std::string query; 405 std::string query;
410 file_util::ReadFileToString(path, &query); 406 file_util::ReadFileToString(path, &query);
411 std::wstring search_string = base::UTF8ToWide(query); 407 std::wstring search_string = UTF8ToWide(query);
412 EXPECT_EQ(1, 408 EXPECT_EQ(1,
413 FindInPageWchar(web_contents, search_string.c_str(), 409 FindInPageWchar(web_contents, search_string.c_str(),
414 kFwd, kIgnoreCase, NULL)); 410 kFwd, kIgnoreCase, NULL));
415 } 411 }
416 412
417 // Find a big font string in a page. 413 // Find a big font string in a page.
418 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, BigString) { 414 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, BigString) {
419 WebContents* web_contents = 415 WebContents* web_contents =
420 browser()->tab_strip_model()->GetActiveWebContents(); 416 browser()->tab_strip_model()->GetActiveWebContents();
421 ui_test_utils::NavigateToURL(browser(), GetURL("BigText.html")); 417 ui_test_utils::NavigateToURL(browser(), GetURL("BigText.html"));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 WebContents* web_contents = 460 WebContents* web_contents =
465 browser()->tab_strip_model()->GetActiveWebContents(); 461 browser()->tab_strip_model()->GetActiveWebContents();
466 462
467 base::FilePath path = ui_test_utils::GetTestFilePath( 463 base::FilePath path = ui_test_utils::GetTestFilePath(
468 base::FilePath().AppendASCII("find_in_page"), 464 base::FilePath().AppendASCII("find_in_page"),
469 base::FilePath().AppendASCII("find_test.txt")); 465 base::FilePath().AppendASCII("find_test.txt"));
470 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(path)); 466 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(path));
471 467
472 std::string query; 468 std::string query;
473 file_util::ReadFileToString(path, &query); 469 file_util::ReadFileToString(path, &query);
474 std::wstring search_string = base::UTF8ToWide(query); 470 std::wstring search_string = UTF8ToWide(query);
475 EXPECT_EQ(1, 471 EXPECT_EQ(1,
476 FindInPageWchar(web_contents, search_string.c_str(), 472 FindInPageWchar(web_contents, search_string.c_str(),
477 false, false, NULL)); 473 false, false, NULL));
478 } 474 }
479 475
480 // Specifying a prototype so that we can add the WARN_UNUSED_RESULT attribute. 476 // Specifying a prototype so that we can add the WARN_UNUSED_RESULT attribute.
481 bool FocusedOnPage(WebContents* web_contents, std::string* result) 477 bool FocusedOnPage(WebContents* web_contents, std::string* result)
482 WARN_UNUSED_RESULT; 478 WARN_UNUSED_RESULT;
483 479
484 bool FocusedOnPage(WebContents* web_contents, std::string* result) { 480 bool FocusedOnPage(WebContents* web_contents, std::string* result) {
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 1183
1188 // Switch back to first tab. 1184 // Switch back to first tab.
1189 browser()->tab_strip_model()->ActivateTabAt(0, false); 1185 browser()->tab_strip_model()->ActivateTabAt(0, false);
1190 browser()->GetFindBarController()->EndFindSession( 1186 browser()->GetFindBarController()->EndFindSession(
1191 FindBarController::kKeepSelectionOnPage, 1187 FindBarController::kKeepSelectionOnPage,
1192 FindBarController::kKeepResultsInFindBox); 1188 FindBarController::kKeepResultsInFindBox);
1193 // Simulate F3. 1189 // Simulate F3.
1194 ui_test_utils::FindInPage(web_contents_1, string16(), 1190 ui_test_utils::FindInPage(web_contents_1, string16(),
1195 kFwd, kIgnoreCase, &ordinal, NULL); 1191 kFwd, kIgnoreCase, &ordinal, NULL);
1196 EXPECT_EQ(FindTabHelper::FromWebContents(web_contents_1)->find_text(), 1192 EXPECT_EQ(FindTabHelper::FromWebContents(web_contents_1)->find_text(),
1197 base::WideToUTF16(L"text")); 1193 WideToUTF16(L"text"));
1198 } 1194 }
1199 1195
1200 // This tests that whenever you close and reopen the Find bar, it should show 1196 // This tests that whenever you close and reopen the Find bar, it should show
1201 // the last search entered in that tab. http://crbug.com/40121. 1197 // the last search entered in that tab. http://crbug.com/40121.
1202 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateSameTab) { 1198 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateSameTab) {
1203 #if defined(OS_MACOSX) 1199 #if defined(OS_MACOSX)
1204 // FindInPage on Mac doesn't use prepopulated values. Search there is global. 1200 // FindInPage on Mac doesn't use prepopulated values. Search there is global.
1205 return; 1201 return;
1206 #endif 1202 #endif
1207 1203
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 content::RunAllPendingInMessageLoop(); // Needed on Linux. 1503 content::RunAllPendingInMessageLoop(); // Needed on Linux.
1508 EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL)); 1504 EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL));
1509 1505
1510 ui_test_utils::NavigateToURLWithDisposition( 1506 ui_test_utils::NavigateToURLWithDisposition(
1511 browser(), url, NEW_FOREGROUND_TAB, 1507 browser(), url, NEW_FOREGROUND_TAB,
1512 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1508 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1513 chrome::CloseTab(browser()); 1509 chrome::CloseTab(browser());
1514 EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL)); 1510 EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL));
1515 EXPECT_EQ(position, position2); 1511 EXPECT_EQ(position, position2);
1516 } 1512 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/omnibox/omnibox_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698