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

Side by Side Diff: chrome/browser/views/find_bar_host_browsertest.cc

Issue 554041: Take 2: Disable the test (I accidentally modified the file before checking in... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 11 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 | « no previous file | no next file » | 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) 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 std::string FocusedOnPage(TabContents* tab_contents) { 148 std::string FocusedOnPage(TabContents* tab_contents) {
149 std::string result; 149 std::string result;
150 ui_test_utils::ExecuteJavaScriptAndExtractString( 150 ui_test_utils::ExecuteJavaScriptAndExtractString(
151 tab_contents->render_view_host(), 151 tab_contents->render_view_host(),
152 L"", 152 L"",
153 L"window.domAutomationController.send(getFocusedElement());", 153 L"window.domAutomationController.send(getFocusedElement());",
154 &result); 154 &result);
155 return result; 155 return result;
156 } 156 }
157 157
158 // This tests the FindInPage end-state, in other words: what is focused and 158 // This tests the FindInPage end-state, in other words: what is focused when you
159 // selected after you close the Find box. For example, if you find within a link 159 // close the Find box (ie. if you find within a link the link should be
160 // the link should be focused, but not selection highlighted. If you find simple 160 // focused).
161 // text, it should be highlighted when closing the Find box.
162 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageEndState) { 161 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageEndState) {
163 HTTPTestServer* server = StartHTTPServer(); 162 HTTPTestServer* server = StartHTTPServer();
164 163
165 // First we navigate to our special focus tracking page. 164 // First we navigate to our special focus tracking page.
166 GURL url = server->TestServerPageW(kEndState); 165 GURL url = server->TestServerPageW(kEndState);
167 ui_test_utils::NavigateToURL(browser(), url); 166 ui_test_utils::NavigateToURL(browser(), url);
168 167
169 TabContents* tab_contents = browser()->GetSelectedTabContents(); 168 TabContents* tab_contents = browser()->GetSelectedTabContents();
170 ASSERT_TRUE(NULL != tab_contents); 169 ASSERT_TRUE(NULL != tab_contents);
171 170
172 // Verify that nothing has focus. 171 // Verify that nothing has focus.
173 ASSERT_STREQ("{nothing focused}", FocusedOnPage(tab_contents).c_str()); 172 ASSERT_STREQ("{nothing focused}", FocusedOnPage(tab_contents).c_str());
174 173
175 // Search for a text that exists within a link on the page. 174 // Search for a text that exists within a link on the page.
176 int ordinal = 0; 175 int ordinal = 0;
177 EXPECT_EQ(1, FindInPageWchar(tab_contents, L"nk", 176 EXPECT_EQ(1, FindInPageWchar(tab_contents, L"nk",
178 kFwd, kIgnoreCase, &ordinal)); 177 kFwd, kIgnoreCase, &ordinal));
179 EXPECT_EQ(1, ordinal); 178 EXPECT_EQ(1, ordinal);
180 179
181 // End the find session, which should set focus to the link. 180 // End the find session, which should set focus to the link.
182 tab_contents->StopFinding(false); 181 tab_contents->StopFinding(false);
183 182
184 // Verify that the link is focused. 183 // Verify that the link is focused.
185 EXPECT_STREQ("link1", FocusedOnPage(tab_contents).c_str()); 184 EXPECT_STREQ("link1", FocusedOnPage(tab_contents).c_str());
186 185
187 // Make sure nothing is highlighted (don't want both focus highlighting and 186 // Search for a text that exists within a link on the page.
188 // selection highlighting at the same time).
189 std::string result;
190 ui_test_utils::ExecuteJavaScriptAndExtractString(
191 tab_contents->render_view_host(),
192 L"",
193 L"window.domAutomationController.send(window.getSelection().toString());",
194 &result);
195 EXPECT_STREQ("", result.c_str());
196
197 // Search for a text that exists within link2 on the page.
198 EXPECT_EQ(1, FindInPageWchar(tab_contents, L"Google", 187 EXPECT_EQ(1, FindInPageWchar(tab_contents, L"Google",
199 kFwd, kIgnoreCase, &ordinal)); 188 kFwd, kIgnoreCase, &ordinal));
200 EXPECT_EQ(1, ordinal); 189 EXPECT_EQ(1, ordinal);
201 190
202 // Move the selection to link 1, after searching. 191 // Move the selection to link 1, after searching.
192 std::string result;
203 ui_test_utils::ExecuteJavaScriptAndExtractString( 193 ui_test_utils::ExecuteJavaScriptAndExtractString(
204 tab_contents->render_view_host(), 194 tab_contents->render_view_host(),
205 L"", 195 L"",
206 L"window.domAutomationController.send(selectLink1());", 196 L"window.domAutomationController.send(selectLink1());",
207 &result); 197 &result);
208 198
209 // End the find session. 199 // End the find session.
210 tab_contents->StopFinding(false); 200 tab_contents->StopFinding(false);
211 201
212 // Verify that link2 is not focused. 202 // Verify that link2 is not focused.
213 EXPECT_STREQ("", FocusedOnPage(tab_contents).c_str()); 203 EXPECT_STREQ("", FocusedOnPage(tab_contents).c_str());
214
215 // Make sure link1 is still highlighted.
216 ui_test_utils::ExecuteJavaScriptAndExtractString(
217 tab_contents->render_view_host(),
218 L"",
219 L"window.domAutomationController.send(window.getSelection().toString());",
220 &result);
221 EXPECT_STREQ("link", result.c_str());
222
223 // Search for 'This'. Should have 1 match.
224 TabContents* tab = browser()->GetSelectedTabContents();
225 EXPECT_EQ(1, FindInPageWchar(tab, L"This", kFwd, kIgnoreCase, &ordinal));
226 EXPECT_EQ(1, ordinal);
227
228 // End the Find session, thereby making the word 'This' highlighted.
229 browser()->GetFindBarController()->EndFindSession();
230
231 // Make sure 'This' is now highlighted.
232 ui_test_utils::ExecuteJavaScriptAndExtractString(
233 tab->render_view_host(),
234 L"",
235 L"window.domAutomationController.send(window.getSelection().toString());",
236 &result);
237 EXPECT_STREQ("This", result.c_str());
238
239 // Search for something that doesn't exist (or at least not on that page).
240 EXPECT_EQ(0, FindInPageWchar(tab, L"aliens", kFwd, kIgnoreCase, &ordinal));
241 EXPECT_EQ(0, ordinal);
242
243 // End the Find session.
244 browser()->GetFindBarController()->EndFindSession();
245
246 // Make sure nothing is highlighted.
247 ui_test_utils::ExecuteJavaScriptAndExtractString(
248 tab->render_view_host(),
249 L"",
250 L"window.domAutomationController.send(window.getSelection().toString());",
251 &result);
252 EXPECT_STREQ("", result.c_str());
253 } 204 }
254 205
255 // This test loads a single-frame page and makes sure the ordinal returned makes 206 // This test loads a single-frame page and makes sure the ordinal returned makes
256 // sense as we FindNext over all the items. 207 // sense as we FindNext over all the items.
257 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageOrdinal) { 208 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageOrdinal) {
258 HTTPTestServer* server = StartHTTPServer(); 209 HTTPTestServer* server = StartHTTPServer();
259 210
260 // First we navigate to our page. 211 // First we navigate to our page.
261 GURL url = server->TestServerPageW(kFrameData); 212 GURL url = server->TestServerPageW(kFrameData);
262 ui_test_utils::NavigateToURL(browser(), url); 213 ui_test_utils::NavigateToURL(browser(), url);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 467
517 // Search for a text that exists within a link on the page. 468 // Search for a text that exists within a link on the page.
518 int ordinal = 0; 469 int ordinal = 0;
519 EXPECT_EQ(2, FindInPageWchar(tab_contents, L"html ", 470 EXPECT_EQ(2, FindInPageWchar(tab_contents, L"html ",
520 kFwd, kIgnoreCase, &ordinal)); 471 kFwd, kIgnoreCase, &ordinal));
521 EXPECT_EQ(1, ordinal); 472 EXPECT_EQ(1, ordinal);
522 } 473 }
523 474
524 // Make sure Find box disappears on Navigate but not on Refresh. 475 // Make sure Find box disappears on Navigate but not on Refresh.
525 #if defined(OS_LINUX) && defined(TOOLKIT_VIEWS) 476 #if defined(OS_LINUX) && defined(TOOLKIT_VIEWS)
526 // The last EXPECT_FALSE(fully_visible) is flaky (especially on 477 // The last EXPECT_FALSE(fully_visible) is failing all the time on
527 // 64bit build.). See bug http://crbug.com/28629. 478 // the linux_views bot. See bug: http://crbug.com/28629.
528 #define FindDisappearOnNavigate FLAKY_FindDisappearOnNavigate 479 #define FindDisappearOnNavigate DISABLED_FindDisappearOnNavigate
529 #endif 480 #endif
530 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) { 481 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) {
531 HTTPTestServer* server = StartHTTPServer(); 482 HTTPTestServer* server = StartHTTPServer();
532 483
533 // First we navigate to our special focus tracking page. 484 // First we navigate to our special focus tracking page.
534 GURL url = server->TestServerPageW(kSimplePage); 485 GURL url = server->TestServerPageW(kSimplePage);
535 GURL url2 = server->TestServerPageW(kFramePage); 486 GURL url2 = server->TestServerPageW(kFramePage);
536 ui_test_utils::NavigateToURL(browser(), url); 487 ui_test_utils::NavigateToURL(browser(), url);
537 488
538 // Open the Find window with animations disabled. 489 // Open the Find window with animations disabled.
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 // Find "given". 787 // Find "given".
837 FindInPageWchar(tab2, L"given", kFwd, kIgnoreCase, &ordinal); 788 FindInPageWchar(tab2, L"given", kFwd, kIgnoreCase, &ordinal);
838 789
839 // Switch back to first tab. 790 // Switch back to first tab.
840 browser()->SelectTabContentsAt(0, false); 791 browser()->SelectTabContentsAt(0, false);
841 browser()->GetFindBarController()->EndFindSession(); 792 browser()->GetFindBarController()->EndFindSession();
842 // Simulate F3. 793 // Simulate F3.
843 ui_test_utils::FindInPage(tab1, string16(), kFwd, kIgnoreCase, &ordinal); 794 ui_test_utils::FindInPage(tab1, string16(), kFwd, kIgnoreCase, &ordinal);
844 EXPECT_EQ(tab1->find_text(), WideToUTF16(L"Default")); 795 EXPECT_EQ(tab1->find_text(), WideToUTF16(L"Default"));
845 } 796 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698