Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1648)

Unified Diff: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc

Issue 13084017: Fix OmniboxViewTest.SelectAllOnClick (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 6 Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/gtk/view_id_util.cc ('k') | chrome/test/base/interactive_test_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
===================================================================
--- chrome/browser/ui/omnibox/omnibox_view_browsertest.cc (revision 192786)
+++ chrome/browser/ui/omnibox/omnibox_view_browsertest.cc (working copy)
@@ -48,10 +48,6 @@
#include <gtk/gtk.h>
#endif
-#if defined(USE_AURA)
-#include "chrome/browser/ui/views/frame/browser_view.h"
-#endif
-
#if defined(OS_MACOSX)
#include "base/mac/scoped_nsautorelease_pool.h"
#endif
@@ -1264,23 +1260,9 @@
EXPECT_EQ(old_text, omnibox_view->GetText());
}
-#if defined(USE_AURA)
- const BrowserView* GetBrowserView() const {
- return static_cast<BrowserView*>(browser()->window());
- }
-
- const views::View* GetFocusView() const {
- return GetBrowserView()->GetViewByID(VIEW_ID_OMNIBOX);
- }
-
// Move the mouse to the center of the browser window and left-click.
void ClickBrowserWindowCenter() {
- ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(
- GetBrowserView()->GetBoundsInScreen().CenterPoint()));
- ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(
- ui_controls::LEFT, ui_controls::DOWN));
- ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(
- ui_controls::LEFT, ui_controls::UP));
+ ui_test_utils::ClickOnView(browser(), VIEW_ID_CONTENTS_SPLIT);
}
// Press and release the mouse in the focus view at an offset from its origin.
@@ -1289,7 +1271,8 @@
void ClickFocusViewOrigin(ui_controls::MouseButton button,
const gfx::Vector2d& press_offset,
const gfx::Vector2d& release_offset) {
- gfx::Point focus_view_origin = GetFocusView()->GetBoundsInScreen().origin();
+ gfx::Point focus_view_origin = ui_test_utils::GetViewBounds(browser(),
+ VIEW_ID_OMNIBOX).origin();
gfx::Point press_point = focus_view_origin + press_offset;
ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(press_point));
ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(button, ui_controls::DOWN));
@@ -1299,7 +1282,6 @@
ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(release_point));
ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(button, ui_controls::UP));
}
-#endif // defined(USE_AURA)
};
// Test if ctrl-* accelerators are workable in omnibox.
@@ -1632,73 +1614,87 @@
}
#endif // defined(TOOLKIT_GTK)
-// TODO(derat): Enable on Windows: http://crbug.com/128556
-#if defined(USE_AURA)
-IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_SelectAllOnClick) {
+IN_PROC_BROWSER_TEST_F(OmniboxViewTest, SelectAllOnClick) {
OmniboxView* omnibox_view = NULL;
ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
omnibox_view->SetUserText(ASCIIToUTF16("http://www.google.com/"));
- const gfx::Vector2d kClickOffset(2, 2);
// Take the focus away from the omnibox.
ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter());
EXPECT_FALSE(omnibox_view->IsSelectAll());
- EXPECT_FALSE(GetFocusView()->HasFocus());
+ EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
+ gfx::Rect omnibox_bounds = ui_test_utils::GetViewBounds(browser(),
+ VIEW_ID_OMNIBOX);
+ gfx::Vector2d click_offset = omnibox_bounds.CenterPoint() -
+ omnibox_bounds.origin();
+
// Click in the omnibox. All of its text should be selected.
ASSERT_NO_FATAL_FAILURE(
- ClickFocusViewOrigin(ui_controls::LEFT, kClickOffset, kClickOffset));
+ ClickFocusViewOrigin(ui_controls::LEFT, click_offset, click_offset));
EXPECT_TRUE(omnibox_view->IsSelectAll());
- EXPECT_TRUE(GetFocusView()->HasFocus());
+ EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
- // Ensure that all of the text is selected and then take the focus away. The
- // selection should persist.
- omnibox_view->SelectAll(false);
- EXPECT_TRUE(omnibox_view->IsSelectAll());
- ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter());
- EXPECT_TRUE(omnibox_view->IsSelectAll());
- EXPECT_FALSE(GetFocusView()->HasFocus());
-
- // Clicking in the omnibox while some of its text is already selected should
- // have the effect of re-selecting the text.
- ASSERT_NO_FATAL_FAILURE(
- ClickFocusViewOrigin(ui_controls::LEFT, kClickOffset, kClickOffset));
- // The following expect fails starting with one of the cls (148415-148428),
- // most likely the WebKit roll @148419.
- // http://crbug.com/139069
- EXPECT_TRUE(omnibox_view->IsSelectAll());
- EXPECT_TRUE(GetFocusView()->HasFocus());
-
// Click in a different spot in the omnibox. It should keep the focus but
// lose the selection.
- omnibox_view->SelectAll(false);
- const gfx::Vector2d kSecondClickOffset(kClickOffset.x() + 10,
- kClickOffset.y());
+ const gfx::Vector2d second_click_offset(click_offset.x() + 10,
+ click_offset.y());
ASSERT_NO_FATAL_FAILURE(
ClickFocusViewOrigin(
- ui_controls::LEFT, kSecondClickOffset, kSecondClickOffset));
+ ui_controls::LEFT, second_click_offset, second_click_offset));
EXPECT_FALSE(omnibox_view->IsSelectAll());
- EXPECT_TRUE(GetFocusView()->HasFocus());
+ EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
// Take the focus away and click in the omnibox again, but drag a bit before
// releasing. We should focus the omnibox but not select all of its text.
ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter());
- const gfx::Vector2d kReleaseOffset(kClickOffset.x() + 10, kClickOffset.y());
+ const gfx::Vector2d release_offset(click_offset.x() + 10, click_offset.y());
ASSERT_NO_FATAL_FAILURE(
- ClickFocusViewOrigin(ui_controls::LEFT, kClickOffset, kReleaseOffset));
+ ClickFocusViewOrigin(ui_controls::LEFT, click_offset, release_offset));
EXPECT_FALSE(omnibox_view->IsSelectAll());
- EXPECT_TRUE(GetFocusView()->HasFocus());
+ EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
+ // Sleep here to avoid triggering a double click.
+ base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
+
// Middle-clicking shouldn't select all the text either.
ASSERT_NO_FATAL_FAILURE(
- ClickFocusViewOrigin(ui_controls::LEFT, kClickOffset, kClickOffset));
+ ClickFocusViewOrigin(ui_controls::LEFT, click_offset, click_offset));
ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter());
ASSERT_NO_FATAL_FAILURE(
- ClickFocusViewOrigin(ui_controls::MIDDLE, kClickOffset, kClickOffset));
+ ClickFocusViewOrigin(ui_controls::MIDDLE, click_offset, click_offset));
EXPECT_FALSE(omnibox_view->IsSelectAll());
}
-#endif // defined(USE_AURA)
+IN_PROC_BROWSER_TEST_F(OmniboxViewTest, SelectionPersistsOnRefocus) {
+ OmniboxView* omnibox_view = NULL;
+ ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
+ omnibox_view->SetUserText(ASCIIToUTF16("http://www.google.com/"));
+
+ gfx::Rect omnibox_bounds = ui_test_utils::GetViewBounds(browser(),
+ VIEW_ID_OMNIBOX);
+ gfx::Vector2d click_offset = omnibox_bounds.CenterPoint() -
+ omnibox_bounds.origin();
+
+ // Ensure that all of the text is selected and then take the focus away. The
+ // selection should persist.
+ omnibox_view->SelectAll(false);
+ EXPECT_TRUE(omnibox_view->IsSelectAll());
+ ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter());
+ EXPECT_TRUE(omnibox_view->IsSelectAll());
+ EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
+
+ // Clicking in the omnibox while some of its text is already selected should
+ // have the effect of re-selecting the text.
+ ASSERT_NO_FATAL_FAILURE(
+ ClickFocusViewOrigin(ui_controls::LEFT, click_offset, click_offset));
+ // The following expect fails starting with one of the cls (148415-148428),
+ // most likely the WebKit roll @148419.
+ // http://crbug.com/139069
+ EXPECT_TRUE(omnibox_view->IsSelectAll());
+ EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX));
+}
+
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, CopyURLToClipboard) {
OmniboxView* omnibox_view = NULL;
ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
« no previous file with comments | « chrome/browser/ui/gtk/view_id_util.cc ('k') | chrome/test/base/interactive_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698