| 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 #ifndef CHROME_TEST_BASE_UI_TEST_UTILS_H_ | 5 #ifndef CHROME_TEST_BASE_UI_TEST_UTILS_H_ |
| 6 #define CHROME_TEST_BASE_UI_TEST_UTILS_H_ | 6 #define CHROME_TEST_BASE_UI_TEST_UTILS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <queue> | 10 #include <queue> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 17 #include "base/process.h" | 17 #include "base/process.h" |
| 18 #include "base/scoped_temp_dir.h" | 18 #include "base/scoped_temp_dir.h" |
| 19 #include "base/string16.h" | 19 #include "base/string16.h" |
| 20 #include "chrome/browser/automation/ui_controls.h" | |
| 21 #include "chrome/browser/ui/view_ids.h" | 20 #include "chrome/browser/ui/view_ids.h" |
| 22 #include "chrome/test/automation/dom_element_proxy.h" | 21 #include "chrome/test/automation/dom_element_proxy.h" |
| 23 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
| 25 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
| 26 #include "content/public/browser/notification_details.h" | 25 #include "content/public/browser/notification_details.h" |
| 27 #include "content/public/browser/notification_source.h" | 26 #include "content/public/browser/notification_source.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "ui/base/keycodes/keyboard_codes.h" | 28 #include "ui/base/keycodes/keyboard_codes.h" |
| 30 #include "ui/gfx/native_widget_types.h" | 29 #include "ui/gfx/native_widget_types.h" |
| 30 #include "ui/ui_controls/ui_controls.h" |
| 31 #include "webkit/glue/window_open_disposition.h" | 31 #include "webkit/glue/window_open_disposition.h" |
| 32 | 32 |
| 33 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
| 34 #include "base/win/scoped_handle.h" | 34 #include "base/win/scoped_handle.h" |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 #if defined(TOOLKIT_VIEWS) |
| 38 #include "ui/views/view.h" |
| 39 #endif |
| 40 |
| 37 class AppModalDialog; | 41 class AppModalDialog; |
| 38 class BookmarkModel; | 42 class BookmarkModel; |
| 39 class Browser; | 43 class Browser; |
| 40 class CommandLine; | 44 class CommandLine; |
| 41 class ExtensionAction; | 45 class ExtensionAction; |
| 42 class FilePath; | 46 class FilePath; |
| 43 class GURL; | 47 class GURL; |
| 44 class MessageLoop; | 48 class MessageLoop; |
| 45 class Profile; | 49 class Profile; |
| 46 class ScopedTempDir; | 50 class ScopedTempDir; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 ui::KeyboardCode key, | 265 ui::KeyboardCode key, |
| 262 bool control, | 266 bool control, |
| 263 bool shift, | 267 bool shift, |
| 264 bool alt, | 268 bool alt, |
| 265 bool command, | 269 bool command, |
| 266 int type, | 270 int type, |
| 267 const content::NotificationSource& source) | 271 const content::NotificationSource& source) |
| 268 WARN_UNUSED_RESULT; | 272 WARN_UNUSED_RESULT; |
| 269 | 273 |
| 270 // Sends a move event blocking until received. Returns true if the event was | 274 // Sends a move event blocking until received. Returns true if the event was |
| 271 // successfully received. This uses ui_controls::SendMouse***NotifyWhenDone, see | 275 // successfully received. This uses ui_controls::SendMouse***NotifyWhenDone, |
| 272 // it for details. | 276 // see it for details. |
| 273 bool SendMouseMoveSync(const gfx::Point& location) WARN_UNUSED_RESULT; | 277 bool SendMouseMoveSync(const gfx::Point& location) WARN_UNUSED_RESULT; |
| 274 bool SendMouseEventsSync(ui_controls::MouseButton type, | 278 bool SendMouseEventsSync(ui_controls::MouseButton type, |
| 275 int state) WARN_UNUSED_RESULT; | 279 int state) WARN_UNUSED_RESULT; |
| 276 | 280 |
| 277 // Run a message loop only for the specified amount of time. | 281 // Run a message loop only for the specified amount of time. |
| 278 class TimedMessageLoopRunner { | 282 class TimedMessageLoopRunner { |
| 279 public: | 283 public: |
| 280 // Create new MessageLoopForUI and attach to it. | 284 // Create new MessageLoopForUI and attach to it. |
| 281 TimedMessageLoopRunner(); | 285 TimedMessageLoopRunner(); |
| 282 | 286 |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 bool TakeRenderWidgetSnapshot(content::RenderWidgetHost* rwh, | 584 bool TakeRenderWidgetSnapshot(content::RenderWidgetHost* rwh, |
| 581 const gfx::Size& page_size, | 585 const gfx::Size& page_size, |
| 582 SkBitmap* bitmap) WARN_UNUSED_RESULT; | 586 SkBitmap* bitmap) WARN_UNUSED_RESULT; |
| 583 | 587 |
| 584 // Takes a snapshot of the entire page, according to the width and height | 588 // Takes a snapshot of the entire page, according to the width and height |
| 585 // properties of the DOM's document. Returns true on success. DOMAutomation | 589 // properties of the DOM's document. Returns true on success. DOMAutomation |
| 586 // must be enabled. | 590 // must be enabled. |
| 587 bool TakeEntirePageSnapshot(content::RenderViewHost* rvh, | 591 bool TakeEntirePageSnapshot(content::RenderViewHost* rvh, |
| 588 SkBitmap* bitmap) WARN_UNUSED_RESULT; | 592 SkBitmap* bitmap) WARN_UNUSED_RESULT; |
| 589 | 593 |
| 594 // A combination of SendMouseMove to the middle of the view followed by |
| 595 // SendMouseEvents. |
| 596 void MoveMouseToCenterAndPress( |
| 597 #if defined(TOOLKIT_VIEWS) |
| 598 views::View* view, |
| 599 #elif defined(TOOLKIT_GTK) |
| 600 GtkWidget* widget, |
| 601 #elif defined(OS_MACOSX) |
| 602 NSView* view, |
| 603 #endif |
| 604 ui_controls::MouseButton button, |
| 605 int state, |
| 606 const base::Closure& task); |
| 607 |
| 608 namespace internal { |
| 609 |
| 610 // A utility function to send a mouse click event in a closure. It's shared by |
| 611 // ui_controls_linux.cc and ui_controls_mac.cc |
| 612 void ClickTask(ui_controls::MouseButton button, |
| 613 int state, |
| 614 const base::Closure& followup); |
| 615 |
| 616 } // namespace internal |
| 617 |
| 590 } // namespace ui_test_utils | 618 } // namespace ui_test_utils |
| 591 | 619 |
| 592 #endif // CHROME_TEST_BASE_UI_TEST_UTILS_H_ | 620 #endif // CHROME_TEST_BASE_UI_TEST_UTILS_H_ |
| OLD | NEW |