| 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/find_bar/find_bar_controller.h" | 9 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 10 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 10 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 FindBarController::kKeepResultsInFindBox); | 129 FindBarController::kKeepResultsInFindBox); |
| 130 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), | 130 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| 131 location_bar_focus_view_id_)); | 131 location_bar_focus_view_id_)); |
| 132 | 132 |
| 133 // Focus the location bar, find something on the page, close the find box, | 133 // Focus the location bar, find something on the page, close the find box, |
| 134 // focus should go to the page. | 134 // focus should go to the page. |
| 135 browser()->FocusLocationBar(); | 135 browser()->FocusLocationBar(); |
| 136 browser()->Find(); | 136 browser()->Find(); |
| 137 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), | 137 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| 138 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 138 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
| 139 ui_test_utils::FindInPage(browser()->GetSelectedTabContentsWrapper(), | 139 ui_test_utils::FindInPage(browser()->GetActiveTabContents(), |
| 140 ASCIIToUTF16("a"), true, false, NULL); | 140 ASCIIToUTF16("a"), true, false, NULL); |
| 141 browser()->GetFindBarController()->EndFindSession( | 141 browser()->GetFindBarController()->EndFindSession( |
| 142 FindBarController::kKeepSelectionOnPage, | 142 FindBarController::kKeepSelectionOnPage, |
| 143 FindBarController::kKeepResultsInFindBox); | 143 FindBarController::kKeepResultsInFindBox); |
| 144 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 144 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| 145 | 145 |
| 146 // Focus the location bar, open and close the find box, focus should return to | 146 // Focus the location bar, open and close the find box, focus should return to |
| 147 // the location bar (same as before, just checking that http://crbug.com/23599 | 147 // the location bar (same as before, just checking that http://crbug.com/23599 |
| 148 // is fixed). | 148 // is fixed). |
| 149 browser()->FocusLocationBar(); | 149 browser()->FocusLocationBar(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 172 ui_test_utils::NavigateToURL(browser(), url); | 172 ui_test_utils::NavigateToURL(browser(), url); |
| 173 | 173 |
| 174 browser()->Find(); | 174 browser()->Find(); |
| 175 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), | 175 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| 176 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 176 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
| 177 | 177 |
| 178 FindBarTesting* find_bar = | 178 FindBarTesting* find_bar = |
| 179 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); | 179 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); |
| 180 | 180 |
| 181 // Search for 'a'. | 181 // Search for 'a'. |
| 182 ui_test_utils::FindInPage(browser()->GetSelectedTabContentsWrapper(), | 182 ui_test_utils::FindInPage(browser()->GetActiveTabContents(), |
| 183 ASCIIToUTF16("a"), true, false, NULL); | 183 ASCIIToUTF16("a"), true, false, NULL); |
| 184 EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText()); | 184 EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText()); |
| 185 | 185 |
| 186 // Open another tab (tab B). | 186 // Open another tab (tab B). |
| 187 ui_test_utils::WindowedNotificationObserver observer( | 187 ui_test_utils::WindowedNotificationObserver observer( |
| 188 content::NOTIFICATION_LOAD_STOP, | 188 content::NOTIFICATION_LOAD_STOP, |
| 189 content::NotificationService::AllSources()); | 189 content::NotificationService::AllSources()); |
| 190 browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); | 190 browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); |
| 191 observer.Wait(); | 191 observer.Wait(); |
| 192 | 192 |
| 193 // Make sure Find box is open. | 193 // Make sure Find box is open. |
| 194 browser()->Find(); | 194 browser()->Find(); |
| 195 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), | 195 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| 196 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); | 196 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); |
| 197 | 197 |
| 198 // Search for 'b'. | 198 // Search for 'b'. |
| 199 ui_test_utils::FindInPage(browser()->GetSelectedTabContentsWrapper(), | 199 ui_test_utils::FindInPage(browser()->GetActiveTabContents(), |
| 200 ASCIIToUTF16("b"), true, false, NULL); | 200 ASCIIToUTF16("b"), true, false, NULL); |
| 201 EXPECT_TRUE(ASCIIToUTF16("b") == find_bar->GetFindSelectedText()); | 201 EXPECT_TRUE(ASCIIToUTF16("b") == find_bar->GetFindSelectedText()); |
| 202 | 202 |
| 203 // Set focus away from the Find bar (to the Location bar). | 203 // Set focus away from the Find bar (to the Location bar). |
| 204 browser()->FocusLocationBar(); | 204 browser()->FocusLocationBar(); |
| 205 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), | 205 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
| 206 location_bar_focus_view_id_)); | 206 location_bar_focus_view_id_)); |
| 207 | 207 |
| 208 // Select tab A. Find bar should get focus. | 208 // Select tab A. Find bar should get focus. |
| 209 browser()->ActivateTabAt(0, true); | 209 browser()->ActivateTabAt(0, true); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 string16 str; | 352 string16 str; |
| 353 views::ViewsDelegate::views_delegate->GetClipboard()-> | 353 views::ViewsDelegate::views_delegate->GetClipboard()-> |
| 354 ReadText(ui::Clipboard::BUFFER_STANDARD, &str); | 354 ReadText(ui::Clipboard::BUFFER_STANDARD, &str); |
| 355 | 355 |
| 356 // Make sure the text is copied successfully. | 356 // Make sure the text is copied successfully. |
| 357 EXPECT_EQ(ASCIIToUTF16("a"), str); | 357 EXPECT_EQ(ASCIIToUTF16("a"), str); |
| 358 | 358 |
| 359 // Press Ctrl-V to paste the content back, it should start finding even if the | 359 // Press Ctrl-V to paste the content back, it should start finding even if the |
| 360 // content is not changed. | 360 // content is not changed. |
| 361 content::Source<WebContents> notification_source( | 361 content::Source<WebContents> notification_source( |
| 362 browser()->GetSelectedWebContents()); | 362 browser()->GetActiveWebContents()); |
| 363 ui_test_utils::WindowedNotificationObserverWithDetails | 363 ui_test_utils::WindowedNotificationObserverWithDetails |
| 364 <FindNotificationDetails> observer( | 364 <FindNotificationDetails> observer( |
| 365 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, notification_source); | 365 chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, notification_source); |
| 366 | 366 |
| 367 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 367 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 368 browser(), ui::VKEY_V, true, false, false, false)); | 368 browser(), ui::VKEY_V, true, false, false, false)); |
| 369 | 369 |
| 370 ASSERT_NO_FATAL_FAILURE(observer.Wait()); | 370 ASSERT_NO_FATAL_FAILURE(observer.Wait()); |
| 371 FindNotificationDetails details; | 371 FindNotificationDetails details; |
| 372 ASSERT_TRUE(observer.GetDetailsFor(notification_source.map_key(), &details)); | 372 ASSERT_TRUE(observer.GetDetailsFor(notification_source.map_key(), &details)); |
| 373 EXPECT_TRUE(details.number_of_matches() > 0); | 373 EXPECT_TRUE(details.number_of_matches() > 0); |
| 374 } | 374 } |
| OLD | NEW |