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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
11 #include "chrome/browser/ui/omnibox/location_bar.h" | 11 #include "chrome/browser/ui/omnibox/location_bar.h" |
12 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 12 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
13 #include "chrome/browser/ui/view_ids.h" | 13 #include "chrome/browser/ui/view_ids.h" |
14 #include "chrome/browser/ui/views/frame/browser_view.h" | 14 #include "chrome/browser/ui/views/frame/browser_view.h" |
15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
16 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
17 #include "chrome/test/base/interactive_test_utils.h" | 17 #include "chrome/test/base/interactive_test_utils.h" |
18 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
19 #include "ui/aura/test/event_generator.h" | 19 #include "ui/aura/test/event_generator.h" |
20 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
21 #include "ui/aura/window_tree_host.h" | 21 #include "ui/aura/window_tree_host.h" |
22 #include "ui/base/clipboard/clipboard.h" | 22 #include "ui/base/clipboard/clipboard.h" |
23 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 23 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
24 #include "ui/base/test/ui_controls.h" | 24 #include "ui/base/test/ui_controls.h" |
25 #include "ui/base/ui_base_switches.h" | 25 #include "ui/base/ui_base_switches.h" |
26 #include "ui/events/event_processor.h" | 26 #include "ui/events/event_processor.h" |
| 27 #include "ui/events/event_utils.h" |
27 #include "ui/views/controls/textfield/textfield_test_api.h" | 28 #include "ui/views/controls/textfield/textfield_test_api.h" |
28 | 29 |
29 class OmniboxViewViewsTest : public InProcessBrowserTest { | 30 class OmniboxViewViewsTest : public InProcessBrowserTest { |
30 protected: | 31 protected: |
31 OmniboxViewViewsTest() {} | 32 OmniboxViewViewsTest() {} |
32 | 33 |
33 static void GetOmniboxViewForBrowser(const Browser* browser, | 34 static void GetOmniboxViewForBrowser(const Browser* browser, |
34 OmniboxView** omnibox_view) { | 35 OmniboxView** omnibox_view) { |
35 BrowserWindow* window = browser->window(); | 36 BrowserWindow* window = browser->window(); |
36 ASSERT_TRUE(window); | 37 ASSERT_TRUE(window); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 GetNativeWindow()->GetRootWindow()); | 74 GetNativeWindow()->GetRootWindow()); |
74 generator.GestureTapAt(center); | 75 generator.GestureTapAt(center); |
75 } | 76 } |
76 | 77 |
77 // Touch down and release at the specified locations. | 78 // Touch down and release at the specified locations. |
78 void Tap(const gfx::Point& press_location, | 79 void Tap(const gfx::Point& press_location, |
79 const gfx::Point& release_location) { | 80 const gfx::Point& release_location) { |
80 ui::EventProcessor* dispatcher = | 81 ui::EventProcessor* dispatcher = |
81 browser()->window()->GetNativeWindow()->GetHost()->event_processor(); | 82 browser()->window()->GetNativeWindow()->GetHost()->event_processor(); |
82 | 83 |
83 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, press_location, | 84 ui::TouchEvent press( |
84 5, base::TimeDelta::FromMilliseconds(0)); | 85 ui::ET_TOUCH_PRESSED, press_location, 5, ui::EventTimeForNow()); |
85 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); | 86 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); |
86 ASSERT_FALSE(details.dispatcher_destroyed); | 87 ASSERT_FALSE(details.dispatcher_destroyed); |
87 | 88 |
| 89 if (press_location != release_location) { |
| 90 ui::TouchEvent move(ui::ET_TOUCH_MOVED, release_location, |
| 91 5, base::TimeDelta::FromMilliseconds(10)); |
| 92 details = dispatcher->OnEventFromSource(&move); |
| 93 } |
| 94 |
88 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, release_location, | 95 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, release_location, |
89 5, base::TimeDelta::FromMilliseconds(50)); | 96 5, base::TimeDelta::FromMilliseconds(50)); |
90 details = dispatcher->OnEventFromSource(&release); | 97 details = dispatcher->OnEventFromSource(&release); |
91 ASSERT_FALSE(details.dispatcher_destroyed); | 98 ASSERT_FALSE(details.dispatcher_destroyed); |
92 } | 99 } |
93 | 100 |
94 private: | 101 private: |
95 // InProcessBrowserTest: | 102 // InProcessBrowserTest: |
96 virtual void SetUpOnMainThread() OVERRIDE { | 103 virtual void SetUpOnMainThread() OVERRIDE { |
97 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 104 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 omnibox_view_views->GetBoundsInScreen().CenterPoint(); | 324 omnibox_view_views->GetBoundsInScreen().CenterPoint(); |
318 Tap(omnibox_center, omnibox_center); | 325 Tap(omnibox_center, omnibox_center); |
319 EXPECT_TRUE(textfield_test_api.touch_selection_controller()); | 326 EXPECT_TRUE(textfield_test_api.touch_selection_controller()); |
320 | 327 |
321 // Execute a command and check if it deactivate touch editing. Paste & Go is | 328 // Execute a command and check if it deactivate touch editing. Paste & Go is |
322 // chosen since it is specific to Omnibox and its execution wouldn't be | 329 // chosen since it is specific to Omnibox and its execution wouldn't be |
323 // delgated to the base Textfield class. | 330 // delgated to the base Textfield class. |
324 omnibox_view_views->ExecuteCommand(IDS_PASTE_AND_GO, ui::EF_NONE); | 331 omnibox_view_views->ExecuteCommand(IDS_PASTE_AND_GO, ui::EF_NONE); |
325 EXPECT_FALSE(textfield_test_api.touch_selection_controller()); | 332 EXPECT_FALSE(textfield_test_api.touch_selection_controller()); |
326 } | 333 } |
OLD | NEW |