Index: chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc |
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc |
index fc39393dc4b6858007084e5e7f154c73a6ba2099..31ee742f76dd372df45ffe2e1dc9d321ba60facf 100644 |
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc |
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc |
@@ -4,6 +4,7 @@ |
#include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
+#include "base/command_line.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_commands.h" |
#include "chrome/browser/ui/browser_window.h" |
@@ -21,6 +22,7 @@ |
#include "ui/base/clipboard/clipboard.h" |
#include "ui/base/clipboard/scoped_clipboard_writer.h" |
#include "ui/base/test/ui_controls.h" |
+#include "ui/base/ui_base_switches.h" |
#include "ui/events/event_processor.h" |
class OmniboxViewViewsTest : public InProcessBrowserTest { |
@@ -37,6 +39,11 @@ class OmniboxViewViewsTest : public InProcessBrowserTest { |
ASSERT_TRUE(*omnibox_view); |
} |
+ static ui::TouchSelectionController* GetTouchSelectionControllerForTextfield( |
+ views::Textfield* textfield) { |
+ return textfield->touch_selection_controller_.get(); |
+ } |
+ |
// Move the mouse to the center of the browser window and left-click. |
void ClickBrowserWindowCenter() { |
ASSERT_TRUE(ui_test_utils::SendMouseMoveSync( |
@@ -289,3 +296,34 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, BackgroundIsOpaque) { |
ASSERT_TRUE(view); |
EXPECT_FALSE(view->GetRenderText()->background_is_transparent()); |
} |
+ |
+// Tests if executing a command hides touch editing handles. |
+IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, |
+ DeactivateTouchEditingOnExecuteCommand) { |
+ CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableTouchEditing); |
+ |
+ OmniboxView* view = NULL; |
+ ASSERT_NO_FATAL_FAILURE(GetOmniboxViewForBrowser(browser(), &view)); |
+ OmniboxViewViews* omnibox_view_views = static_cast<OmniboxViewViews*>(view); |
+ |
+ // Put a URL on the clipboard. It is written to the clipboard upon destruction |
+ // of the writer. |
+ { |
+ ui::ScopedClipboardWriter clipboard_writer( |
+ ui::Clipboard::GetForCurrentThread(), |
+ ui::CLIPBOARD_TYPE_COPY_PASTE); |
+ clipboard_writer.WriteURL(base::ASCIIToUTF16("http://www.example.com/")); |
+ } |
+ |
+ // Tap to activate touch editing. |
+ gfx::Point omnibox_center = |
+ omnibox_view_views->GetBoundsInScreen().CenterPoint(); |
+ Tap(omnibox_center, omnibox_center); |
+ EXPECT_TRUE(GetTouchSelectionControllerForTextfield(omnibox_view_views)); |
+ |
+ // Execute a command and check if it deactivate touch editing. Paste & Go is |
+ // chosen since it is specific to Omnibox and its execution wouldn't be |
+ // delgated to the base Textfield class. |
+ omnibox_view_views->ExecuteCommand(IDS_PASTE_AND_GO, ui::EF_NONE); |
+ EXPECT_FALSE(GetTouchSelectionControllerForTextfield(omnibox_view_views)); |
+} |