Chromium Code Reviews| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); | 103 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); |
| 104 #endif | 104 #endif |
| 105 | 105 |
| 106 // This used to crash until bug 1303709 was fixed. | 106 // This used to crash until bug 1303709 was fixed. |
| 107 ui_controls::SendKeyPressNotifyWhenDone( | 107 ui_controls::SendKeyPressNotifyWhenDone( |
| 108 browser()->window()->GetNativeHandle(), base::VKEY_ESCAPE, | 108 browser()->window()->GetNativeHandle(), base::VKEY_ESCAPE, |
| 109 true, false, false, new MessageLoop::QuitTask()); | 109 true, false, false, new MessageLoop::QuitTask()); |
| 110 ui_test_utils::RunMessageLoop(); | 110 ui_test_utils::RunMessageLoop(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 // TODO: http://crbug.com/26231 | 113 // TODO: http://crbug.com/26231 |
|
Paweł Hajdan Jr.
2009/10/29 20:45:32
This comment is probably outdated.
| |
| 114 IN_PROC_BROWSER_TEST_F(FindInPageTest, DISABLED_FocusRestore) { | 114 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) { |
| 115 scoped_refptr<HTTPTestServer> server = | 115 scoped_refptr<HTTPTestServer> server = |
| 116 HTTPTestServer::CreateServer(kDocRoot, NULL); | 116 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 117 ASSERT_TRUE(NULL != server.get()); | 117 ASSERT_TRUE(NULL != server.get()); |
| 118 | 118 |
| 119 GURL url = server->TestServerPageW(L"title1.html"); | 119 GURL url = server->TestServerPageW(L"title1.html"); |
| 120 ui_test_utils::NavigateToURL(browser(), url); | 120 ui_test_utils::NavigateToURL(browser(), url); |
| 121 | 121 |
| 122 // Focus the location bar, open and close the find-in-page, focus should | 122 // Focus the location bar, open and close the find-in-page, focus should |
| 123 // return to the location bar. | 123 // return to the location bar. |
| 124 browser()->FocusLocationBar(); | 124 browser()->FocusLocationBar(); |
| 125 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); | 125 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); |
| 126 browser()->find_bar()->Show(); | 126 // Ensure the creation of the find bar controller. |
| 127 browser()->GetFindBarController()->Show(); | |
| 127 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); | 128 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); |
| 128 browser()->find_bar()->EndFindSession(); | 129 browser()->GetFindBarController()->EndFindSession(); |
| 129 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); | 130 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); |
| 130 | 131 |
| 131 // Focus the location bar, find something on the page, close the find box, | 132 // Focus the location bar, find something on the page, close the find box, |
| 132 // focus should go to the page. | 133 // focus should go to the page. |
| 133 browser()->FocusLocationBar(); | 134 browser()->FocusLocationBar(); |
| 134 browser()->Find(); | 135 browser()->Find(); |
| 135 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); | 136 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); |
| 136 ui_test_utils::FindInPage(browser()->GetSelectedTabContents(), | 137 ui_test_utils::FindInPage(browser()->GetSelectedTabContents(), |
| 137 L"a", true, false, NULL); | 138 L"a", true, false, NULL); |
| 138 browser()->find_bar()->EndFindSession(); | 139 browser()->GetFindBarController()->EndFindSession(); |
| 139 EXPECT_EQ(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW, GetFocusedViewID()); | 140 EXPECT_EQ(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW, GetFocusedViewID()); |
| 140 | 141 |
| 141 // Focus the location bar, open and close the find box, focus should return to | 142 // Focus the location bar, open and close the find box, focus should return to |
| 142 // the location bar (same as before, just checking that http://crbug.com/23599 | 143 // the location bar (same as before, just checking that http://crbug.com/23599 |
| 143 // is fixed). | 144 // is fixed). |
| 144 browser()->FocusLocationBar(); | 145 browser()->FocusLocationBar(); |
| 145 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); | 146 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); |
| 146 browser()->find_bar()->Show(); | 147 browser()->GetFindBarController()->Show(); |
| 147 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); | 148 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); |
| 148 browser()->find_bar()->EndFindSession(); | 149 browser()->GetFindBarController()->EndFindSession(); |
| 149 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); | 150 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); |
| 150 } | 151 } |
| OLD | NEW |