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

Unified Diff: chrome/browser/views/find_bar_win_unittest.cc

Issue 79024: Fix 10573: Dismissing FindInPage doesn't set focus to the link... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/browser_focus_uitest.cc ('k') | chrome/test/data/find_in_page/end_state.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/find_bar_win_unittest.cc
===================================================================
--- chrome/browser/views/find_bar_win_unittest.cc (revision 13860)
+++ chrome/browser/views/find_bar_win_unittest.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -19,6 +19,7 @@
const std::wstring kUserSelectPage = L"files/find_in_page/user-select.html";
const std::wstring kCrashPage = L"files/find_in_page/crash_1341577.html";
const std::wstring kTooFewMatchesPage = L"files/find_in_page/bug_1155639.html";
+const std::wstring kEndState = L"files/find_in_page/end_state.html";
class FindInPageNotificationObserver : public NotificationObserver {
public:
@@ -78,6 +79,11 @@
typedef enum FindInPageCase { IGNORE_CASE = 0, CASE_SENSITIVE = 1 };
class FindInPageControllerTest : public InProcessBrowserTest {
+ public:
+ FindInPageControllerTest() {
+ EnableDOMAutomation();
+ }
+
protected:
int FindInPage(const std::wstring& search_string,
FindInPageDirection forward,
@@ -98,7 +104,7 @@
}
};
-// This test loads a page with frames and starts FindInPage requests
+// This test loads a page with frames and starts FindInPage requests.
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageFrames) {
HTTPTestServer* server = StartHTTPServer();
@@ -141,3 +147,56 @@
EXPECT_EQ(1, FindInPage(L"Hreggvi\u00F0ur", FWD, CASE_SENSITIVE, false));
EXPECT_EQ(0, FindInPage(L"hreggvi\u00F0ur", FWD, CASE_SENSITIVE, false));
}
+
+std::string FocusedOnPage(WebContents* web_contents) {
+ ui_test_utils::JavaScriptRunner js_runner(
+ web_contents,
+ L"",
+ L"window.domAutomationController.send(getFocusedElement());");
+ return js_runner.Run();
+}
+
+// This tests the FindInPage end-state, in other words: what is focused when you
+// close the Find box (ie. if you find within a link the link should be
+// focused).
+// TODO(jcampan): This test needs to be enabled once Jay fixes the issues with
+// running two InProc browser tests that both start a web server (crashes).
+IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, DISABLED_FindInPageEndState) {
+ HTTPTestServer* server = StartHTTPServer();
+
+ // First we navigate to our special focus tracking page.
+ GURL url = server->TestServerPageW(kEndState);
+ ui_test_utils::NavigateToURL(browser(), url);
+
+ WebContents* web_contents =
+ browser()->GetSelectedTabContents()->AsWebContents();
+ ASSERT_TRUE(NULL != web_contents);
+
+ // Verify that nothing has focus.
+ ASSERT_STREQ("{nothing focused}", FocusedOnPage(web_contents).c_str());
+
+ // Search for a text that exists within a link on the page.
+ EXPECT_EQ(1, FindInPage(L"nk", FWD, IGNORE_CASE, false));
+
+ // End the find session, which should set focus to the link.
+ web_contents->StopFinding(false);
+
+ // Verify that the link is focused.
+ EXPECT_STREQ("link1", FocusedOnPage(web_contents).c_str());
+
+ // Search for a text that exists within a link on the page.
+ EXPECT_EQ(1, FindInPage(L"Google", FWD, IGNORE_CASE, false));
+
+ // Move the selection to link 1, after searching.
+ ui_test_utils::JavaScriptRunner js_runner(
+ web_contents,
+ L"",
+ L"window.domAutomationController.send(selectLink1());");
+ js_runner.Run();
+
+ // End the find session.
+ web_contents->StopFinding(false);
+
+ // Verify that link2 is not focused.
+ EXPECT_STREQ("", FocusedOnPage(web_contents).c_str());
+}
« no previous file with comments | « chrome/browser/browser_focus_uitest.cc ('k') | chrome/test/data/find_in_page/end_state.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698