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

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

Issue 10823392: Let ui_test_utils::FindInPage optionally return the selection rect. This will be used in a future c… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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/tab_restore_browsertest.cc ('k') | chrome/browser/ui/pdf/pdf_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/string16.h" 6 #include "base/string16.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 // Platform independent FindInPage that takes |const wchar_t*| 134 // Platform independent FindInPage that takes |const wchar_t*|
135 // as an input. 135 // as an input.
136 int FindInPageWchar(TabContents* tab, 136 int FindInPageWchar(TabContents* tab,
137 const wchar_t* search_str, 137 const wchar_t* search_str,
138 bool forward, 138 bool forward,
139 bool case_sensitive, 139 bool case_sensitive,
140 int* ordinal) { 140 int* ordinal) {
141 return ui_test_utils::FindInPage( 141 return ui_test_utils::FindInPage(
142 tab, WideToUTF16(std::wstring(search_str)), 142 tab, WideToUTF16(std::wstring(search_str)),
143 forward, case_sensitive, ordinal); 143 forward, case_sensitive, ordinal, NULL);
144 } 144 }
145 145
146 // Calls FindInPageWchar till the find box's x position != |start_x_position|. 146 // Calls FindInPageWchar till the find box's x position != |start_x_position|.
147 // Return |start_x_position| if the find box has not moved after iterating 147 // Return |start_x_position| if the find box has not moved after iterating
148 // through all matches of |search_str|. 148 // through all matches of |search_str|.
149 int FindInPageTillBoxMoves(TabContents* tab, 149 int FindInPageTillBoxMoves(TabContents* tab,
150 int start_x_position, 150 int start_x_position,
151 const wchar_t* search_str, 151 const wchar_t* search_str,
152 int expected_matches) { 152 int expected_matches) {
153 // Search for |search_str| which the Find box is obscuring. 153 // Search for |search_str| which the Find box is obscuring.
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 kFwd, kIgnoreCase, &ordinal)); 804 kFwd, kIgnoreCase, &ordinal));
805 EXPECT_EQ(0, ordinal); 805 EXPECT_EQ(0, ordinal);
806 806
807 // Open another tab (tab B). 807 // Open another tab (tab B).
808 chrome::NewTab(browser()); 808 chrome::NewTab(browser());
809 ui_test_utils::NavigateToURL(browser(), url); 809 ui_test_utils::NavigateToURL(browser(), url);
810 810
811 // Simulate what happens when you press F3 for FindNext. We should get a 811 // Simulate what happens when you press F3 for FindNext. We should get a
812 // response here (a hang means search was aborted). 812 // response here (a hang means search was aborted).
813 EXPECT_EQ(0, ui_test_utils::FindInPage(tab, string16(), 813 EXPECT_EQ(0, ui_test_utils::FindInPage(tab, string16(),
814 kFwd, kIgnoreCase, &ordinal)); 814 kFwd, kIgnoreCase, &ordinal, NULL));
815 EXPECT_EQ(0, ordinal); 815 EXPECT_EQ(0, ordinal);
816 816
817 // Open another tab (tab C). 817 // Open another tab (tab C).
818 chrome::NewTab(browser()); 818 chrome::NewTab(browser());
819 ui_test_utils::NavigateToURL(browser(), url); 819 ui_test_utils::NavigateToURL(browser(), url);
820 820
821 // Simulate what happens when you press F3 for FindNext. We should get a 821 // Simulate what happens when you press F3 for FindNext. We should get a
822 // response here (a hang means search was aborted). 822 // response here (a hang means search was aborted).
823 EXPECT_EQ(0, ui_test_utils::FindInPage(tab, string16(), 823 EXPECT_EQ(0, ui_test_utils::FindInPage(tab, string16(),
824 kFwd, kIgnoreCase, &ordinal)); 824 kFwd, kIgnoreCase, &ordinal, NULL));
825 EXPECT_EQ(0, ordinal); 825 EXPECT_EQ(0, ordinal);
826 } 826 }
827 827
828 #if defined(TOOLKIT_VIEWS) 828 #if defined(TOOLKIT_VIEWS)
829 // Make sure Find box grabs the Esc accelerator and restores it again. 829 // Make sure Find box grabs the Esc accelerator and restores it again.
830 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, AcceleratorRestoring) { 830 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, AcceleratorRestoring) {
831 // First we navigate to any page. 831 // First we navigate to any page.
832 GURL url = GetURL(kSimple); 832 GURL url = GetURL(kSimple);
833 ui_test_utils::NavigateToURL(browser(), url); 833 ui_test_utils::NavigateToURL(browser(), url);
834 834
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 901
902 // Search for 'page'. Should have 1 match. 902 // Search for 'page'. Should have 1 match.
903 int ordinal = 0; 903 int ordinal = 0;
904 TabContents* tab = chrome::GetActiveTabContents(browser()); 904 TabContents* tab = chrome::GetActiveTabContents(browser());
905 EXPECT_EQ(1, FindInPageWchar(tab, L"page", kFwd, kIgnoreCase, &ordinal)); 905 EXPECT_EQ(1, FindInPageWchar(tab, L"page", kFwd, kIgnoreCase, &ordinal));
906 EXPECT_EQ(1, ordinal); 906 EXPECT_EQ(1, ordinal);
907 907
908 // Simulate what happens when you press F3 for FindNext. Still should show 908 // Simulate what happens when you press F3 for FindNext. Still should show
909 // one match. This cleared the pre-populate string at one point (see bug). 909 // one match. This cleared the pre-populate string at one point (see bug).
910 EXPECT_EQ(1, ui_test_utils::FindInPage(tab, string16(), 910 EXPECT_EQ(1, ui_test_utils::FindInPage(tab, string16(),
911 kFwd, kIgnoreCase, &ordinal)); 911 kFwd, kIgnoreCase, &ordinal, NULL));
912 EXPECT_EQ(1, ordinal); 912 EXPECT_EQ(1, ordinal);
913 913
914 // End the Find session, thereby making the next F3 start afresh. 914 // End the Find session, thereby making the next F3 start afresh.
915 browser()->GetFindBarController()->EndFindSession( 915 browser()->GetFindBarController()->EndFindSession(
916 FindBarController::kKeepSelectionOnPage, 916 FindBarController::kKeepSelectionOnPage,
917 FindBarController::kKeepResultsInFindBox); 917 FindBarController::kKeepResultsInFindBox);
918 918
919 // Simulate F3 while Find box is closed. Should have 1 match. 919 // Simulate F3 while Find box is closed. Should have 1 match.
920 EXPECT_EQ(1, FindInPageWchar(tab, L"", kFwd, kIgnoreCase, &ordinal)); 920 EXPECT_EQ(1, FindInPageWchar(tab, L"", kFwd, kIgnoreCase, &ordinal));
921 EXPECT_EQ(1, ordinal); 921 EXPECT_EQ(1, ordinal);
(...skipping 23 matching lines...) Expand all
945 945
946 // Find "given". 946 // Find "given".
947 FindInPageWchar(tab2, L"given", kFwd, kIgnoreCase, &ordinal); 947 FindInPageWchar(tab2, L"given", kFwd, kIgnoreCase, &ordinal);
948 948
949 // Switch back to first tab. 949 // Switch back to first tab.
950 chrome::ActivateTabAt(browser(), 0, false); 950 chrome::ActivateTabAt(browser(), 0, false);
951 browser()->GetFindBarController()->EndFindSession( 951 browser()->GetFindBarController()->EndFindSession(
952 FindBarController::kKeepSelectionOnPage, 952 FindBarController::kKeepSelectionOnPage,
953 FindBarController::kKeepResultsInFindBox); 953 FindBarController::kKeepResultsInFindBox);
954 // Simulate F3. 954 // Simulate F3.
955 ui_test_utils::FindInPage(tab1, string16(), kFwd, kIgnoreCase, &ordinal); 955 ui_test_utils::FindInPage(tab1, string16(), kFwd, kIgnoreCase, &ordinal,
956 NULL);
956 EXPECT_EQ(tab1->find_tab_helper()->find_text(), WideToUTF16(L"text")); 957 EXPECT_EQ(tab1->find_tab_helper()->find_text(), WideToUTF16(L"text"));
957 } 958 }
958 959
959 // This tests that whenever you close and reopen the Find bar, it should show 960 // This tests that whenever you close and reopen the Find bar, it should show
960 // the last search entered in that tab. http://crbug.com/40121. 961 // the last search entered in that tab. http://crbug.com/40121.
961 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateSameTab) { 962 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateSameTab) {
962 #if defined(OS_MACOSX) 963 #if defined(OS_MACOSX)
963 // FindInPage on Mac doesn't use prepopulated values. Search there is global. 964 // FindInPage on Mac doesn't use prepopulated values. Search there is global.
964 return; 965 return;
965 #endif 966 #endif
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 content::RunAllPendingInMessageLoop(); // Needed on Linux. 1253 content::RunAllPendingInMessageLoop(); // Needed on Linux.
1253 EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL)); 1254 EXPECT_TRUE(GetFindBarWindowInfo(&position, NULL));
1254 1255
1255 ui_test_utils::NavigateToURLWithDisposition( 1256 ui_test_utils::NavigateToURLWithDisposition(
1256 browser(), url, NEW_FOREGROUND_TAB, 1257 browser(), url, NEW_FOREGROUND_TAB,
1257 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1258 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1258 chrome::CloseTab(browser()); 1259 chrome::CloseTab(browser());
1259 EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL)); 1260 EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL));
1260 EXPECT_EQ(position, position2); 1261 EXPECT_EQ(position, position2);
1261 } 1262 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_restore_browsertest.cc ('k') | chrome/browser/ui/pdf/pdf_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698