| 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" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 ASSERT_TRUE(view); | 46 ASSERT_TRUE(view); |
| 47 ui_controls::MoveMouseToCenterAndPress(view, | 47 ui_controls::MoveMouseToCenterAndPress(view, |
| 48 ui_controls::LEFT, | 48 ui_controls::LEFT, |
| 49 ui_controls::DOWN | ui_controls::UP, | 49 ui_controls::DOWN | ui_controls::UP, |
| 50 new MessageLoop::QuitTask()); | 50 new MessageLoop::QuitTask()); |
| 51 ui_test_utils::RunMessageLoop(); | 51 ui_test_utils::RunMessageLoop(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 int GetFocusedViewID() { | 54 int GetFocusedViewID() { |
| 55 #if defined(TOOLKIT_VIEWS) | 55 #if defined(TOOLKIT_VIEWS) |
| 56 #if defined(OS_LINUX) |
| 57 // See http://crbug.com/26873 . |
| 58 views::FocusManager* focus_manager = |
| 59 views::FocusManager::GetFocusManagerForNativeView( |
| 60 GTK_WIDGET(browser()->window()->GetNativeHandle())); |
| 61 #else |
| 56 views::FocusManager* focus_manager = | 62 views::FocusManager* focus_manager = |
| 57 views::FocusManager::GetFocusManagerForNativeView( | 63 views::FocusManager::GetFocusManagerForNativeView( |
| 58 browser()->window()->GetNativeHandle()); | 64 browser()->window()->GetNativeHandle()); |
| 65 #endif |
| 66 |
| 59 if (!focus_manager) { | 67 if (!focus_manager) { |
| 60 NOTREACHED(); | 68 NOTREACHED(); |
| 61 return -1; | 69 return -1; |
| 62 } | 70 } |
| 63 views::View* focused_view = focus_manager->GetFocusedView(); | 71 views::View* focused_view = focus_manager->GetFocusedView(); |
| 64 if (!focused_view) | 72 if (!focused_view) |
| 65 return -1; | 73 return -1; |
| 66 return focused_view->GetID(); | 74 return focused_view->GetID(); |
| 67 #else | 75 #else |
| 68 return -1; | 76 return -1; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 browser()->GetFindBarController()->EndFindSession( | 136 browser()->GetFindBarController()->EndFindSession( |
| 129 FindBarController::kKeepSelection); | 137 FindBarController::kKeepSelection); |
| 130 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); | 138 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); |
| 131 | 139 |
| 132 // Focus the location bar, find something on the page, close the find box, | 140 // Focus the location bar, find something on the page, close the find box, |
| 133 // focus should go to the page. | 141 // focus should go to the page. |
| 134 browser()->FocusLocationBar(); | 142 browser()->FocusLocationBar(); |
| 135 browser()->Find(); | 143 browser()->Find(); |
| 136 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); | 144 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); |
| 137 ui_test_utils::FindInPage(browser()->GetSelectedTabContents(), | 145 ui_test_utils::FindInPage(browser()->GetSelectedTabContents(), |
| 138 L"a", true, false, NULL); | 146 ASCIIToUTF16("a"), true, false, NULL); |
| 139 browser()->GetFindBarController()->EndFindSession( | 147 browser()->GetFindBarController()->EndFindSession( |
| 140 FindBarController::kKeepSelection); | 148 FindBarController::kKeepSelection); |
| 141 EXPECT_EQ(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW, GetFocusedViewID()); | 149 EXPECT_EQ(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW, GetFocusedViewID()); |
| 142 | 150 |
| 143 // Focus the location bar, open and close the find box, focus should return to | 151 // Focus the location bar, open and close the find box, focus should return to |
| 144 // 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 |
| 145 // is fixed). | 153 // is fixed). |
| 146 browser()->FocusLocationBar(); | 154 browser()->FocusLocationBar(); |
| 147 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); | 155 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); |
| 148 browser()->GetFindBarController()->Show(); | 156 browser()->GetFindBarController()->Show(); |
| 149 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); | 157 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); |
| 150 browser()->GetFindBarController()->EndFindSession( | 158 browser()->GetFindBarController()->EndFindSession( |
| 151 FindBarController::kKeepSelection); | 159 FindBarController::kKeepSelection); |
| 152 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); | 160 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); |
| 153 } | 161 } |
| OLD | NEW |