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

Side by Side Diff: chrome/browser/automation/ui_controls_linux.cc

Issue 2986004: [Mac]Port browser_keyevents_browsertest.cc and browser_focus_uitest.cc to Mac. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Enable BrowserFocusTest and BrowserKeyEventsTests on Mac. Created 10 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/automation/ui_controls.h" 5 #include "chrome/browser/automation/ui_controls.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 9
10 #include "gfx/rect.h" 10 #include "gfx/rect.h"
11 #include "base/event_synthesis_gtk.h" 11 #include "base/event_synthesis_gtk.h"
12 #include "base/keyboard_code_conversion_gtk.h" 12 #include "base/keyboard_code_conversion_gtk.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "chrome/browser/automation/ui_controls_internal.h"
15 #include "chrome/browser/gtk/gtk_util.h" 16 #include "chrome/browser/gtk/gtk_util.h"
16 #include "chrome/test/automation/automation_constants.h" 17 #include "chrome/test/automation/automation_constants.h"
17 18
18 #if defined(TOOLKIT_VIEWS) 19 #if defined(TOOLKIT_VIEWS)
19 #include "views/view.h" 20 #include "views/view.h"
20 #include "views/widget/widget.h" 21 #include "views/widget/widget.h"
21 #endif 22 #endif
22 23
23 namespace { 24 namespace {
24 25
(...skipping 30 matching lines...) Expand all
55 56
56 private: 57 private:
57 // We pass ownership of task_ to MessageLoop when the current event is 58 // We pass ownership of task_ to MessageLoop when the current event is
58 // received. 59 // received.
59 Task* task_; 60 Task* task_;
60 GdkEventType type_; 61 GdkEventType type_;
61 // The number of events of this type to wait for. 62 // The number of events of this type to wait for.
62 int count_; 63 int count_;
63 }; 64 };
64 65
65 class ClickTask : public Task {
66 public:
67 ClickTask(ui_controls::MouseButton button, int state, Task* followup)
68 : button_(button), state_(state), followup_(followup) {
69 }
70
71 virtual ~ClickTask() {}
72
73 virtual void Run() {
74 if (followup_)
75 ui_controls::SendMouseEventsNotifyWhenDone(button_, state_, followup_);
76 else
77 ui_controls::SendMouseEvents(button_, state_);
78 }
79
80 private:
81 ui_controls::MouseButton button_;
82 int state_;
83 Task* followup_;
84 };
85
86 void FakeAMouseMotionEvent(gint x, gint y) { 66 void FakeAMouseMotionEvent(gint x, gint y) {
87 GdkEvent* event = gdk_event_new(GDK_MOTION_NOTIFY); 67 GdkEvent* event = gdk_event_new(GDK_MOTION_NOTIFY);
88 68
89 event->motion.send_event = false; 69 event->motion.send_event = false;
90 event->motion.time = gtk_util::XTimeNow(); 70 event->motion.time = gtk_util::XTimeNow();
91 71
92 GtkWidget* grab_widget = gtk_grab_get_current(); 72 GtkWidget* grab_widget = gtk_grab_get_current();
93 if (grab_widget) { 73 if (grab_widget) {
94 // If there is a grab, we need to target all events at it regardless of 74 // If there is a grab, we need to target all events at it regardless of
95 // what widget the mouse is over. 75 // what widget the mouse is over.
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 int state, 260 int state,
281 Task* task) { 261 Task* task) {
282 gfx::Rect bounds = gtk_util::GetWidgetScreenBounds(widget); 262 gfx::Rect bounds = gtk_util::GetWidgetScreenBounds(widget);
283 SendMouseMoveNotifyWhenDone(bounds.x() + bounds.width() / 2, 263 SendMouseMoveNotifyWhenDone(bounds.x() + bounds.width() / 2,
284 bounds.y() + bounds.height() / 2, 264 bounds.y() + bounds.height() / 2,
285 new ClickTask(button, state, task)); 265 new ClickTask(button, state, task));
286 } 266 }
287 #endif 267 #endif
288 268
289 } // namespace ui_controls 269 } // namespace ui_controls
OLDNEW
« no previous file with comments | « chrome/browser/automation/ui_controls_internal.h ('k') | chrome/browser/automation/ui_controls_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698