| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 // Clicking in the omnibox should take focus and select all text. | 143 // Clicking in the omnibox should take focus and select all text. |
| 144 const gfx::Rect omnibox_bounds = BrowserView::GetBrowserViewForBrowser( | 144 const gfx::Rect omnibox_bounds = BrowserView::GetBrowserViewForBrowser( |
| 145 browser())->GetViewByID(VIEW_ID_OMNIBOX)->GetBoundsInScreen(); | 145 browser())->GetViewByID(VIEW_ID_OMNIBOX)->GetBoundsInScreen(); |
| 146 const gfx::Point click_location = omnibox_bounds.CenterPoint(); | 146 const gfx::Point click_location = omnibox_bounds.CenterPoint(); |
| 147 ASSERT_NO_FATAL_FAILURE(Click(ui_controls::LEFT, | 147 ASSERT_NO_FATAL_FAILURE(Click(ui_controls::LEFT, |
| 148 click_location, click_location)); | 148 click_location, click_location)); |
| 149 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 149 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
| 150 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 150 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
| 151 | 151 |
| 152 // Clicking in another view should clear focus and the selection. | 152 // Clicking in another view should clear focus. |
| 153 ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter()); | 153 ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter()); |
| 154 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 154 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
| 155 EXPECT_FALSE(omnibox_view->IsSelectAll()); | |
| 156 | 155 |
| 157 // Clicking in the omnibox again should take focus and select all text again. | 156 // Clicking in the omnibox again should take focus and select all text again. |
| 158 ASSERT_NO_FATAL_FAILURE(Click(ui_controls::LEFT, | 157 ASSERT_NO_FATAL_FAILURE(Click(ui_controls::LEFT, |
| 159 click_location, click_location)); | 158 click_location, click_location)); |
| 160 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 159 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
| 161 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 160 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
| 162 | 161 |
| 163 // Clicking another omnibox spot should keep focus but clear the selection. | 162 // Clicking another omnibox spot should keep focus but clear the selection. |
| 164 omnibox_view->SelectAll(false); | 163 omnibox_view->SelectAll(false); |
| 165 const gfx::Point click2_location = omnibox_bounds.origin() + | 164 const gfx::Point click2_location = omnibox_bounds.origin() + |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 #endif // OS_LINUX && !OS_CHROMEOS | 237 #endif // OS_LINUX && !OS_CHROMEOS |
| 239 | 238 |
| 240 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, SelectAllOnTap) { | 239 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, SelectAllOnTap) { |
| 241 OmniboxView* omnibox_view = NULL; | 240 OmniboxView* omnibox_view = NULL; |
| 242 ASSERT_NO_FATAL_FAILURE(GetOmniboxViewForBrowser(browser(), &omnibox_view)); | 241 ASSERT_NO_FATAL_FAILURE(GetOmniboxViewForBrowser(browser(), &omnibox_view)); |
| 243 omnibox_view->SetUserText(base::ASCIIToUTF16("http://www.google.com/")); | 242 omnibox_view->SetUserText(base::ASCIIToUTF16("http://www.google.com/")); |
| 244 | 243 |
| 245 // Take the focus away from the omnibox. | 244 // Take the focus away from the omnibox. |
| 246 ASSERT_NO_FATAL_FAILURE(TapBrowserWindowCenter()); | 245 ASSERT_NO_FATAL_FAILURE(TapBrowserWindowCenter()); |
| 247 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 246 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
| 248 EXPECT_FALSE(omnibox_view->IsSelectAll()); | |
| 249 | 247 |
| 250 // Tapping in the omnibox should take focus and select all text. | 248 // Tapping in the omnibox should take focus and select all text. |
| 251 const gfx::Rect omnibox_bounds = BrowserView::GetBrowserViewForBrowser( | 249 const gfx::Rect omnibox_bounds = BrowserView::GetBrowserViewForBrowser( |
| 252 browser())->GetViewByID(VIEW_ID_OMNIBOX)->GetBoundsInScreen(); | 250 browser())->GetViewByID(VIEW_ID_OMNIBOX)->GetBoundsInScreen(); |
| 253 const gfx::Point tap_location = omnibox_bounds.CenterPoint(); | 251 const gfx::Point tap_location = omnibox_bounds.CenterPoint(); |
| 254 ASSERT_NO_FATAL_FAILURE(Tap(tap_location, tap_location)); | 252 ASSERT_NO_FATAL_FAILURE(Tap(tap_location, tap_location)); |
| 255 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 253 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
| 256 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 254 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
| 257 | 255 |
| 258 // Tapping in another view should clear focus and the selection. | 256 // Tapping in another view should clear focus. |
| 259 ASSERT_NO_FATAL_FAILURE(TapBrowserWindowCenter()); | 257 ASSERT_NO_FATAL_FAILURE(TapBrowserWindowCenter()); |
| 260 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 258 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
| 261 EXPECT_FALSE(omnibox_view->IsSelectAll()); | |
| 262 | 259 |
| 263 // Tapping in the omnibox again should take focus and select all text again. | 260 // Tapping in the omnibox again should take focus and select all text again. |
| 264 ASSERT_NO_FATAL_FAILURE(Tap(tap_location, tap_location)); | 261 ASSERT_NO_FATAL_FAILURE(Tap(tap_location, tap_location)); |
| 265 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 262 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
| 266 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 263 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
| 267 | 264 |
| 268 // Tapping another omnibox spot should keep focus and selection. | 265 // Tapping another omnibox spot should keep focus and selection. |
| 269 omnibox_view->SelectAll(false); | 266 omnibox_view->SelectAll(false); |
| 270 const gfx::Point tap2_location = omnibox_bounds.origin() + | 267 const gfx::Point tap2_location = omnibox_bounds.origin() + |
| 271 gfx::Vector2d(omnibox_bounds.width() / 4, omnibox_bounds.height() / 4); | 268 gfx::Vector2d(omnibox_bounds.width() / 4, omnibox_bounds.height() / 4); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 OmniboxViewViews* omnibox_view_views = static_cast<OmniboxViewViews*>(view); | 450 OmniboxViewViews* omnibox_view_views = static_cast<OmniboxViewViews*>(view); |
| 454 | 451 |
| 455 ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter()); | 452 ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter()); |
| 456 EXPECT_EQ(omnibox_view_views->GetRenderText()->elide_behavior(), | 453 EXPECT_EQ(omnibox_view_views->GetRenderText()->elide_behavior(), |
| 457 gfx::ELIDE_TAIL); | 454 gfx::ELIDE_TAIL); |
| 458 | 455 |
| 459 chrome::FocusLocationBar(browser()); | 456 chrome::FocusLocationBar(browser()); |
| 460 EXPECT_EQ(omnibox_view_views->GetRenderText()->elide_behavior(), | 457 EXPECT_EQ(omnibox_view_views->GetRenderText()->elide_behavior(), |
| 461 gfx::NO_ELIDE); | 458 gfx::NO_ELIDE); |
| 462 } | 459 } |
| OLD | NEW |