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/search_engines/template_url_service_factory.h" | 8 #include "chrome/browser/search_engines/template_url_service_factory.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
12 #include "chrome/browser/ui/browser_window_testing_views.h" | 12 #include "chrome/browser/ui/browser_window_testing_views.h" |
13 #include "chrome/browser/ui/location_bar/location_bar.h" | 13 #include "chrome/browser/ui/location_bar/location_bar.h" |
14 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 14 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
15 #include "chrome/browser/ui/view_ids.h" | 15 #include "chrome/browser/ui/view_ids.h" |
16 #include "chrome/browser/ui/views/frame/browser_view.h" | 16 #include "chrome/browser/ui/views/frame/browser_view.h" |
17 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 17 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
18 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
19 #include "chrome/test/base/interactive_test_utils.h" | 19 #include "chrome/test/base/interactive_test_utils.h" |
20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
21 #include "ui/aura/window.h" | |
22 #include "ui/aura/window_tree_host.h" | |
23 #include "ui/base/clipboard/clipboard.h" | 21 #include "ui/base/clipboard/clipboard.h" |
24 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 22 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
25 #include "ui/base/ime/text_input_focus_manager.h" | 23 #include "ui/base/ime/text_input_focus_manager.h" |
26 #include "ui/base/test/ui_controls.h" | 24 #include "ui/base/test/ui_controls.h" |
27 #include "ui/base/ui_base_switches.h" | 25 #include "ui/base/ui_base_switches.h" |
28 #include "ui/events/event_processor.h" | 26 #include "ui/events/event_processor.h" |
29 #include "ui/events/event_utils.h" | 27 #include "ui/events/event_utils.h" |
30 #include "ui/events/test/event_generator.h" | 28 #include "ui/events/test/event_generator.h" |
31 #include "ui/views/controls/textfield/textfield_test_api.h" | 29 #include "ui/views/controls/textfield/textfield_test_api.h" |
32 | 30 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 | 64 |
67 if (press_location != release_location) | 65 if (press_location != release_location) |
68 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(release_location)); | 66 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(release_location)); |
69 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(button, ui_controls::UP)); | 67 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(button, ui_controls::UP)); |
70 } | 68 } |
71 | 69 |
72 // Tap the center of the browser window. | 70 // Tap the center of the browser window. |
73 void TapBrowserWindowCenter() { | 71 void TapBrowserWindowCenter() { |
74 gfx::Point center = BrowserView::GetBrowserViewForBrowser( | 72 gfx::Point center = BrowserView::GetBrowserViewForBrowser( |
75 browser())->GetBoundsInScreen().CenterPoint(); | 73 browser())->GetBoundsInScreen().CenterPoint(); |
76 ui::test::EventGenerator generator( | 74 ui::test::EventGenerator generator(browser()->window()->GetNativeWindow()); |
77 browser()->window()->GetNativeWindow()->GetRootWindow()); | |
tapted
2014/08/05 13:52:13
note that events are always sent via the window ho
| |
78 generator.GestureTapAt(center); | 75 generator.GestureTapAt(center); |
79 } | 76 } |
80 | 77 |
81 // Touch down and release at the specified locations. | 78 // Touch down and release at the specified locations. |
82 void Tap(const gfx::Point& press_location, | 79 void Tap(const gfx::Point& press_location, |
83 const gfx::Point& release_location) { | 80 const gfx::Point& release_location) { |
84 ui::EventProcessor* dispatcher = | 81 ui::test::EventGenerator generator(browser()->window()->GetNativeWindow()); |
85 browser()->window()->GetNativeWindow()->GetHost()->event_processor(); | 82 if (press_location == release_location) { |
86 | 83 generator.GestureTapAt(press_location); |
87 base::TimeDelta timestamp = ui::EventTimeForNow(); | 84 } else { |
88 ui::TouchEvent press( | 85 generator.GestureScrollSequence(press_location, |
89 ui::ET_TOUCH_PRESSED, press_location, 5, timestamp); | 86 release_location, |
90 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&press); | 87 base::TimeDelta::FromMilliseconds(10), |
91 ASSERT_FALSE(details.dispatcher_destroyed); | 88 1); |
tapted
2014/08/05 13:52:13
note there is a CHECK at EventGenerator::DoDispatc
| |
92 | |
93 if (press_location != release_location) { | |
94 timestamp += base::TimeDelta::FromMilliseconds(10); | |
95 ui::TouchEvent move( | |
96 ui::ET_TOUCH_MOVED, release_location, 5, timestamp); | |
97 details = dispatcher->OnEventFromSource(&move); | |
98 } | 89 } |
99 | |
100 timestamp += base::TimeDelta::FromMilliseconds(50); | |
101 ui::TouchEvent release( | |
102 ui::ET_TOUCH_RELEASED, release_location, 5, timestamp); | |
103 details = dispatcher->OnEventFromSource(&release); | |
104 ASSERT_FALSE(details.dispatcher_destroyed); | |
105 } | 90 } |
106 | 91 |
107 private: | 92 private: |
108 // InProcessBrowserTest: | 93 // InProcessBrowserTest: |
109 virtual void SetUpOnMainThread() OVERRIDE { | 94 virtual void SetUpOnMainThread() OVERRIDE { |
110 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 95 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
111 chrome::FocusLocationBar(browser()); | 96 chrome::FocusLocationBar(browser()); |
112 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 97 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
113 } | 98 } |
114 | 99 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 // TextInputFocusManager completes. | 334 // TextInputFocusManager completes. |
350 chrome::FocusLocationBar(browser()); | 335 chrome::FocusLocationBar(browser()); |
351 OmniboxView* view = NULL; | 336 OmniboxView* view = NULL; |
352 ASSERT_NO_FATAL_FAILURE(GetOmniboxViewForBrowser(browser(), &view)); | 337 ASSERT_NO_FATAL_FAILURE(GetOmniboxViewForBrowser(browser(), &view)); |
353 OmniboxViewViews* omnibox_view_views = static_cast<OmniboxViewViews*>(view); | 338 OmniboxViewViews* omnibox_view_views = static_cast<OmniboxViewViews*>(view); |
354 ui::TextInputFocusManager* text_input_focus_manager = | 339 ui::TextInputFocusManager* text_input_focus_manager = |
355 ui::TextInputFocusManager::GetInstance(); | 340 ui::TextInputFocusManager::GetInstance(); |
356 EXPECT_EQ(omnibox_view_views->GetTextInputClient(), | 341 EXPECT_EQ(omnibox_view_views->GetTextInputClient(), |
357 text_input_focus_manager->GetFocusedTextInputClient()); | 342 text_input_focus_manager->GetFocusedTextInputClient()); |
358 } | 343 } |
OLD | NEW |