OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/test/base/ui_test_utils.h" | 5 #include "chrome/test/base/ui_test_utils.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 DCHECK(browser_window); | 51 DCHECK(browser_window); |
52 gfx::NativeWindow window = browser_window->GetNativeWindow(); | 52 gfx::NativeWindow window = browser_window->GetNativeWindow(); |
53 DCHECK(window); | 53 DCHECK(window); |
54 GtkWidget* view = ViewIDUtil::GetWidget(GTK_WIDGET(window), vid); | 54 GtkWidget* view = ViewIDUtil::GetWidget(GTK_WIDGET(window), vid); |
55 DCHECK(view); | 55 DCHECK(view); |
56 MoveMouseToCenterAndPress( | 56 MoveMouseToCenterAndPress( |
57 view, | 57 view, |
58 ui_controls::LEFT, | 58 ui_controls::LEFT, |
59 ui_controls::DOWN | ui_controls::UP, | 59 ui_controls::DOWN | ui_controls::UP, |
60 MessageLoop::QuitClosure()); | 60 MessageLoop::QuitClosure()); |
61 RunMessageLoop(); | 61 content::RunMessageLoop(); |
62 } | 62 } |
63 | 63 |
64 void HideNativeWindow(gfx::NativeWindow window) { | 64 void HideNativeWindow(gfx::NativeWindow window) { |
65 gtk_widget_hide(GTK_WIDGET(window)); | 65 gtk_widget_hide(GTK_WIDGET(window)); |
66 } | 66 } |
67 | 67 |
68 bool ShowAndFocusNativeWindow(gfx::NativeWindow window) { | 68 bool ShowAndFocusNativeWindow(gfx::NativeWindow window) { |
69 if (!gtk_window_has_toplevel_focus(GTK_WINDOW(window))) | 69 if (!gtk_window_has_toplevel_focus(GTK_WINDOW(window))) |
70 gtk_window_present(GTK_WINDOW(window)); | 70 gtk_window_present(GTK_WINDOW(window)); |
71 return true; | 71 return true; |
72 } | 72 } |
73 | 73 |
74 void MoveMouseToCenterAndPress(GtkWidget* widget, | 74 void MoveMouseToCenterAndPress(GtkWidget* widget, |
75 ui_controls::MouseButton button, | 75 ui_controls::MouseButton button, |
76 int state, | 76 int state, |
77 const base::Closure& task) { | 77 const base::Closure& task) { |
78 gfx::Rect bounds = ui::GetWidgetScreenBounds(widget); | 78 gfx::Rect bounds = ui::GetWidgetScreenBounds(widget); |
79 ui_controls::SendMouseMoveNotifyWhenDone( | 79 ui_controls::SendMouseMoveNotifyWhenDone( |
80 bounds.x() + bounds.width() / 2, | 80 bounds.x() + bounds.width() / 2, |
81 bounds.y() + bounds.height() / 2, | 81 bounds.y() + bounds.height() / 2, |
82 base::Bind(&internal::ClickTask, button, state, task)); | 82 base::Bind(&internal::ClickTask, button, state, task)); |
83 } | 83 } |
84 | 84 |
85 } // namespace ui_test_utils | 85 } // namespace ui_test_utils |
OLD | NEW |