| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "chrome/browser/ui/browser_finder.h" | 6 #include "chrome/browser/ui/browser_finder.h" |
| 7 #include "chrome/browser/ui/find_bar/find_bar.h" | 7 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 8 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 8 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 9 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 9 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 11 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/in_process_browser_test.h" |
| 12 #include "chrome/test/base/interactive_test_utils.h" | 12 #include "chrome/test/base/interactive_test_utils.h" |
| 13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/test/browser_test_utils.h" | 15 #include "content/public/test/browser_test_utils.h" |
| 16 #include "net/test/embedded_test_server/embedded_test_server.h" | 16 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 17 | 17 |
| 18 using base::WideToUTF16; | 18 using base::WideToUTF16; |
| 19 using content::WebContents; | 19 using content::WebContents; |
| 20 using net::test_server::EmbeddedTestServer; | |
| 21 | 20 |
| 22 namespace { | 21 namespace { |
| 23 | 22 |
| 24 const char kEndState[] = "/find_in_page/end_state.html"; | 23 const char kEndState[] = "/find_in_page/end_state.html"; |
| 25 | 24 |
| 26 class FindInPageInteractiveTest : public InProcessBrowserTest { | 25 class FindInPageInteractiveTest : public InProcessBrowserTest { |
| 27 public: | 26 public: |
| 28 FindInPageInteractiveTest() { | 27 FindInPageInteractiveTest() { |
| 29 } | 28 } |
| 30 | 29 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 60 // This tests the FindInPage end-state, in other words: what is focused when you | 59 // This tests the FindInPage end-state, in other words: what is focused when you |
| 61 // close the Find box (ie. if you find within a link the link should be | 60 // close the Find box (ie. if you find within a link the link should be |
| 62 // focused). | 61 // focused). |
| 63 // Flaky on CrOS. | 62 // Flaky on CrOS. |
| 64 #if defined(OS_CHROMEOS) | 63 #if defined(OS_CHROMEOS) |
| 65 #define MAYBE_FindInPageEndState DISABLED_FindInPageEndState | 64 #define MAYBE_FindInPageEndState DISABLED_FindInPageEndState |
| 66 #else | 65 #else |
| 67 #define MAYBE_FindInPageEndState FindInPageEndState | 66 #define MAYBE_FindInPageEndState FindInPageEndState |
| 68 #endif | 67 #endif |
| 69 IN_PROC_BROWSER_TEST_F(FindInPageInteractiveTest, MAYBE_FindInPageEndState) { | 68 IN_PROC_BROWSER_TEST_F(FindInPageInteractiveTest, MAYBE_FindInPageEndState) { |
| 70 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 69 ASSERT_TRUE(embedded_test_server()->Start()); |
| 71 | 70 |
| 72 // Make sure Chrome is in the foreground, otherwise sending input | 71 // Make sure Chrome is in the foreground, otherwise sending input |
| 73 // won't do anything and the test will hang. | 72 // won't do anything and the test will hang. |
| 74 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 73 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 75 | 74 |
| 76 // First we navigate to our special focus tracking page. | 75 // First we navigate to our special focus tracking page. |
| 77 GURL url = embedded_test_server()->GetURL(kEndState); | 76 GURL url = embedded_test_server()->GetURL(kEndState); |
| 78 ui_test_utils::NavigateToURL(browser(), url); | 77 ui_test_utils::NavigateToURL(browser(), url); |
| 79 | 78 |
| 80 WebContents* web_contents = | 79 WebContents* web_contents = |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 "window.domAutomationController.send(selectLink1());", | 111 "window.domAutomationController.send(selectLink1());", |
| 113 &result)); | 112 &result)); |
| 114 | 113 |
| 115 // End the find session. | 114 // End the find session. |
| 116 find_tab_helper->StopFinding(FindBarController::kKeepSelectionOnPage); | 115 find_tab_helper->StopFinding(FindBarController::kKeepSelectionOnPage); |
| 117 | 116 |
| 118 // Verify that link2 is not focused. | 117 // Verify that link2 is not focused. |
| 119 ASSERT_TRUE(FocusedOnPage(web_contents, &result)); | 118 ASSERT_TRUE(FocusedOnPage(web_contents, &result)); |
| 120 EXPECT_STREQ("", result.c_str()); | 119 EXPECT_STREQ("", result.c_str()); |
| 121 } | 120 } |
| OLD | NEW |