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 base::TimeDelta timestamp = ui::EventTimeForNow(); |
84 5, base::TimeDelta::FromMilliseconds(0)); | 85 ui::TouchEvent press( |
| 86 ui::ET_TOUCH_PRESSED, press_location, 5, timestamp); |
85 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); | 87 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); |
86 ASSERT_FALSE(details.dispatcher_destroyed); | 88 ASSERT_FALSE(details.dispatcher_destroyed); |
87 | 89 |
88 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, release_location, | 90 if (press_location != release_location) { |
89 5, base::TimeDelta::FromMilliseconds(50)); | 91 timestamp += base::TimeDelta::FromMilliseconds(10); |
| 92 ui::TouchEvent move( |
| 93 ui::ET_TOUCH_MOVED, release_location, 5, timestamp); |
| 94 details = dispatcher->OnEventFromSource(&move); |
| 95 } |
| 96 |
| 97 timestamp += base::TimeDelta::FromMilliseconds(50); |
| 98 ui::TouchEvent release( |
| 99 ui::ET_TOUCH_RELEASED, release_location, 5, timestamp); |
90 details = dispatcher->OnEventFromSource(&release); | 100 details = dispatcher->OnEventFromSource(&release); |
91 ASSERT_FALSE(details.dispatcher_destroyed); | 101 ASSERT_FALSE(details.dispatcher_destroyed); |
92 } | 102 } |
93 | 103 |
94 private: | 104 private: |
95 // InProcessBrowserTest: | 105 // InProcessBrowserTest: |
96 virtual void SetUpOnMainThread() OVERRIDE { | 106 virtual void SetUpOnMainThread() OVERRIDE { |
97 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 107 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
98 chrome::FocusLocationBar(browser()); | 108 chrome::FocusLocationBar(browser()); |
99 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 109 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 omnibox_view_views->GetBoundsInScreen().CenterPoint(); | 327 omnibox_view_views->GetBoundsInScreen().CenterPoint(); |
318 Tap(omnibox_center, omnibox_center); | 328 Tap(omnibox_center, omnibox_center); |
319 EXPECT_TRUE(textfield_test_api.touch_selection_controller()); | 329 EXPECT_TRUE(textfield_test_api.touch_selection_controller()); |
320 | 330 |
321 // Execute a command and check if it deactivate touch editing. Paste & Go is | 331 // 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 | 332 // chosen since it is specific to Omnibox and its execution wouldn't be |
323 // delgated to the base Textfield class. | 333 // delgated to the base Textfield class. |
324 omnibox_view_views->ExecuteCommand(IDS_PASTE_AND_GO, ui::EF_NONE); | 334 omnibox_view_views->ExecuteCommand(IDS_PASTE_AND_GO, ui::EF_NONE); |
325 EXPECT_FALSE(textfield_test_api.touch_selection_controller()); | 335 EXPECT_FALSE(textfield_test_api.touch_selection_controller()); |
326 } | 336 } |
OLD | NEW |