| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/automation/ui_controls.h" | 7 #include "chrome/browser/automation/ui_controls.h" |
| 8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
| 9 #include "chrome/browser/browser_window.h" | 9 #include "chrome/browser/browser_window.h" |
| 10 #include "chrome/browser/find_bar_controller.h" | 10 #include "chrome/browser/find_bar_controller.h" |
| 11 #include "chrome/browser/tab_contents/tab_contents.h" | 11 #include "chrome/browser/tab_contents/tab_contents.h" |
| 12 #include "chrome/browser/views/find_bar_host.h" | 12 #include "chrome/browser/views/find_bar_host.h" |
| 13 #include "chrome/browser/views/frame/browser_view.h" | 13 #include "chrome/browser/views/frame/browser_view.h" |
| 14 #include "chrome/browser/view_ids.h" | 14 #include "chrome/browser/view_ids.h" |
| 15 #include "chrome/test/in_process_browser_test.h" | 15 #include "chrome/test/in_process_browser_test.h" |
| 16 #include "chrome/test/ui_test_utils.h" | 16 #include "chrome/test/ui_test_utils.h" |
| 17 #include "net/url_request/url_request_unittest.h" | 17 #include "net/url_request/url_request_unittest.h" |
| 18 #include "views/focus/focus_manager.h" | 18 #include "views/focus/focus_manager.h" |
| 19 #include "views/view.h" | 19 #include "views/view.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // The delay waited after sending an OS simulated event. | 23 // The delay waited after sending an OS simulated event. |
| 24 static const int kActionDelayMs = 500; | 24 static const int kActionDelayMs = 500; |
| 25 static const wchar_t kDocRoot[] = L"chrome/test/data"; | 25 static const wchar_t kDocRoot[] = L"chrome/test/data"; |
| 26 static const wchar_t kSimplePage[] = L"404_is_enough_for_us.html"; | 26 static const char kSimplePage[] = "404_is_enough_for_us.html"; |
| 27 | 27 |
| 28 class FindInPageTest : public InProcessBrowserTest { | 28 class FindInPageTest : public InProcessBrowserTest { |
| 29 public: | 29 public: |
| 30 FindInPageTest() { | 30 FindInPageTest() { |
| 31 set_show_window(true); | 31 set_show_window(true); |
| 32 FindBarHost::disable_animations_during_testing_ = true; | 32 FindBarHost::disable_animations_during_testing_ = true; |
| 33 } | 33 } |
| 34 | 34 |
| 35 void ClickOnView(ViewID view_id) { | 35 void ClickOnView(ViewID view_id) { |
| 36 BrowserWindow* browser_window = browser()->window(); | 36 BrowserWindow* browser_window = browser()->window(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } // namespace | 81 } // namespace |
| 82 | 82 |
| 83 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) { | 83 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) { |
| 84 scoped_refptr<HTTPTestServer> server = | 84 scoped_refptr<HTTPTestServer> server = |
| 85 HTTPTestServer::CreateServer(kDocRoot, NULL); | 85 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 86 ASSERT_TRUE(NULL != server.get()); | 86 ASSERT_TRUE(NULL != server.get()); |
| 87 | 87 |
| 88 // First we navigate to our test page (tab A). | 88 // First we navigate to our test page (tab A). |
| 89 GURL url = server->TestServerPageW(kSimplePage); | 89 GURL url = server->TestServerPage(kSimplePage); |
| 90 ui_test_utils::NavigateToURL(browser(), url); | 90 ui_test_utils::NavigateToURL(browser(), url); |
| 91 | 91 |
| 92 browser()->Find(); | 92 browser()->Find(); |
| 93 | 93 |
| 94 // Open another tab (tab B). | 94 // Open another tab (tab B). |
| 95 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1, | 95 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1, |
| 96 Browser::ADD_SELECTED, NULL, std::string()); | 96 Browser::ADD_SELECTED, NULL, std::string()); |
| 97 | 97 |
| 98 browser()->Find(); | 98 browser()->Find(); |
| 99 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); | 99 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 116 browser()->window()->GetNativeHandle(), base::VKEY_ESCAPE, | 116 browser()->window()->GetNativeHandle(), base::VKEY_ESCAPE, |
| 117 false, false, false, new MessageLoop::QuitTask()); | 117 false, false, false, new MessageLoop::QuitTask()); |
| 118 ui_test_utils::RunMessageLoop(); | 118 ui_test_utils::RunMessageLoop(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) { | 121 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) { |
| 122 scoped_refptr<HTTPTestServer> server = | 122 scoped_refptr<HTTPTestServer> server = |
| 123 HTTPTestServer::CreateServer(kDocRoot, NULL); | 123 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 124 ASSERT_TRUE(NULL != server.get()); | 124 ASSERT_TRUE(NULL != server.get()); |
| 125 | 125 |
| 126 GURL url = server->TestServerPageW(L"title1.html"); | 126 GURL url = server->TestServerPage("title1.html"); |
| 127 ui_test_utils::NavigateToURL(browser(), url); | 127 ui_test_utils::NavigateToURL(browser(), url); |
| 128 | 128 |
| 129 // Focus the location bar, open and close the find-in-page, focus should | 129 // Focus the location bar, open and close the find-in-page, focus should |
| 130 // return to the location bar. | 130 // return to the location bar. |
| 131 browser()->FocusLocationBar(); | 131 browser()->FocusLocationBar(); |
| 132 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); | 132 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); |
| 133 // Ensure the creation of the find bar controller. | 133 // Ensure the creation of the find bar controller. |
| 134 browser()->GetFindBarController()->Show(); | 134 browser()->GetFindBarController()->Show(); |
| 135 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); | 135 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); |
| 136 browser()->GetFindBarController()->EndFindSession( | 136 browser()->GetFindBarController()->EndFindSession( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 152 // the location bar (same as before, just checking that http://crbug.com/23599 | 152 // the location bar (same as before, just checking that http://crbug.com/23599 |
| 153 // is fixed). | 153 // is fixed). |
| 154 browser()->FocusLocationBar(); | 154 browser()->FocusLocationBar(); |
| 155 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); | 155 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); |
| 156 browser()->GetFindBarController()->Show(); | 156 browser()->GetFindBarController()->Show(); |
| 157 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); | 157 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); |
| 158 browser()->GetFindBarController()->EndFindSession( | 158 browser()->GetFindBarController()->EndFindSession( |
| 159 FindBarController::kKeepSelection); | 159 FindBarController::kKeepSelection); |
| 160 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); | 160 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); |
| 161 } | 161 } |
| OLD | NEW |