OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
10 #include "chrome/browser/ui/browser_tabstrip.h" | 10 #include "chrome/browser/ui/browser_tabstrip.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), | 132 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
133 location_bar_focus_view_id_)); | 133 location_bar_focus_view_id_)); |
134 | 134 |
135 // Focus the location bar, find something on the page, close the find box, | 135 // Focus the location bar, find something on the page, close the find box, |
136 // focus should go to the page. | 136 // focus should go to the page. |
137 chrome::FocusLocationBar(browser()); | 137 chrome::FocusLocationBar(browser()); |
138 chrome::Find(browser()); | 138 chrome::Find(browser()); |
139 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), | 139 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
140 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 140 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
141 ui_test_utils::FindInPage(chrome::GetActiveTabContents(browser()), | 141 ui_test_utils::FindInPage(chrome::GetActiveTabContents(browser()), |
142 ASCIIToUTF16("a"), true, false, NULL); | 142 ASCIIToUTF16("a"), true, false, NULL, NULL); |
143 browser()->GetFindBarController()->EndFindSession( | 143 browser()->GetFindBarController()->EndFindSession( |
144 FindBarController::kKeepSelectionOnPage, | 144 FindBarController::kKeepSelectionOnPage, |
145 FindBarController::kKeepResultsInFindBox); | 145 FindBarController::kKeepResultsInFindBox); |
146 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 146 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
147 | 147 |
148 // Focus the location bar, open and close the find box, focus should return to | 148 // Focus the location bar, open and close the find box, focus should return to |
149 // the location bar (same as before, just checking that http://crbug.com/23599 | 149 // the location bar (same as before, just checking that http://crbug.com/23599 |
150 // is fixed). | 150 // is fixed). |
151 chrome::FocusLocationBar(browser()); | 151 chrome::FocusLocationBar(browser()); |
152 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), | 152 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
(...skipping 22 matching lines...) Expand all Loading... |
175 | 175 |
176 chrome::Find(browser()); | 176 chrome::Find(browser()); |
177 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), | 177 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
178 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 178 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
179 | 179 |
180 FindBarTesting* find_bar = | 180 FindBarTesting* find_bar = |
181 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); | 181 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); |
182 | 182 |
183 // Search for 'a'. | 183 // Search for 'a'. |
184 ui_test_utils::FindInPage(chrome::GetActiveTabContents(browser()), | 184 ui_test_utils::FindInPage(chrome::GetActiveTabContents(browser()), |
185 ASCIIToUTF16("a"), true, false, NULL); | 185 ASCIIToUTF16("a"), true, false, NULL, NULL); |
186 EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText()); | 186 EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText()); |
187 | 187 |
188 // Open another tab (tab B). | 188 // Open another tab (tab B). |
189 content::WindowedNotificationObserver observer( | 189 content::WindowedNotificationObserver observer( |
190 content::NOTIFICATION_LOAD_STOP, | 190 content::NOTIFICATION_LOAD_STOP, |
191 content::NotificationService::AllSources()); | 191 content::NotificationService::AllSources()); |
192 chrome::AddSelectedTabWithURL(browser(), url, content::PAGE_TRANSITION_TYPED); | 192 chrome::AddSelectedTabWithURL(browser(), url, content::PAGE_TRANSITION_TYPED); |
193 observer.Wait(); | 193 observer.Wait(); |
194 | 194 |
195 // Make sure Find box is open. | 195 // Make sure Find box is open. |
196 chrome::Find(browser()); | 196 chrome::Find(browser()); |
197 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), | 197 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
198 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 198 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
199 | 199 |
200 // Search for 'b'. | 200 // Search for 'b'. |
201 ui_test_utils::FindInPage(chrome::GetActiveTabContents(browser()), | 201 ui_test_utils::FindInPage(chrome::GetActiveTabContents(browser()), |
202 ASCIIToUTF16("b"), true, false, NULL); | 202 ASCIIToUTF16("b"), true, false, NULL, NULL); |
203 EXPECT_TRUE(ASCIIToUTF16("b") == find_bar->GetFindSelectedText()); | 203 EXPECT_TRUE(ASCIIToUTF16("b") == find_bar->GetFindSelectedText()); |
204 | 204 |
205 // Set focus away from the Find bar (to the Location bar). | 205 // Set focus away from the Find bar (to the Location bar). |
206 chrome::FocusLocationBar(browser()); | 206 chrome::FocusLocationBar(browser()); |
207 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), | 207 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
208 location_bar_focus_view_id_)); | 208 location_bar_focus_view_id_)); |
209 | 209 |
210 // Select tab A. Find bar should get focus. | 210 // Select tab A. Find bar should get focus. |
211 chrome::ActivateTabAt(browser(), 0, true); | 211 chrome::ActivateTabAt(browser(), 0, true); |
212 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), | 212 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, notification_source); | 367 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, notification_source); |
368 | 368 |
369 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 369 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
370 browser(), ui::VKEY_V, true, false, false, false)); | 370 browser(), ui::VKEY_V, true, false, false, false)); |
371 | 371 |
372 ASSERT_NO_FATAL_FAILURE(observer.Wait()); | 372 ASSERT_NO_FATAL_FAILURE(observer.Wait()); |
373 FindNotificationDetails details; | 373 FindNotificationDetails details; |
374 ASSERT_TRUE(observer.GetDetailsFor(notification_source.map_key(), &details)); | 374 ASSERT_TRUE(observer.GetDetailsFor(notification_source.map_key(), &details)); |
375 EXPECT_TRUE(details.number_of_matches() > 0); | 375 EXPECT_TRUE(details.number_of_matches() > 0); |
376 } | 376 } |
OLD | NEW |