| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/keyboard_codes.h" | 5 #include "base/keyboard_codes.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "chrome/browser/browser.h" | 7 #include "chrome/browser/browser.h" |
| 8 #include "chrome/browser/browser_window.h" | 8 #include "chrome/browser/browser_window.h" |
| 9 #include "chrome/browser/find_bar_controller.h" | 9 #include "chrome/browser/find_bar_controller.h" |
| 10 #include "chrome/browser/find_notification_details.h" | 10 #include "chrome/browser/find_notification_details.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 const std::wstring kFramePage = L"files/find_in_page/frames.html"; | 21 const std::wstring kFramePage = L"files/find_in_page/frames.html"; |
| 22 const std::wstring kFrameData = L"files/find_in_page/framedata_general.html"; | 22 const std::wstring kFrameData = L"files/find_in_page/framedata_general.html"; |
| 23 const std::wstring kUserSelectPage = L"files/find_in_page/user-select.html"; | 23 const std::wstring kUserSelectPage = L"files/find_in_page/user-select.html"; |
| 24 const std::wstring kCrashPage = L"files/find_in_page/crash_1341577.html"; | 24 const std::wstring kCrashPage = L"files/find_in_page/crash_1341577.html"; |
| 25 const std::wstring kTooFewMatchesPage = L"files/find_in_page/bug_1155639.html"; | 25 const std::wstring kTooFewMatchesPage = L"files/find_in_page/bug_1155639.html"; |
| 26 const std::wstring kEndState = L"files/find_in_page/end_state.html"; | 26 const std::wstring kEndState = L"files/find_in_page/end_state.html"; |
| 27 const std::wstring kPrematureEnd = L"files/find_in_page/premature_end.html"; | 27 const std::wstring kPrematureEnd = L"files/find_in_page/premature_end.html"; |
| 28 const std::wstring kMoveIfOver = L"files/find_in_page/move_if_obscuring.html"; | 28 const std::wstring kMoveIfOver = L"files/find_in_page/move_if_obscuring.html"; |
| 29 const std::wstring kBitstackCrash = L"files/find_in_page/crash_14491.html"; | 29 const std::wstring kBitstackCrash = L"files/find_in_page/crash_14491.html"; |
| 30 | 30 |
| 31 namespace { | 31 const bool kBack = false; |
| 32 const bool kFwd = true; |
| 32 | 33 |
| 33 class FindInPageNotificationObserver : public NotificationObserver { | 34 const bool kIgnoreCase = false; |
| 34 public: | 35 const bool kCaseSensitive = true; |
| 35 explicit FindInPageNotificationObserver(TabContents* parent_tab) | |
| 36 : parent_tab_(parent_tab), | |
| 37 active_match_ordinal_(-1), | |
| 38 number_of_matches_(0) { | |
| 39 current_find_request_id_ = parent_tab->current_find_request_id(); | |
| 40 registrar_.Add(this, NotificationType::FIND_RESULT_AVAILABLE, | |
| 41 Source<TabContents>(parent_tab_)); | |
| 42 ui_test_utils::RunMessageLoop(); | |
| 43 } | |
| 44 | |
| 45 int active_match_ordinal() const { return active_match_ordinal_; } | |
| 46 | |
| 47 int number_of_matches() const { return number_of_matches_; } | |
| 48 | |
| 49 virtual void Observe(NotificationType type, const NotificationSource& source, | |
| 50 const NotificationDetails& details) { | |
| 51 if (type == NotificationType::FIND_RESULT_AVAILABLE) { | |
| 52 Details<FindNotificationDetails> find_details(details); | |
| 53 if (find_details->request_id() == current_find_request_id_) { | |
| 54 // We get multiple responses and one of those will contain the ordinal. | |
| 55 // This message comes to us before the final update is sent. | |
| 56 if (find_details->active_match_ordinal() > -1) | |
| 57 active_match_ordinal_ = find_details->active_match_ordinal(); | |
| 58 if (find_details->final_update()) { | |
| 59 number_of_matches_ = find_details->number_of_matches(); | |
| 60 MessageLoopForUI::current()->Quit(); | |
| 61 } else { | |
| 62 DLOG(INFO) << "Ignoring, since we only care about the final message"; | |
| 63 } | |
| 64 } | |
| 65 } else { | |
| 66 NOTREACHED(); | |
| 67 } | |
| 68 } | |
| 69 | |
| 70 private: | |
| 71 NotificationRegistrar registrar_; | |
| 72 TabContents* parent_tab_; | |
| 73 // We will at some point (before final update) be notified of the ordinal and | |
| 74 // we need to preserve it so we can send it later. | |
| 75 int active_match_ordinal_; | |
| 76 int number_of_matches_; | |
| 77 // The id of the current find request, obtained from TabContents. Allows us | |
| 78 // to monitor when the search completes. | |
| 79 int current_find_request_id_; | |
| 80 }; | |
| 81 | |
| 82 } // namespace | |
| 83 | |
| 84 typedef enum { BACK = 0, FWD = 1 } FindInPageDirection; | |
| 85 typedef enum { IGNORE_CASE = 0, CASE_SENSITIVE = 1 } FindInPageCase; | |
| 86 | 36 |
| 87 class FindInPageControllerTest : public InProcessBrowserTest { | 37 class FindInPageControllerTest : public InProcessBrowserTest { |
| 88 public: | 38 public: |
| 89 FindInPageControllerTest() { | 39 FindInPageControllerTest() { |
| 90 EnableDOMAutomation(); | 40 EnableDOMAutomation(); |
| 91 } | 41 } |
| 92 | 42 |
| 93 protected: | 43 protected: |
| 94 int FindInPage(const std::wstring& search_string, | |
| 95 FindInPageDirection forward, | |
| 96 FindInPageCase match_case, | |
| 97 int* ordinal) { | |
| 98 TabContents* tab_contents = browser()->GetSelectedTabContents(); | |
| 99 tab_contents->StartFinding(search_string, forward == FWD, | |
| 100 match_case == CASE_SENSITIVE); | |
| 101 | |
| 102 FindInPageNotificationObserver observer = | |
| 103 FindInPageNotificationObserver(tab_contents); | |
| 104 if (ordinal) | |
| 105 *ordinal = observer.active_match_ordinal(); | |
| 106 return observer.number_of_matches(); | |
| 107 } | |
| 108 | |
| 109 void GetFindBarWindowInfo(gfx::Point* position, bool* fully_visible) { | 44 void GetFindBarWindowInfo(gfx::Point* position, bool* fully_visible) { |
| 110 FindBarTesting* find_bar = | 45 FindBarTesting* find_bar = |
| 111 browser()->find_bar()->find_bar()->GetFindBarTesting(); | 46 browser()->find_bar()->find_bar()->GetFindBarTesting(); |
| 112 find_bar->GetFindBarWindowInfo(position, fully_visible); | 47 find_bar->GetFindBarWindowInfo(position, fully_visible); |
| 113 } | 48 } |
| 114 }; | 49 }; |
| 115 | 50 |
| 116 // This test loads a page with frames and starts FindInPage requests. | 51 // This test loads a page with frames and starts FindInPage requests. |
| 117 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageFrames) { | 52 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageFrames) { |
| 118 HTTPTestServer* server = StartHTTPServer(); | 53 HTTPTestServer* server = StartHTTPServer(); |
| 119 | 54 |
| 120 // First we navigate to our frames page. | 55 // First we navigate to our frames page. |
| 121 GURL url = server->TestServerPageW(kFramePage); | 56 GURL url = server->TestServerPageW(kFramePage); |
| 122 ui_test_utils::NavigateToURL(browser(), url); | 57 ui_test_utils::NavigateToURL(browser(), url); |
| 123 | 58 |
| 124 // Try incremental search (mimicking user typing in). | 59 // Try incremental search (mimicking user typing in). |
| 125 int ordinal = 0; | 60 int ordinal = 0; |
| 126 EXPECT_EQ(18, FindInPage(L"g", FWD, IGNORE_CASE, &ordinal)); | 61 TabContents* tab = browser()->GetSelectedTabContents(); |
| 62 EXPECT_EQ(18, ui_test_utils::FindInPage(tab, L"g", |
| 63 kFwd, kIgnoreCase, &ordinal)); |
| 127 EXPECT_EQ(1, ordinal); | 64 EXPECT_EQ(1, ordinal); |
| 128 EXPECT_EQ(11, FindInPage(L"go", FWD, IGNORE_CASE, &ordinal)); | 65 EXPECT_EQ(11, ui_test_utils::FindInPage(tab, L"go", |
| 66 kFwd, kIgnoreCase, &ordinal)); |
| 129 EXPECT_EQ(1, ordinal); | 67 EXPECT_EQ(1, ordinal); |
| 130 EXPECT_EQ(04, FindInPage(L"goo", FWD, IGNORE_CASE, &ordinal)); | 68 EXPECT_EQ(04, ui_test_utils::FindInPage(tab, L"goo", |
| 69 kFwd, kIgnoreCase, &ordinal)); |
| 131 EXPECT_EQ(1, ordinal); | 70 EXPECT_EQ(1, ordinal); |
| 132 EXPECT_EQ(03, FindInPage(L"goog", FWD, IGNORE_CASE, &ordinal)); | 71 EXPECT_EQ(03, ui_test_utils::FindInPage(tab, L"goog", |
| 72 kFwd, kIgnoreCase, &ordinal)); |
| 133 EXPECT_EQ(1, ordinal); | 73 EXPECT_EQ(1, ordinal); |
| 134 EXPECT_EQ(02, FindInPage(L"googl", FWD, IGNORE_CASE, &ordinal)); | 74 EXPECT_EQ(02, ui_test_utils::FindInPage(tab, L"googl", |
| 75 kFwd, kIgnoreCase, &ordinal)); |
| 135 EXPECT_EQ(1, ordinal); | 76 EXPECT_EQ(1, ordinal); |
| 136 EXPECT_EQ(01, FindInPage(L"google", FWD, IGNORE_CASE, &ordinal)); | 77 EXPECT_EQ(01, ui_test_utils::FindInPage(tab, L"google", |
| 78 kFwd, kIgnoreCase, &ordinal)); |
| 137 EXPECT_EQ(1, ordinal); | 79 EXPECT_EQ(1, ordinal); |
| 138 EXPECT_EQ(00, FindInPage(L"google!", FWD, IGNORE_CASE, &ordinal)); | 80 EXPECT_EQ(00, ui_test_utils::FindInPage(tab, L"google!", |
| 81 kFwd, kIgnoreCase, &ordinal)); |
| 139 EXPECT_EQ(0, ordinal); | 82 EXPECT_EQ(0, ordinal); |
| 140 | 83 |
| 141 // Negative test (no matches should be found). | 84 // Negative test (no matches should be found). |
| 142 EXPECT_EQ(0, FindInPage(L"Non-existing string", FWD, IGNORE_CASE, &ordinal)); | 85 EXPECT_EQ(0, ui_test_utils::FindInPage(tab, L"Non-existing string", |
| 86 kFwd, kIgnoreCase, &ordinal)); |
| 143 EXPECT_EQ(0, ordinal); | 87 EXPECT_EQ(0, ordinal); |
| 144 | 88 |
| 145 // 'horse' only exists in the three right frames. | 89 // 'horse' only exists in the three right frames. |
| 146 EXPECT_EQ(3, FindInPage(L"horse", FWD, IGNORE_CASE, &ordinal)); | 90 EXPECT_EQ(3, ui_test_utils::FindInPage(tab, L"horse", |
| 91 kFwd, kIgnoreCase, &ordinal)); |
| 147 EXPECT_EQ(1, ordinal); | 92 EXPECT_EQ(1, ordinal); |
| 148 | 93 |
| 149 // 'cat' only exists in the first frame. | 94 // 'cat' only exists in the first frame. |
| 150 EXPECT_EQ(1, FindInPage(L"cat", FWD, IGNORE_CASE, &ordinal)); | 95 EXPECT_EQ(1, ui_test_utils::FindInPage(tab, L"cat", |
| 96 kFwd, kIgnoreCase, &ordinal)); |
| 151 EXPECT_EQ(1, ordinal); | 97 EXPECT_EQ(1, ordinal); |
| 152 | 98 |
| 153 // Try searching again, should still come up with 1 match. | 99 // Try searching again, should still come up with 1 match. |
| 154 EXPECT_EQ(1, FindInPage(L"cat", FWD, IGNORE_CASE, &ordinal)); | 100 EXPECT_EQ(1, ui_test_utils::FindInPage(tab, L"cat", |
| 101 kFwd, kIgnoreCase, &ordinal)); |
| 155 EXPECT_EQ(1, ordinal); | 102 EXPECT_EQ(1, ordinal); |
| 156 | 103 |
| 157 // Try searching backwards, ignoring case, should still come up with 1 match. | 104 // Try searching backwards, ignoring case, should still come up with 1 match. |
| 158 EXPECT_EQ(1, FindInPage(L"CAT", BACK, IGNORE_CASE, &ordinal)); | 105 EXPECT_EQ(1, ui_test_utils::FindInPage(tab, L"CAT", |
| 106 kBack, kIgnoreCase, &ordinal)); |
| 159 EXPECT_EQ(1, ordinal); | 107 EXPECT_EQ(1, ordinal); |
| 160 | 108 |
| 161 // Try case sensitive, should NOT find it. | 109 // Try case sensitive, should NOT find it. |
| 162 EXPECT_EQ(0, FindInPage(L"CAT", FWD, CASE_SENSITIVE, &ordinal)); | 110 EXPECT_EQ(0, ui_test_utils::FindInPage(tab, L"CAT", |
| 111 kFwd, kCaseSensitive, &ordinal)); |
| 163 EXPECT_EQ(0, ordinal); | 112 EXPECT_EQ(0, ordinal); |
| 164 | 113 |
| 165 // Try again case sensitive, but this time with right case. | 114 // Try again case sensitive, but this time with right case. |
| 166 EXPECT_EQ(1, FindInPage(L"dog", FWD, CASE_SENSITIVE, &ordinal)); | 115 EXPECT_EQ(1, ui_test_utils::FindInPage(tab, L"dog", |
| 116 kFwd, kCaseSensitive, &ordinal)); |
| 167 EXPECT_EQ(1, ordinal); | 117 EXPECT_EQ(1, ordinal); |
| 168 | 118 |
| 169 // Try non-Latin characters ('Hreggvidur' with 'eth' for 'd' in left frame). | 119 // Try non-Latin characters ('Hreggvidur' with 'eth' for 'd' in left frame). |
| 170 EXPECT_EQ(1, FindInPage(L"Hreggvi\u00F0ur", FWD, IGNORE_CASE, &ordinal)); | 120 EXPECT_EQ(1, ui_test_utils::FindInPage(tab, L"Hreggvi\u00F0ur", |
| 121 kFwd, kIgnoreCase, &ordinal)); |
| 171 EXPECT_EQ(1, ordinal); | 122 EXPECT_EQ(1, ordinal); |
| 172 EXPECT_EQ(1, FindInPage(L"Hreggvi\u00F0ur", FWD, CASE_SENSITIVE, &ordinal)); | 123 EXPECT_EQ(1, ui_test_utils::FindInPage(tab, L"Hreggvi\u00F0ur", |
| 124 kFwd, kCaseSensitive, &ordinal)); |
| 173 EXPECT_EQ(1, ordinal); | 125 EXPECT_EQ(1, ordinal); |
| 174 EXPECT_EQ(0, FindInPage(L"hreggvi\u00F0ur", FWD, CASE_SENSITIVE, &ordinal)); | 126 EXPECT_EQ(0, ui_test_utils::FindInPage(tab, L"hreggvi\u00F0ur", |
| 127 kFwd, kCaseSensitive, &ordinal)); |
| 175 EXPECT_EQ(0, ordinal); | 128 EXPECT_EQ(0, ordinal); |
| 176 } | 129 } |
| 177 | 130 |
| 178 std::string FocusedOnPage(TabContents* tab_contents) { | 131 std::string FocusedOnPage(TabContents* tab_contents) { |
| 179 std::string result; | 132 std::string result; |
| 180 ui_test_utils::ExecuteJavaScriptAndExtractString( | 133 ui_test_utils::ExecuteJavaScriptAndExtractString( |
| 181 tab_contents->render_view_host(), | 134 tab_contents->render_view_host(), |
| 182 L"", | 135 L"", |
| 183 L"window.domAutomationController.send(getFocusedElement());", | 136 L"window.domAutomationController.send(getFocusedElement());", |
| 184 &result); | 137 &result); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 196 ui_test_utils::NavigateToURL(browser(), url); | 149 ui_test_utils::NavigateToURL(browser(), url); |
| 197 | 150 |
| 198 TabContents* tab_contents = browser()->GetSelectedTabContents(); | 151 TabContents* tab_contents = browser()->GetSelectedTabContents(); |
| 199 ASSERT_TRUE(NULL != tab_contents); | 152 ASSERT_TRUE(NULL != tab_contents); |
| 200 | 153 |
| 201 // Verify that nothing has focus. | 154 // Verify that nothing has focus. |
| 202 ASSERT_STREQ("{nothing focused}", FocusedOnPage(tab_contents).c_str()); | 155 ASSERT_STREQ("{nothing focused}", FocusedOnPage(tab_contents).c_str()); |
| 203 | 156 |
| 204 // Search for a text that exists within a link on the page. | 157 // Search for a text that exists within a link on the page. |
| 205 int ordinal = 0; | 158 int ordinal = 0; |
| 206 EXPECT_EQ(1, FindInPage(L"nk", FWD, IGNORE_CASE, &ordinal)); | 159 EXPECT_EQ(1, ui_test_utils::FindInPage(tab_contents, L"nk", |
| 160 kFwd, kIgnoreCase, &ordinal)); |
| 207 EXPECT_EQ(1, ordinal); | 161 EXPECT_EQ(1, ordinal); |
| 208 | 162 |
| 209 // End the find session, which should set focus to the link. | 163 // End the find session, which should set focus to the link. |
| 210 tab_contents->StopFinding(false); | 164 tab_contents->StopFinding(false); |
| 211 | 165 |
| 212 // Verify that the link is focused. | 166 // Verify that the link is focused. |
| 213 EXPECT_STREQ("link1", FocusedOnPage(tab_contents).c_str()); | 167 EXPECT_STREQ("link1", FocusedOnPage(tab_contents).c_str()); |
| 214 | 168 |
| 215 // Search for a text that exists within a link on the page. | 169 // Search for a text that exists within a link on the page. |
| 216 EXPECT_EQ(1, FindInPage(L"Google", FWD, IGNORE_CASE, &ordinal)); | 170 EXPECT_EQ(1, ui_test_utils::FindInPage(tab_contents, L"Google", |
| 171 kFwd, kIgnoreCase, &ordinal)); |
| 217 EXPECT_EQ(1, ordinal); | 172 EXPECT_EQ(1, ordinal); |
| 218 | 173 |
| 219 // Move the selection to link 1, after searching. | 174 // Move the selection to link 1, after searching. |
| 220 std::string result; | 175 std::string result; |
| 221 ui_test_utils::ExecuteJavaScriptAndExtractString( | 176 ui_test_utils::ExecuteJavaScriptAndExtractString( |
| 222 tab_contents->render_view_host(), | 177 tab_contents->render_view_host(), |
| 223 L"", | 178 L"", |
| 224 L"window.domAutomationController.send(selectLink1());", | 179 L"window.domAutomationController.send(selectLink1());", |
| 225 &result); | 180 &result); |
| 226 | 181 |
| 227 // End the find session. | 182 // End the find session. |
| 228 tab_contents->StopFinding(false); | 183 tab_contents->StopFinding(false); |
| 229 | 184 |
| 230 // Verify that link2 is not focused. | 185 // Verify that link2 is not focused. |
| 231 EXPECT_STREQ("", FocusedOnPage(tab_contents).c_str()); | 186 EXPECT_STREQ("", FocusedOnPage(tab_contents).c_str()); |
| 232 } | 187 } |
| 233 | 188 |
| 234 // This test loads a single-frame page and makes sure the ordinal returned makes | 189 // This test loads a single-frame page and makes sure the ordinal returned makes |
| 235 // sense as we FindNext over all the items. | 190 // sense as we FindNext over all the items. |
| 236 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageOrdinal) { | 191 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageOrdinal) { |
| 237 HTTPTestServer* server = StartHTTPServer(); | 192 HTTPTestServer* server = StartHTTPServer(); |
| 238 | 193 |
| 239 // First we navigate to our page. | 194 // First we navigate to our page. |
| 240 GURL url = server->TestServerPageW(kFrameData); | 195 GURL url = server->TestServerPageW(kFrameData); |
| 241 ui_test_utils::NavigateToURL(browser(), url); | 196 ui_test_utils::NavigateToURL(browser(), url); |
| 242 | 197 |
| 243 // Search for 'o', which should make the first item active and return | 198 // Search for 'o', which should make the first item active and return |
| 244 // '1 in 3' (1st ordinal of a total of 3 matches). | 199 // '1 in 3' (1st ordinal of a total of 3 matches). |
| 200 TabContents* tab = browser()->GetSelectedTabContents(); |
| 245 int ordinal = 0; | 201 int ordinal = 0; |
| 246 EXPECT_EQ(3, FindInPage(L"o", FWD, IGNORE_CASE, &ordinal)); | 202 EXPECT_EQ(3, ui_test_utils::FindInPage(tab, L"o", |
| 203 kFwd, kIgnoreCase, &ordinal)); |
| 247 EXPECT_EQ(1, ordinal); | 204 EXPECT_EQ(1, ordinal); |
| 248 EXPECT_EQ(3, FindInPage(L"o", FWD, IGNORE_CASE, &ordinal)); | 205 EXPECT_EQ(3, ui_test_utils::FindInPage(tab, L"o", |
| 206 kFwd, kIgnoreCase, &ordinal)); |
| 249 EXPECT_EQ(2, ordinal); | 207 EXPECT_EQ(2, ordinal); |
| 250 EXPECT_EQ(3, FindInPage(L"o", FWD, IGNORE_CASE, &ordinal)); | 208 EXPECT_EQ(3, ui_test_utils::FindInPage(tab, L"o", |
| 209 kFwd, kIgnoreCase, &ordinal)); |
| 251 EXPECT_EQ(3, ordinal); | 210 EXPECT_EQ(3, ordinal); |
| 252 // Go back one match. | 211 // Go back one match. |
| 253 EXPECT_EQ(3, FindInPage(L"o", BACK, IGNORE_CASE, &ordinal)); | 212 EXPECT_EQ(3, ui_test_utils::FindInPage(tab, L"o", |
| 213 kBack, kIgnoreCase, &ordinal)); |
| 254 EXPECT_EQ(2, ordinal); | 214 EXPECT_EQ(2, ordinal); |
| 255 EXPECT_EQ(3, FindInPage(L"o", FWD, IGNORE_CASE, &ordinal)); | 215 EXPECT_EQ(3, ui_test_utils::FindInPage(tab, L"o", |
| 216 kFwd, kIgnoreCase, &ordinal)); |
| 256 EXPECT_EQ(3, ordinal); | 217 EXPECT_EQ(3, ordinal); |
| 257 // This should wrap to the top. | 218 // This should wrap to the top. |
| 258 EXPECT_EQ(3, FindInPage(L"o", FWD, IGNORE_CASE, &ordinal)); | 219 EXPECT_EQ(3, ui_test_utils::FindInPage(tab, L"o", |
| 220 kFwd, kIgnoreCase, &ordinal)); |
| 259 EXPECT_EQ(1, ordinal); | 221 EXPECT_EQ(1, ordinal); |
| 260 // This should go back to the end. | 222 // This should go back to the end. |
| 261 EXPECT_EQ(3, FindInPage(L"o", BACK, IGNORE_CASE, &ordinal)); | 223 EXPECT_EQ(3, ui_test_utils::FindInPage(tab, L"o", |
| 224 kBack, kIgnoreCase, &ordinal)); |
| 262 EXPECT_EQ(3, ordinal); | 225 EXPECT_EQ(3, ordinal); |
| 263 } | 226 } |
| 264 | 227 |
| 265 // This test loads a page with frames and makes sure the ordinal returned makes | 228 // This test loads a page with frames and makes sure the ordinal returned makes |
| 266 // sense. | 229 // sense. |
| 267 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageMultiFramesOrdinal) { | 230 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageMultiFramesOrdinal) { |
| 268 HTTPTestServer* server = StartHTTPServer(); | 231 HTTPTestServer* server = StartHTTPServer(); |
| 269 | 232 |
| 270 // First we navigate to our page. | 233 // First we navigate to our page. |
| 271 GURL url = server->TestServerPageW(kFramePage); | 234 GURL url = server->TestServerPageW(kFramePage); |
| 272 ui_test_utils::NavigateToURL(browser(), url); | 235 ui_test_utils::NavigateToURL(browser(), url); |
| 273 | 236 |
| 274 // Search for 'a', which should make the first item active and return | 237 // Search for 'a', which should make the first item active and return |
| 275 // '1 in 7' (1st ordinal of a total of 7 matches). | 238 // '1 in 7' (1st ordinal of a total of 7 matches). |
| 239 TabContents* tab = browser()->GetSelectedTabContents(); |
| 276 int ordinal = 0; | 240 int ordinal = 0; |
| 277 EXPECT_EQ(7, FindInPage(L"a", FWD, IGNORE_CASE, &ordinal)); | 241 EXPECT_EQ(7, |
| 242 ui_test_utils::FindInPage(tab, L"a", kFwd, kIgnoreCase, &ordinal)); |
| 278 EXPECT_EQ(1, ordinal); | 243 EXPECT_EQ(1, ordinal); |
| 279 EXPECT_EQ(7, FindInPage(L"a", FWD, IGNORE_CASE, &ordinal)); | 244 EXPECT_EQ(7, |
| 245 ui_test_utils::FindInPage(tab, L"a", kFwd, kIgnoreCase, &ordinal)); |
| 280 EXPECT_EQ(2, ordinal); | 246 EXPECT_EQ(2, ordinal); |
| 281 EXPECT_EQ(7, FindInPage(L"a", FWD, IGNORE_CASE, &ordinal)); | 247 EXPECT_EQ(7, |
| 248 ui_test_utils::FindInPage(tab, L"a", kFwd, kIgnoreCase, &ordinal)); |
| 282 EXPECT_EQ(3, ordinal); | 249 EXPECT_EQ(3, ordinal); |
| 283 EXPECT_EQ(7, FindInPage(L"a", FWD, IGNORE_CASE, &ordinal)); | 250 EXPECT_EQ(7, |
| 251 ui_test_utils::FindInPage(tab, L"a", kFwd, kIgnoreCase, &ordinal)); |
| 284 EXPECT_EQ(4, ordinal); | 252 EXPECT_EQ(4, ordinal); |
| 285 // Go back one, which should go back one frame. | 253 // Go back one, which should go back one frame. |
| 286 EXPECT_EQ(7, FindInPage(L"a", BACK, IGNORE_CASE, &ordinal)); | 254 EXPECT_EQ(7, |
| 255 ui_test_utils::FindInPage(tab, L"a", kBack, kIgnoreCase, &ordinal)); |
| 287 EXPECT_EQ(3, ordinal); | 256 EXPECT_EQ(3, ordinal); |
| 288 EXPECT_EQ(7, FindInPage(L"a", FWD, IGNORE_CASE, &ordinal)); | 257 EXPECT_EQ(7, |
| 258 ui_test_utils::FindInPage(tab, L"a", kFwd, kIgnoreCase, &ordinal)); |
| 289 EXPECT_EQ(4, ordinal); | 259 EXPECT_EQ(4, ordinal); |
| 290 EXPECT_EQ(7, FindInPage(L"a", FWD, IGNORE_CASE, &ordinal)); | 260 EXPECT_EQ(7, |
| 261 ui_test_utils::FindInPage(tab, L"a", kFwd, kIgnoreCase, &ordinal)); |
| 291 EXPECT_EQ(5, ordinal); | 262 EXPECT_EQ(5, ordinal); |
| 292 EXPECT_EQ(7, FindInPage(L"a", FWD, IGNORE_CASE, &ordinal)); | 263 EXPECT_EQ(7, |
| 264 ui_test_utils::FindInPage(tab, L"a", kFwd, kIgnoreCase, &ordinal)); |
| 293 EXPECT_EQ(6, ordinal); | 265 EXPECT_EQ(6, ordinal); |
| 294 EXPECT_EQ(7, FindInPage(L"a", FWD, IGNORE_CASE, &ordinal)); | 266 EXPECT_EQ(7, |
| 267 ui_test_utils::FindInPage(tab, L"a", kFwd, kIgnoreCase, &ordinal)); |
| 295 EXPECT_EQ(7, ordinal); | 268 EXPECT_EQ(7, ordinal); |
| 296 // Now we should wrap back to frame 1. | 269 // Now we should wrap back to frame 1. |
| 297 EXPECT_EQ(7, FindInPage(L"a", FWD, IGNORE_CASE, &ordinal)); | 270 EXPECT_EQ(7, |
| 271 ui_test_utils::FindInPage(tab, L"a", kFwd, kIgnoreCase, &ordinal)); |
| 298 EXPECT_EQ(1, ordinal); | 272 EXPECT_EQ(1, ordinal); |
| 299 // Now we should wrap back to frame last frame. | 273 // Now we should wrap back to frame last frame. |
| 300 EXPECT_EQ(7, FindInPage(L"a", BACK, IGNORE_CASE, &ordinal)); | 274 EXPECT_EQ(7, |
| 275 ui_test_utils::FindInPage(tab, L"a", kBack, kIgnoreCase, &ordinal)); |
| 301 EXPECT_EQ(7, ordinal); | 276 EXPECT_EQ(7, ordinal); |
| 302 } | 277 } |
| 303 | 278 |
| 304 // We could get ordinals out of whack when restarting search in subframes. | 279 // We could get ordinals out of whack when restarting search in subframes. |
| 305 // See http://crbug.com/5132 | 280 // See http://crbug.com/5132 |
| 306 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPage_Issue5132) { | 281 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPage_Issue5132) { |
| 307 HTTPTestServer* server = StartHTTPServer(); | 282 HTTPTestServer* server = StartHTTPServer(); |
| 308 | 283 |
| 309 // First we navigate to our page. | 284 // First we navigate to our page. |
| 310 GURL url = server->TestServerPageW(kFramePage); | 285 GURL url = server->TestServerPageW(kFramePage); |
| 311 ui_test_utils::NavigateToURL(browser(), url); | 286 ui_test_utils::NavigateToURL(browser(), url); |
| 312 | 287 |
| 313 // Search for 'goa' three times (6 matches on page). | 288 // Search for 'goa' three times (6 matches on page). |
| 314 int ordinal = 0; | 289 int ordinal = 0; |
| 315 EXPECT_EQ(6, FindInPage(L"goa", FWD, IGNORE_CASE, &ordinal)); | 290 TabContents* tab = browser()->GetSelectedTabContents(); |
| 291 EXPECT_EQ(6, ui_test_utils::FindInPage(tab, L"goa", |
| 292 kFwd, kIgnoreCase, &ordinal)); |
| 316 EXPECT_EQ(1, ordinal); | 293 EXPECT_EQ(1, ordinal); |
| 317 EXPECT_EQ(6, FindInPage(L"goa", FWD, IGNORE_CASE, &ordinal)); | 294 EXPECT_EQ(6, ui_test_utils::FindInPage(tab, L"goa", |
| 295 kFwd, kIgnoreCase, &ordinal)); |
| 318 EXPECT_EQ(2, ordinal); | 296 EXPECT_EQ(2, ordinal); |
| 319 EXPECT_EQ(6, FindInPage(L"goa", FWD, IGNORE_CASE, &ordinal)); | 297 EXPECT_EQ(6, ui_test_utils::FindInPage(tab, L"goa", |
| 298 kFwd, kIgnoreCase, &ordinal)); |
| 320 EXPECT_EQ(3, ordinal); | 299 EXPECT_EQ(3, ordinal); |
| 321 // Add space to search (should result in no matches). | 300 // Add space to search (should result in no matches). |
| 322 EXPECT_EQ(0, FindInPage(L"goa ", FWD, IGNORE_CASE, &ordinal)); | 301 EXPECT_EQ(0, ui_test_utils::FindInPage(tab, L"goa ", |
| 302 kFwd, kIgnoreCase, &ordinal)); |
| 323 EXPECT_EQ(0, ordinal); | 303 EXPECT_EQ(0, ordinal); |
| 324 // Remove the space, should be back to '3 out of 6') | 304 // Remove the space, should be back to '3 out of 6') |
| 325 EXPECT_EQ(6, FindInPage(L"goa", FWD, IGNORE_CASE, &ordinal)); | 305 EXPECT_EQ(6, ui_test_utils::FindInPage(tab, L"goa", |
| 306 kFwd, kIgnoreCase, &ordinal)); |
| 326 EXPECT_EQ(3, ordinal); | 307 EXPECT_EQ(3, ordinal); |
| 327 } | 308 } |
| 328 | 309 |
| 329 // Load a page with no selectable text and make sure we don't crash. | 310 // Load a page with no selectable text and make sure we don't crash. |
| 330 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindUnSelectableText) { | 311 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindUnSelectableText) { |
| 331 HTTPTestServer* server = StartHTTPServer(); | 312 HTTPTestServer* server = StartHTTPServer(); |
| 332 | 313 |
| 333 // First we navigate to our page. | 314 // First we navigate to our page. |
| 334 GURL url = server->TestServerPageW(kUserSelectPage); | 315 GURL url = server->TestServerPageW(kUserSelectPage); |
| 335 ui_test_utils::NavigateToURL(browser(), url); | 316 ui_test_utils::NavigateToURL(browser(), url); |
| 336 | 317 |
| 337 int ordinal = 0; | 318 int ordinal = 0; |
| 338 EXPECT_EQ(0, FindInPage(L"text", FWD, IGNORE_CASE, &ordinal)); | 319 TabContents* tab = browser()->GetSelectedTabContents(); |
| 320 EXPECT_EQ(0, ui_test_utils::FindInPage(tab, L"text", |
| 321 kFwd, kIgnoreCase, &ordinal)); |
| 339 EXPECT_EQ(-1, ordinal); // Nothing is selected. | 322 EXPECT_EQ(-1, ordinal); // Nothing is selected. |
| 340 EXPECT_EQ(0, FindInPage(L"Non-existing string", FWD, IGNORE_CASE, &ordinal)); | 323 EXPECT_EQ(0, ui_test_utils::FindInPage(tab, L"Non-existing string", |
| 324 kFwd, kIgnoreCase, &ordinal)); |
| 341 EXPECT_EQ(0, ordinal); | 325 EXPECT_EQ(0, ordinal); |
| 342 } | 326 } |
| 343 | 327 |
| 344 // Try to reproduce the crash seen in issue 1341577. | 328 // Try to reproduce the crash seen in issue 1341577. |
| 345 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindCrash_Issue1341577) { | 329 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindCrash_Issue1341577) { |
| 346 HTTPTestServer* server = StartHTTPServer(); | 330 HTTPTestServer* server = StartHTTPServer(); |
| 347 | 331 |
| 348 // First we navigate to our page. | 332 // First we navigate to our page. |
| 349 GURL url = server->TestServerPageW(kCrashPage); | 333 GURL url = server->TestServerPageW(kCrashPage); |
| 350 ui_test_utils::NavigateToURL(browser(), url); | 334 ui_test_utils::NavigateToURL(browser(), url); |
| 351 | 335 |
| 352 // This would crash the tab. These must be the first two find requests issued | 336 // This would crash the tab. These must be the first two find requests issued |
| 353 // against the frame, otherwise an active frame pointer is set and it wont | 337 // against the frame, otherwise an active frame pointer is set and it wont |
| 354 // produce the crash. | 338 // produce the crash. |
| 355 // We used to check the return value and |ordinal|. With ICU 4.2, FiP does | 339 // We used to check the return value and |ordinal|. With ICU 4.2, FiP does |
| 356 // not find a stand-alone dependent vowel sign of Indic scripts. So, the | 340 // not find a stand-alone dependent vowel sign of Indic scripts. So, the |
| 357 // exptected values are all 0. To make this test pass regardless of | 341 // exptected values are all 0. To make this test pass regardless of |
| 358 // ICU version, we just call FiP and see if there's any crash. | 342 // ICU version, we just call FiP and see if there's any crash. |
| 359 // TODO(jungshik): According to a native Malayalam speaker, it's ok not | 343 // TODO(jungshik): According to a native Malayalam speaker, it's ok not |
| 360 // to find U+0D4C. Still need to investigate further this issue. | 344 // to find U+0D4C. Still need to investigate further this issue. |
| 361 int ordinal = 0; | 345 int ordinal = 0; |
| 362 FindInPage(L"\u0D4C", FWD, IGNORE_CASE, &ordinal); | 346 TabContents* tab = browser()->GetSelectedTabContents(); |
| 363 FindInPage(L"\u0D4C", FWD, IGNORE_CASE, &ordinal); | 347 ui_test_utils::FindInPage(tab, L"\u0D4C", kFwd, kIgnoreCase, &ordinal); |
| 348 ui_test_utils::FindInPage(tab, L"\u0D4C", kFwd, kIgnoreCase, &ordinal); |
| 364 | 349 |
| 365 // This should work fine. | 350 // This should work fine. |
| 366 EXPECT_EQ(1, FindInPage(L"\u0D24\u0D46", FWD, IGNORE_CASE, &ordinal)); | 351 EXPECT_EQ(1, ui_test_utils::FindInPage(tab, L"\u0D24\u0D46", |
| 352 kFwd, kIgnoreCase, &ordinal)); |
| 367 EXPECT_EQ(1, ordinal); | 353 EXPECT_EQ(1, ordinal); |
| 368 EXPECT_EQ(0, FindInPage(L"nostring", FWD, IGNORE_CASE, &ordinal)); | 354 EXPECT_EQ(0, ui_test_utils::FindInPage(tab, L"nostring", |
| 355 kFwd, kIgnoreCase, &ordinal)); |
| 369 EXPECT_EQ(0, ordinal); | 356 EXPECT_EQ(0, ordinal); |
| 370 } | 357 } |
| 371 | 358 |
| 372 // Try to reproduce the crash seen in http://crbug.com/14491, where an assert | 359 // Try to reproduce the crash seen in http://crbug.com/14491, where an assert |
| 373 // hits in the BitStack size comparison in WebKit. | 360 // hits in the BitStack size comparison in WebKit. |
| 374 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindCrash_Issue14491) { | 361 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindCrash_Issue14491) { |
| 375 HTTPTestServer* server = StartHTTPServer(); | 362 HTTPTestServer* server = StartHTTPServer(); |
| 376 | 363 |
| 377 // First we navigate to our page. | 364 // First we navigate to our page. |
| 378 GURL url = server->TestServerPageW(kBitstackCrash); | 365 GURL url = server->TestServerPageW(kBitstackCrash); |
| 379 ui_test_utils::NavigateToURL(browser(), url); | 366 ui_test_utils::NavigateToURL(browser(), url); |
| 380 | 367 |
| 381 // This used to crash the tab. | 368 // This used to crash the tab. |
| 382 int ordinal = 0; | 369 int ordinal = 0; |
| 383 EXPECT_EQ(0, FindInPage(L"s", FWD, IGNORE_CASE, &ordinal)); | 370 EXPECT_EQ(0, ui_test_utils::FindInPage(browser()->GetSelectedTabContents(), |
| 371 L"s", kFwd, kIgnoreCase, &ordinal)); |
| 384 EXPECT_EQ(0, ordinal); | 372 EXPECT_EQ(0, ordinal); |
| 385 } | 373 } |
| 386 | 374 |
| 387 // Test to make sure Find does the right thing when restarting from a timeout. | 375 // Test to make sure Find does the right thing when restarting from a timeout. |
| 388 // We used to have a problem where we'd stop finding matches when all of the | 376 // We used to have a problem where we'd stop finding matches when all of the |
| 389 // following conditions were true: | 377 // following conditions were true: |
| 390 // 1) The page has a lot of text to search. | 378 // 1) The page has a lot of text to search. |
| 391 // 2) The page contains more than one match. | 379 // 2) The page contains more than one match. |
| 392 // 3) It takes longer than the time-slice given to each Find operation (100 | 380 // 3) It takes longer than the time-slice given to each Find operation (100 |
| 393 // ms) to find one or more of those matches (so Find times out and has to try | 381 // ms) to find one or more of those matches (so Find times out and has to try |
| 394 // again from where it left off). | 382 // again from where it left off). |
| 395 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindRestarts_Issue1155639) { | 383 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindRestarts_Issue1155639) { |
| 396 HTTPTestServer* server = StartHTTPServer(); | 384 HTTPTestServer* server = StartHTTPServer(); |
| 397 | 385 |
| 398 // First we navigate to our page. | 386 // First we navigate to our page. |
| 399 GURL url = server->TestServerPageW(kTooFewMatchesPage); | 387 GURL url = server->TestServerPageW(kTooFewMatchesPage); |
| 400 ui_test_utils::NavigateToURL(browser(), url); | 388 ui_test_utils::NavigateToURL(browser(), url); |
| 401 | 389 |
| 402 // This string appears 5 times at the bottom of a long page. If Find restarts | 390 // This string appears 5 times at the bottom of a long page. If Find restarts |
| 403 // properly after a timeout, it will find 5 matches, not just 1. | 391 // properly after a timeout, it will find 5 matches, not just 1. |
| 404 int ordinal = 0; | 392 int ordinal = 0; |
| 405 EXPECT_EQ(5, FindInPage(L"008.xml", FWD, IGNORE_CASE, &ordinal)); | 393 EXPECT_EQ(5, ui_test_utils::FindInPage(browser()->GetSelectedTabContents(), |
| 394 L"008.xml", |
| 395 kFwd, kIgnoreCase, &ordinal)); |
| 406 EXPECT_EQ(1, ordinal); | 396 EXPECT_EQ(1, ordinal); |
| 407 } | 397 } |
| 408 | 398 |
| 409 // This tests bug 11761: FindInPage terminates search prematurely. | 399 // This tests bug 11761: FindInPage terminates search prematurely. |
| 410 // This test will be enabled once the bug is fixed. | 400 // This test will be enabled once the bug is fixed. |
| 411 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, | 401 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| 412 DISABLED_FindInPagePrematureEnd) { | 402 DISABLED_FindInPagePrematureEnd) { |
| 413 HTTPTestServer* server = StartHTTPServer(); | 403 HTTPTestServer* server = StartHTTPServer(); |
| 414 | 404 |
| 415 // First we navigate to our special focus tracking page. | 405 // First we navigate to our special focus tracking page. |
| 416 GURL url = server->TestServerPageW(kPrematureEnd); | 406 GURL url = server->TestServerPageW(kPrematureEnd); |
| 417 ui_test_utils::NavigateToURL(browser(), url); | 407 ui_test_utils::NavigateToURL(browser(), url); |
| 418 | 408 |
| 419 TabContents* tab_contents = browser()->GetSelectedTabContents(); | 409 TabContents* tab_contents = browser()->GetSelectedTabContents(); |
| 420 ASSERT_TRUE(NULL != tab_contents); | 410 ASSERT_TRUE(NULL != tab_contents); |
| 421 | 411 |
| 422 // Search for a text that exists within a link on the page. | 412 // Search for a text that exists within a link on the page. |
| 423 int ordinal = 0; | 413 int ordinal = 0; |
| 424 EXPECT_EQ(2, FindInPage(L"html ", FWD, IGNORE_CASE, &ordinal)); | 414 EXPECT_EQ(2, ui_test_utils::FindInPage(tab_contents, L"html ", |
| 415 kFwd, kIgnoreCase, &ordinal)); |
| 425 EXPECT_EQ(1, ordinal); | 416 EXPECT_EQ(1, ordinal); |
| 426 } | 417 } |
| 427 | 418 |
| 428 // Make sure Find box disappears on Navigate but not on Refresh. | 419 // Make sure Find box disappears on Navigate but not on Refresh. |
| 429 // Flaky, see http://crbug.com/16447. | 420 // Flaky, see http://crbug.com/16447. |
| 430 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, | 421 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| 431 DISABLED_FindDisappearOnNavigate) { | 422 DISABLED_FindDisappearOnNavigate) { |
| 432 HTTPTestServer* server = StartHTTPServer(); | 423 HTTPTestServer* server = StartHTTPServer(); |
| 433 | 424 |
| 434 // First we navigate to our special focus tracking page. | 425 // First we navigate to our special focus tracking page. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 gfx::Point start_position; | 510 gfx::Point start_position; |
| 520 gfx::Point position; | 511 gfx::Point position; |
| 521 bool fully_visible = false; | 512 bool fully_visible = false; |
| 522 | 513 |
| 523 // Make sure it is open. | 514 // Make sure it is open. |
| 524 GetFindBarWindowInfo(&start_position, &fully_visible); | 515 GetFindBarWindowInfo(&start_position, &fully_visible); |
| 525 EXPECT_TRUE(fully_visible); | 516 EXPECT_TRUE(fully_visible); |
| 526 | 517 |
| 527 // Search for 'dream' which the Find box is obscuring. | 518 // Search for 'dream' which the Find box is obscuring. |
| 528 int ordinal = 0; | 519 int ordinal = 0; |
| 529 EXPECT_EQ(1, FindInPage(L"dream", FWD, IGNORE_CASE, &ordinal)); | 520 TabContents* tab = browser()->GetSelectedTabContents(); |
| 521 EXPECT_EQ(1, ui_test_utils::FindInPage(tab, L"dream", |
| 522 kFwd, kIgnoreCase, &ordinal)); |
| 530 EXPECT_EQ(1, ordinal); | 523 EXPECT_EQ(1, ordinal); |
| 531 | 524 |
| 532 // Make sure Find box has moved. | 525 // Make sure Find box has moved. |
| 533 GetFindBarWindowInfo(&position, &fully_visible); | 526 GetFindBarWindowInfo(&position, &fully_visible); |
| 534 EXPECT_EQ(start_position.y(), position.y()); | 527 EXPECT_EQ(start_position.y(), position.y()); |
| 535 EXPECT_NE(start_position.x(), position.x()); | 528 EXPECT_NE(start_position.x(), position.x()); |
| 536 EXPECT_TRUE(fully_visible); | 529 EXPECT_TRUE(fully_visible); |
| 537 | 530 |
| 538 // Search for 'Too much' which the Find box is not obscuring. | 531 // Search for 'Too much' which the Find box is not obscuring. |
| 539 EXPECT_EQ(1, FindInPage(L"Too much", FWD, IGNORE_CASE, &ordinal)); | 532 EXPECT_EQ(1, ui_test_utils::FindInPage(tab, L"Too much", |
| 533 kFwd, kIgnoreCase, &ordinal)); |
| 540 EXPECT_EQ(1, ordinal); | 534 EXPECT_EQ(1, ordinal); |
| 541 | 535 |
| 542 // Make sure Find box has moved back to its original location. | 536 // Make sure Find box has moved back to its original location. |
| 543 GetFindBarWindowInfo(&position, &fully_visible); | 537 GetFindBarWindowInfo(&position, &fully_visible); |
| 544 EXPECT_EQ(start_position, position); | 538 EXPECT_EQ(start_position, position); |
| 545 EXPECT_TRUE(fully_visible); | 539 EXPECT_TRUE(fully_visible); |
| 546 } | 540 } |
| 547 | 541 |
| 548 // Make sure F3 in a new tab works if Find has previous string to search for. | 542 // Make sure F3 in a new tab works if Find has previous string to search for. |
| 549 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, | 543 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| 550 FindNextInNewTabUsesPrepopulate) { | 544 FindNextInNewTabUsesPrepopulate) { |
| 551 HTTPTestServer* server = StartHTTPServer(); | 545 HTTPTestServer* server = StartHTTPServer(); |
| 552 | 546 |
| 553 // First we navigate to any page. | 547 // First we navigate to any page. |
| 554 GURL url = server->TestServerPageW(kSimplePage); | 548 GURL url = server->TestServerPageW(kSimplePage); |
| 555 ui_test_utils::NavigateToURL(browser(), url); | 549 ui_test_utils::NavigateToURL(browser(), url); |
| 556 | 550 |
| 557 // Search for 'no_match'. No matches should be found. | 551 // Search for 'no_match'. No matches should be found. |
| 558 int ordinal = 0; | 552 int ordinal = 0; |
| 559 EXPECT_EQ(0, FindInPage(L"no_match", FWD, IGNORE_CASE, &ordinal)); | 553 TabContents* tab = browser()->GetSelectedTabContents(); |
| 554 EXPECT_EQ(0, ui_test_utils::FindInPage(tab, L"no_match", |
| 555 kFwd, kIgnoreCase, &ordinal)); |
| 560 EXPECT_EQ(0, ordinal); | 556 EXPECT_EQ(0, ordinal); |
| 561 | 557 |
| 562 // Open another tab (tab B). | 558 // Open another tab (tab B). |
| 563 browser()->NewTab(); | 559 browser()->NewTab(); |
| 564 ui_test_utils::NavigateToURL(browser(), url); | 560 ui_test_utils::NavigateToURL(browser(), url); |
| 565 | 561 |
| 566 // Simulate what happens when you press F3 for FindNext. We should get a | 562 // Simulate what happens when you press F3 for FindNext. We should get a |
| 567 // response here (a hang means search was aborted). | 563 // response here (a hang means search was aborted). |
| 568 EXPECT_EQ(0, FindInPage(std::wstring(), FWD, IGNORE_CASE, &ordinal)); | 564 EXPECT_EQ(0, ui_test_utils::FindInPage(tab, std::wstring(), |
| 565 kFwd, kIgnoreCase, &ordinal)); |
| 569 EXPECT_EQ(0, ordinal); | 566 EXPECT_EQ(0, ordinal); |
| 570 | 567 |
| 571 // Open another tab (tab C). | 568 // Open another tab (tab C). |
| 572 browser()->NewTab(); | 569 browser()->NewTab(); |
| 573 ui_test_utils::NavigateToURL(browser(), url); | 570 ui_test_utils::NavigateToURL(browser(), url); |
| 574 | 571 |
| 575 // Simulate what happens when you press F3 for FindNext. We should get a | 572 // Simulate what happens when you press F3 for FindNext. We should get a |
| 576 // response here (a hang means search was aborted). | 573 // response here (a hang means search was aborted). |
| 577 EXPECT_EQ(0, FindInPage(std::wstring(), FWD, IGNORE_CASE, &ordinal)); | 574 EXPECT_EQ(0, ui_test_utils::FindInPage(tab, std::wstring(), |
| 575 kFwd, kIgnoreCase, &ordinal)); |
| 578 EXPECT_EQ(0, ordinal); | 576 EXPECT_EQ(0, ordinal); |
| 579 } | 577 } |
| 580 | 578 |
| 581 // Make sure Find box grabs the Esc accelerator and restores it again. | 579 // Make sure Find box grabs the Esc accelerator and restores it again. |
| 582 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, AcceleratorRestoring) { | 580 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, AcceleratorRestoring) { |
| 583 HTTPTestServer* server = StartHTTPServer(); | 581 HTTPTestServer* server = StartHTTPServer(); |
| 584 | 582 |
| 585 // First we navigate to any page. | 583 // First we navigate to any page. |
| 586 GURL url = server->TestServerPageW(kSimplePage); | 584 GURL url = server->TestServerPageW(kSimplePage); |
| 587 ui_test_utils::NavigateToURL(browser(), url); | 585 ui_test_utils::NavigateToURL(browser(), url); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 // backspace, but that's been proven flaky in the past, so we go straight to | 629 // backspace, but that's been proven flaky in the past, so we go straight to |
| 632 // tab_contents. | 630 // tab_contents. |
| 633 TabContents* tab_contents = browser()->GetSelectedTabContents(); | 631 TabContents* tab_contents = browser()->GetSelectedTabContents(); |
| 634 // Stop the (non-existing) find operation, and clear the selection (which | 632 // Stop the (non-existing) find operation, and clear the selection (which |
| 635 // signals the UI is still active). | 633 // signals the UI is still active). |
| 636 tab_contents->StopFinding(true); | 634 tab_contents->StopFinding(true); |
| 637 // Make sure the Find UI flag hasn't been cleared, it must be so that the UI | 635 // Make sure the Find UI flag hasn't been cleared, it must be so that the UI |
| 638 // still responds to browser window resizing. | 636 // still responds to browser window resizing. |
| 639 ASSERT_TRUE(tab_contents->find_ui_active()); | 637 ASSERT_TRUE(tab_contents->find_ui_active()); |
| 640 } | 638 } |
| OLD | NEW |