OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/process_util.h" | 5 #include "base/process_util.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/tabs/tab_strip_model.h" | 8 #include "chrome/browser/tabs/tab_strip_model.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 10 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
11 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 11 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
12 #include "chrome/browser/ui/view_ids.h" | 12 #include "chrome/browser/ui/view_ids.h" |
13 #include "chrome/browser/ui/views/find_bar_host.h" | 13 #include "chrome/browser/ui/views/find_bar_host.h" |
14 #include "chrome/browser/ui/views/frame/browser_view.h" | 14 #include "chrome/browser/ui/views/frame/browser_view.h" |
15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
16 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
17 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
18 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
| 19 #include "content/public/browser/notification_service.h" |
19 #include "net/test/test_server.h" | 20 #include "net/test/test_server.h" |
20 #include "ui/base/clipboard/clipboard.h" | 21 #include "ui/base/clipboard/clipboard.h" |
21 #include "ui/base/keycodes/keyboard_codes.h" | 22 #include "ui/base/keycodes/keyboard_codes.h" |
22 #include "views/focus/focus_manager.h" | 23 #include "views/focus/focus_manager.h" |
23 #include "views/view.h" | 24 #include "views/view.h" |
24 #include "views/views_delegate.h" | 25 #include "views/views_delegate.h" |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 // The delay waited after sending an OS simulated event. | 29 // The delay waited after sending an OS simulated event. |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 FindBarTesting* find_bar = | 157 FindBarTesting* find_bar = |
157 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); | 158 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); |
158 | 159 |
159 // Search for 'a'. | 160 // Search for 'a'. |
160 ui_test_utils::FindInPage(browser()->GetSelectedTabContentsWrapper(), | 161 ui_test_utils::FindInPage(browser()->GetSelectedTabContentsWrapper(), |
161 ASCIIToUTF16("a"), true, false, NULL); | 162 ASCIIToUTF16("a"), true, false, NULL); |
162 EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText()); | 163 EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText()); |
163 | 164 |
164 // Open another tab (tab B). | 165 // Open another tab (tab B). |
165 ui_test_utils::WindowedNotificationObserver observer( | 166 ui_test_utils::WindowedNotificationObserver observer( |
166 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); | 167 content::NOTIFICATION_LOAD_STOP, |
| 168 content::NotificationService::AllSources()); |
167 browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); | 169 browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); |
168 observer.Wait(); | 170 observer.Wait(); |
169 | 171 |
170 // Make sure Find box is open. | 172 // Make sure Find box is open. |
171 browser()->Find(); | 173 browser()->Find(); |
172 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), | 174 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
173 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 175 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
174 | 176 |
175 // Search for 'b'. | 177 // Search for 'b'. |
176 ui_test_utils::FindInPage(browser()->GetSelectedTabContentsWrapper(), | 178 ui_test_utils::FindInPage(browser()->GetSelectedTabContentsWrapper(), |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, notification_source); | 341 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, notification_source); |
340 | 342 |
341 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 343 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
342 browser(), ui::VKEY_V, true, false, false, false)); | 344 browser(), ui::VKEY_V, true, false, false, false)); |
343 | 345 |
344 ASSERT_NO_FATAL_FAILURE(observer.Wait()); | 346 ASSERT_NO_FATAL_FAILURE(observer.Wait()); |
345 FindNotificationDetails details; | 347 FindNotificationDetails details; |
346 ASSERT_TRUE(observer.GetDetailsFor(notification_source.map_key(), &details)); | 348 ASSERT_TRUE(observer.GetDetailsFor(notification_source.map_key(), &details)); |
347 EXPECT_TRUE(details.number_of_matches() > 0); | 349 EXPECT_TRUE(details.number_of_matches() > 0); |
348 } | 350 } |
OLD | NEW |