| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_AUTOMATION_WINDOW_PROXY_H__ | 5 #ifndef CHROME_TEST_AUTOMATION_WINDOW_PROXY_H__ |
| 6 #define CHROME_TEST_AUTOMATION_WINDOW_PROXY_H__ | 6 #define CHROME_TEST_AUTOMATION_WINDOW_PROXY_H__ |
| 7 | 7 |
| 8 #include "build/build_config.h" |
| 9 |
| 10 #if defined(OS_WIN) |
| 11 #include <windows.h> |
| 12 #endif |
| 13 |
| 8 #include <string> | 14 #include <string> |
| 9 | 15 |
| 10 #include <windows.h> | |
| 11 | |
| 12 #include "base/thread.h" | 16 #include "base/thread.h" |
| 13 #include "chrome/test/automation/automation_handle_tracker.h" | 17 #include "chrome/test/automation/automation_handle_tracker.h" |
| 14 | 18 |
| 15 class BrowserProxy; | 19 class BrowserProxy; |
| 16 class WindowProxy; | 20 class WindowProxy; |
| 17 | 21 |
| 18 namespace gfx { | 22 namespace gfx { |
| 19 class Rect; | 23 class Rect; |
| 20 } | 24 } |
| 21 | 25 |
| 22 // This class presents the interface to actions that can be performed on a given | 26 // This class presents the interface to actions that can be performed on a given |
| 23 // window. Note that this object can be invalidated at any time if the | 27 // window. Note that this object can be invalidated at any time if the |
| 24 // corresponding window in the app is closed. In that case, any subsequent | 28 // corresponding window in the app is closed. In that case, any subsequent |
| 25 // calls will return false immediately. | 29 // calls will return false immediately. |
| 26 class WindowProxy : public AutomationResourceProxy { | 30 class WindowProxy : public AutomationResourceProxy { |
| 27 public: | 31 public: |
| 28 WindowProxy(AutomationMessageSender* sender, | 32 WindowProxy(AutomationMessageSender* sender, |
| 29 AutomationHandleTracker* tracker, | 33 AutomationHandleTracker* tracker, |
| 30 int handle) | 34 int handle) |
| 31 : AutomationResourceProxy(tracker, sender, handle) {} | 35 : AutomationResourceProxy(tracker, sender, handle) {} |
| 32 virtual ~WindowProxy() {} | 36 virtual ~WindowProxy() {} |
| 33 | 37 |
| 38 #if defined(OS_WIN) |
| 39 // TODO(port): Use portable replacements for windowsisms. |
| 40 |
| 34 // Gets the outermost HWND that corresponds to the given window. | 41 // Gets the outermost HWND that corresponds to the given window. |
| 35 // Returns true if the call was successful. | 42 // Returns true if the call was successful. |
| 36 bool GetHWND(HWND* handle) const; | 43 bool GetHWND(HWND* handle) const; |
| 37 | 44 |
| 38 // Simulates a click at the OS level. |click| is in the window's coordinates | 45 // Simulates a click at the OS level. |click| is in the window's coordinates |
| 39 // and |flags| specifies which buttons are pressed (as defined in | 46 // and |flags| specifies which buttons are pressed (as defined in |
| 40 // chrome/views/event.h). Note that this is equivalent to the user moving | 47 // chrome/views/event.h). Note that this is equivalent to the user moving |
| 41 // the mouse and pressing the button. So if there is a window on top of this | 48 // the mouse and pressing the button. So if there is a window on top of this |
| 42 // window, the top window is clicked. | 49 // window, the top window is clicked. |
| 43 bool SimulateOSClick(const POINT& click, int flags); | 50 bool SimulateOSClick(const POINT& click, int flags); |
| 51 #endif // defined(OS_WIN) |
| 44 | 52 |
| 45 // Simulates a key press at the OS level. |key| is the key pressed and | 53 // Simulates a key press at the OS level. |key| is the key pressed and |
| 46 // |flags| specifies which modifiers keys are also pressed (as defined in | 54 // |flags| specifies which modifiers keys are also pressed (as defined in |
| 47 // chrome/views/event.h). Note that this actually sends the event to the | 55 // chrome/views/event.h). Note that this actually sends the event to the |
| 48 // window that has focus. | 56 // window that has focus. |
| 49 bool SimulateOSKeyPress(wchar_t key, int flags); | 57 bool SimulateOSKeyPress(wchar_t key, int flags); |
| 50 | 58 |
| 51 // Shows/hides the window and as a result makes it active/inactive. | 59 // Shows/hides the window and as a result makes it active/inactive. |
| 52 // Returns true if the call was successful. | 60 // Returns true if the call was successful. |
| 53 bool SetVisible(bool visible); | 61 bool SetVisible(bool visible); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 81 | 89 |
| 82 // Same as GetWindow except return NULL if response isn't received | 90 // Same as GetWindow except return NULL if response isn't received |
| 83 // before the specified timeout. | 91 // before the specified timeout. |
| 84 BrowserProxy* GetBrowserWithTimeout(uint32 timeout_ms, bool* is_timeout); | 92 BrowserProxy* GetBrowserWithTimeout(uint32 timeout_ms, bool* is_timeout); |
| 85 | 93 |
| 86 private: | 94 private: |
| 87 DISALLOW_COPY_AND_ASSIGN(WindowProxy); | 95 DISALLOW_COPY_AND_ASSIGN(WindowProxy); |
| 88 }; | 96 }; |
| 89 | 97 |
| 90 #endif // CHROME_TEST_AUTOMATION_WINDOW_PROXY_H__ | 98 #endif // CHROME_TEST_AUTOMATION_WINDOW_PROXY_H__ |
| OLD | NEW |