OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/test/test_server.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 char kSimplePage[] = "files/find_in_page/simple.html"; | 26 static const char kSimplePage[] = "files/find_in_page/simple.html"; |
27 | 27 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 string16 GetFindBarText() { | 80 string16 GetFindBarText() { |
81 FindBarTesting* find_bar = | 81 FindBarTesting* find_bar = |
82 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); | 82 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); |
83 return find_bar->GetFindText(); | 83 return find_bar->GetFindText(); |
84 } | 84 } |
85 }; | 85 }; |
86 | 86 |
87 } // namespace | 87 } // namespace |
88 | 88 |
89 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) { | 89 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) { |
90 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); | 90 scoped_refptr<net::HTTPTestServer> server(net::HTTPTestServer::CreateServer(kD
ocRoot)); |
91 ASSERT_TRUE(NULL != server.get()); | 91 ASSERT_TRUE(NULL != server.get()); |
92 | 92 |
93 // First we navigate to our test page (tab A). | 93 // First we navigate to our test page (tab A). |
94 GURL url = server->TestServerPage(kSimplePage); | 94 GURL url = server->TestServerPage(kSimplePage); |
95 ui_test_utils::NavigateToURL(browser(), url); | 95 ui_test_utils::NavigateToURL(browser(), url); |
96 | 96 |
97 browser()->Find(); | 97 browser()->Find(); |
98 | 98 |
99 // Open another tab (tab B). | 99 // Open another tab (tab B). |
100 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1, | 100 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1, |
(...skipping 16 matching lines...) Expand all Loading... |
117 #endif | 117 #endif |
118 | 118 |
119 // This used to crash until bug 1303709 was fixed. | 119 // This used to crash until bug 1303709 was fixed. |
120 ui_controls::SendKeyPressNotifyWhenDone( | 120 ui_controls::SendKeyPressNotifyWhenDone( |
121 browser()->window()->GetNativeHandle(), base::VKEY_ESCAPE, | 121 browser()->window()->GetNativeHandle(), base::VKEY_ESCAPE, |
122 false, false, false, false, new MessageLoop::QuitTask()); | 122 false, false, false, false, new MessageLoop::QuitTask()); |
123 ui_test_utils::RunMessageLoop(); | 123 ui_test_utils::RunMessageLoop(); |
124 } | 124 } |
125 | 125 |
126 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) { | 126 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) { |
127 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); | 127 scoped_refptr<net::HTTPTestServer> server(net::HTTPTestServer::CreateServer(kD
ocRoot)); |
128 ASSERT_TRUE(NULL != server.get()); | 128 ASSERT_TRUE(NULL != server.get()); |
129 | 129 |
130 GURL url = server->TestServerPage("title1.html"); | 130 GURL url = server->TestServerPage("title1.html"); |
131 ui_test_utils::NavigateToURL(browser(), url); | 131 ui_test_utils::NavigateToURL(browser(), url); |
132 | 132 |
133 // Focus the location bar, open and close the find-in-page, focus should | 133 // Focus the location bar, open and close the find-in-page, focus should |
134 // return to the location bar. | 134 // return to the location bar. |
135 browser()->FocusLocationBar(); | 135 browser()->FocusLocationBar(); |
136 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); | 136 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); |
137 // Ensure the creation of the find bar controller. | 137 // Ensure the creation of the find bar controller. |
(...skipping 28 matching lines...) Expand all Loading... |
166 | 166 |
167 // This tests that whenever you clear values from the Find box and close it that | 167 // This tests that whenever you clear values from the Find box and close it that |
168 // it respects that and doesn't show you the last search, as reported in bug: | 168 // it respects that and doesn't show you the last search, as reported in bug: |
169 // http://crbug.com/40121. | 169 // http://crbug.com/40121. |
170 IN_PROC_BROWSER_TEST_F(FindInPageTest, PrepopulateRespectBlank) { | 170 IN_PROC_BROWSER_TEST_F(FindInPageTest, PrepopulateRespectBlank) { |
171 #if defined(OS_MACOSX) | 171 #if defined(OS_MACOSX) |
172 // FindInPage on Mac doesn't use prepopulated values. Search there is global. | 172 // FindInPage on Mac doesn't use prepopulated values. Search there is global. |
173 return; | 173 return; |
174 #endif | 174 #endif |
175 | 175 |
176 HTTPTestServer* server = StartHTTPServer(); | 176 net::HTTPTestServer* server = StartHTTPServer(); |
177 ASSERT_TRUE(server); | 177 ASSERT_TRUE(server); |
178 | 178 |
179 // First we navigate to any page. | 179 // First we navigate to any page. |
180 GURL url = server->TestServerPage(kSimplePage); | 180 GURL url = server->TestServerPage(kSimplePage); |
181 ui_test_utils::NavigateToURL(browser(), url); | 181 ui_test_utils::NavigateToURL(browser(), url); |
182 | 182 |
183 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); | 183 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); |
184 | 184 |
185 // Show the Find bar. | 185 // Show the Find bar. |
186 browser()->GetFindBarController()->Show(); | 186 browser()->GetFindBarController()->Show(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 // Press F3 to trigger FindNext. | 225 // Press F3 to trigger FindNext. |
226 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F3, | 226 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F3, |
227 false, false, false, false, // No modifiers. | 227 false, false, false, false, // No modifiers. |
228 new MessageLoop::QuitTask()); | 228 new MessageLoop::QuitTask()); |
229 ui_test_utils::RunMessageLoop(); | 229 ui_test_utils::RunMessageLoop(); |
230 | 230 |
231 // After the Find box has been reopened, it should still have no prepopulate | 231 // After the Find box has been reopened, it should still have no prepopulate |
232 // value. | 232 // value. |
233 EXPECT_EQ(string16(), GetFindBarText()); | 233 EXPECT_EQ(string16(), GetFindBarText()); |
234 } | 234 } |
OLD | NEW |