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" | 8 #include "build/build_config.h" |
9 | 9 |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
(...skipping 18 matching lines...) Expand all Loading... |
29 // window. Note that this object can be invalidated at any time if the | 29 // window. Note that this object can be invalidated at any time if the |
30 // corresponding window in the app is closed. In that case, any subsequent | 30 // corresponding window in the app is closed. In that case, any subsequent |
31 // calls will return false immediately. | 31 // calls will return false immediately. |
32 class WindowProxy : public AutomationResourceProxy { | 32 class WindowProxy : public AutomationResourceProxy { |
33 public: | 33 public: |
34 WindowProxy(AutomationMessageSender* sender, | 34 WindowProxy(AutomationMessageSender* sender, |
35 AutomationHandleTracker* tracker, | 35 AutomationHandleTracker* tracker, |
36 int handle) | 36 int handle) |
37 : AutomationResourceProxy(tracker, sender, handle) {} | 37 : AutomationResourceProxy(tracker, sender, handle) {} |
38 | 38 |
39 #if defined(OS_WIN) | |
40 // TODO(port): Use portable replacements for windowsisms. | |
41 | |
42 // Gets the outermost HWND that corresponds to the given window. | |
43 // Returns true if the call was successful. | |
44 bool GetHWND(HWND* handle) const; | |
45 #endif // defined(OS_WIN) | |
46 | |
47 // Simulates a click at the OS level. |click| is in the window's coordinates | 39 // Simulates a click at the OS level. |click| is in the window's coordinates |
48 // and |flags| specifies which buttons are pressed (as defined in | 40 // and |flags| specifies which buttons are pressed (as defined in |
49 // chrome/views/event.h). Note that this is equivalent to the user moving | 41 // chrome/views/event.h). Note that this is equivalent to the user moving |
50 // the mouse and pressing the button. So if there is a window on top of this | 42 // the mouse and pressing the button. So if there is a window on top of this |
51 // window, the top window is clicked. | 43 // window, the top window is clicked. |
52 bool SimulateOSClick(const gfx::Point& click, int flags); | 44 bool SimulateOSClick(const gfx::Point& click, int flags); |
53 | 45 |
54 // Get the title of the top level window. | 46 // Get the title of the top level window. |
55 bool GetWindowTitle(string16* text); | 47 bool GetWindowTitle(string16* text); |
56 | 48 |
57 // Simulates a key press at the OS level. |key| is the key pressed and | 49 // Simulates a key press at the OS level. |key| is the key pressed and |
58 // |flags| specifies which modifiers keys are also pressed (as defined in | 50 // |flags| specifies which modifiers keys are also pressed (as defined in |
59 // chrome/views/event.h). Note that this actually sends the event to the | 51 // chrome/views/event.h). Note that this actually sends the event to the |
60 // window that has focus. | 52 // window that has focus. |
61 bool SimulateOSKeyPress(wchar_t key, int flags); | 53 bool SimulateOSKeyPress(wchar_t key, int flags); |
62 | 54 |
63 // Shows/hides the window and as a result makes it active/inactive. | 55 // Shows/hides the window and as a result makes it active/inactive. |
64 // Returns true if the call was successful. | 56 // Returns true if the call was successful. |
65 bool SetVisible(bool visible); | 57 bool SetVisible(bool visible); |
66 | 58 |
67 // Sets |active| to true if this view is currently the active window. | 59 // Sets |active| to true if this view is currently the active window. |
68 // Returns true if the call was successful. | 60 // Returns true if the call was successful. |
69 bool IsActive(bool* active); | 61 bool IsActive(bool* active); |
70 | 62 |
71 // Make this window the active window. | 63 // Make this window the active window. |
72 // Returns true if the call was successful. | 64 // Returns true if the call was successful. |
73 bool Activate(); | 65 bool Activate(); |
74 | 66 |
| 67 // Sets |maximized| to true if this window is maximized. |
| 68 bool IsMaximized(bool* maximized); |
| 69 |
75 // Gets the bounds (in window coordinates) that correspond to the view with | 70 // Gets the bounds (in window coordinates) that correspond to the view with |
76 // the given ID in this window. Returns true if bounds could be obtained. | 71 // the given ID in this window. Returns true if bounds could be obtained. |
77 // If |screen_coordinates| is true, the bounds are returned in the coordinates | 72 // If |screen_coordinates| is true, the bounds are returned in the coordinates |
78 // of the screen, if false in the coordinates of the browser. | 73 // of the screen, if false in the coordinates of the browser. |
79 bool GetViewBounds(int view_id, gfx::Rect* bounds, bool screen_coordinates); | 74 bool GetViewBounds(int view_id, gfx::Rect* bounds, bool screen_coordinates); |
80 | 75 |
81 // Like GetViewBounds except returns false if timeout occurs before view | 76 // Like GetViewBounds except returns false if timeout occurs before view |
82 // bounds are obtained, and sets is_timeout accordingly. | 77 // bounds are obtained, and sets is_timeout accordingly. |
83 bool GetViewBoundsWithTimeout(int view_id, gfx::Rect* bounds, | 78 bool GetViewBoundsWithTimeout(int view_id, gfx::Rect* bounds, |
84 bool screen_coordinates, uint32 timeout_ms, | 79 bool screen_coordinates, uint32 timeout_ms, |
85 bool* is_timeout); | 80 bool* is_timeout); |
86 | 81 |
| 82 // Gets the position and size of the window. Returns true if setting the |
| 83 // bounds was successful. |
| 84 bool GetBounds(gfx::Rect* bounds); |
| 85 |
87 // Sets the position and size of the window. Returns true if setting the | 86 // Sets the position and size of the window. Returns true if setting the |
88 // bounds was successful. | 87 // bounds was successful. |
89 bool SetBounds(const gfx::Rect& bounds); | 88 bool SetBounds(const gfx::Rect& bounds); |
90 | 89 |
91 // Gets the id of the view that currently has focus. Returns true if the id | 90 // Gets the id of the view that currently has focus. Returns true if the id |
92 // was retrieved. | 91 // was retrieved. |
93 bool GetFocusedViewID(int* view_id); | 92 bool GetFocusedViewID(int* view_id); |
94 | 93 |
95 // Returns the browser this window corresponds to, or NULL if this window | 94 // Returns the browser this window corresponds to, or NULL if this window |
96 // is not a browser. The caller owns the returned BrowserProxy. | 95 // is not a browser. The caller owns the returned BrowserProxy. |
97 scoped_refptr<BrowserProxy> GetBrowser(); | 96 scoped_refptr<BrowserProxy> GetBrowser(); |
98 | 97 |
99 // Same as GetWindow except return NULL if response isn't received | 98 // Same as GetWindow except return NULL if response isn't received |
100 // before the specified timeout. | 99 // before the specified timeout. |
101 scoped_refptr<BrowserProxy> GetBrowserWithTimeout(uint32 timeout_ms, | 100 scoped_refptr<BrowserProxy> GetBrowserWithTimeout(uint32 timeout_ms, |
102 bool* is_timeout); | 101 bool* is_timeout); |
103 protected: | 102 protected: |
104 virtual ~WindowProxy() {} | 103 virtual ~WindowProxy() {} |
105 private: | 104 private: |
106 DISALLOW_COPY_AND_ASSIGN(WindowProxy); | 105 DISALLOW_COPY_AND_ASSIGN(WindowProxy); |
107 }; | 106 }; |
108 | 107 |
109 #endif // CHROME_TEST_AUTOMATION_WINDOW_PROXY_H__ | 108 #endif // CHROME_TEST_AUTOMATION_WINDOW_PROXY_H__ |
OLD | NEW |