OLD | NEW |
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 #ifndef CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_UITEST_H_ | 5 #ifndef CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_UITEST_H_ |
6 #define CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_UITEST_H_ | 6 #define CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_UITEST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 // Used to implement external tab UI tests. | 31 // Used to implement external tab UI tests. |
32 // | 32 // |
33 // We have to derive from AutomationProxy in order to hook up | 33 // We have to derive from AutomationProxy in order to hook up |
34 // OnMessageReceived callbacks. | 34 // OnMessageReceived callbacks. |
35 class ExternalTabUITestMockClient : public AutomationProxy { | 35 class ExternalTabUITestMockClient : public AutomationProxy { |
36 public: | 36 public: |
37 explicit ExternalTabUITestMockClient(int execution_timeout); | 37 explicit ExternalTabUITestMockClient(int execution_timeout); |
38 virtual ~ExternalTabUITestMockClient(); | 38 virtual ~ExternalTabUITestMockClient(); |
39 | 39 |
40 MOCK_METHOD2(OnDidNavigate, void(int tab_handle, | 40 MOCK_METHOD1(OnDidNavigate, void(const NavigationInfo& nav_info)); |
41 const IPC::NavigationInfo& nav_info)); | 41 MOCK_METHOD3(OnForwardMessageToExternalHost, void( |
42 MOCK_METHOD4(OnForwardMessageToExternalHost, void(int handle, | |
43 const std::string& message, const std::string& origin, | 42 const std::string& message, const std::string& origin, |
44 const std::string& target)); | 43 const std::string& target)); |
45 MOCK_METHOD3(OnRequestStart, void(int tab_handle, int request_id, | 44 MOCK_METHOD2(OnRequestStart, void(int request_id, |
46 const IPC::AutomationURLRequest& request)); | 45 const AutomationURLRequest& request)); |
47 MOCK_METHOD3(OnRequestRead, void(int tab_handle, int request_id, | 46 MOCK_METHOD2(OnRequestRead, void(int request_id, |
48 int bytes_to_read)); | 47 int bytes_to_read)); |
49 MOCK_METHOD3(OnRequestEnd, void(int tab_handle, int request_id, | 48 MOCK_METHOD2(OnRequestEnd, void(int request_id, |
50 const URLRequestStatus& status)); | 49 const URLRequestStatus& status)); |
51 MOCK_METHOD3(OnSetCookieAsync, void(int tab_handle, const GURL& url, | 50 MOCK_METHOD2(OnSetCookieAsync, void(const GURL& url, |
52 const std::string& cookie)); | 51 const std::string& cookie)); |
53 MOCK_METHOD1(HandleClosed, void(int handle)); | 52 MOCK_METHOD1(HandleClosed, void(int handle)); |
54 | 53 |
55 | 54 |
56 MOCK_METHOD4(OnOpenURL, void(int tab_handle, const GURL& url, | 55 MOCK_METHOD3(OnOpenURL, void(const GURL& url, |
57 const GURL& referrer, int open_disposition)); | 56 const GURL& referrer, int open_disposition)); |
58 MOCK_METHOD3(OnNavigationStateChanged, void(int tab_handle, int flags, | 57 MOCK_METHOD2(OnNavigationStateChanged, void(int flags, |
59 const IPC::NavigationInfo& nav_info)); | 58 const NavigationInfo& nav_info)); |
60 MOCK_METHOD2(OnAttachExternalTab, void(int tab_handle, | 59 MOCK_METHOD1(OnAttachExternalTab, void( |
61 const IPC::AttachExternalTabParams& params)); | 60 const AttachExternalTabParams& params)); |
62 MOCK_METHOD2(OnLoad, void(int tab_handle, const GURL&url)); | 61 MOCK_METHOD1(OnLoad, void(const GURL&url)); |
63 | 62 |
64 | 63 |
65 // Action helpers for OnRequest* incoming messages. Create the message and | 64 // Action helpers for OnRequest* incoming messages. Create the message and |
66 // delegate sending to the base class. Apparently we do not have wrappers | 65 // delegate sending to the base class. Apparently we do not have wrappers |
67 // in AutomationProxy for these messages. | 66 // in AutomationProxy for these messages. |
68 void ReplyStarted(const IPC::AutomationURLResponse* response, | 67 void ReplyStarted(const AutomationURLResponse* response, |
69 int tab_handle, int request_id); | 68 int tab_handle, int request_id); |
70 void ReplyData(const std::string* data, int tab_handle, int request_id); | 69 void ReplyData(const std::string* data, int tab_handle, int request_id); |
71 void ReplyEOF(int tab_handle, int request_id); | 70 void ReplyEOF(int tab_handle, int request_id); |
72 void ReplyEnd(const URLRequestStatus& status, int tab_handle, int request_id); | 71 void ReplyEnd(const URLRequestStatus& status, int tab_handle, int request_id); |
73 void Reply404(int tab_handle, int request_id); | 72 void Reply404(int tab_handle, int request_id); |
74 | 73 |
75 // Test setup helpers | 74 // Test setup helpers |
76 scoped_refptr<TabProxy> CreateHostWindowAndTab( | 75 scoped_refptr<TabProxy> CreateHostWindowAndTab( |
77 const IPC::ExternalTabSettings& settings); | 76 const ExternalTabSettings& settings); |
78 scoped_refptr<TabProxy> CreateTabWithUrl(const GURL& initial_url); | 77 scoped_refptr<TabProxy> CreateTabWithUrl(const GURL& initial_url); |
79 void NavigateInExternalTab(int tab_handle, const GURL& url, | 78 void NavigateInExternalTab(int tab_handle, const GURL& url, |
80 const GURL& referrer = GURL()); | 79 const GURL& referrer = GURL()); |
81 | 80 |
82 // Navigation using keyboard (TAB + Enter) inside the page. | 81 // Navigation using keyboard (TAB + Enter) inside the page. |
83 void NavigateThroughUserGesture(); | 82 void NavigateThroughUserGesture(); |
84 void IgnoreFavIconNetworkRequest(); | 83 void IgnoreFavIconNetworkRequest(); |
85 | 84 |
86 void ConnectToExternalTab(gfx::NativeWindow parent, | 85 void ConnectToExternalTab(gfx::NativeWindow parent, |
87 const IPC::AttachExternalTabParams& attach_params); | 86 const AttachExternalTabParams& attach_params); |
88 // Helper for network requests. | 87 // Helper for network requests. |
89 void ServeHTMLData(int tab_handle, const GURL& url, const std::string& data); | 88 void ServeHTMLData(int tab_handle, const GURL& url, const std::string& data); |
90 // Destroys the host window. | 89 // Destroys the host window. |
91 void DestroyHostWindow(); | 90 void DestroyHostWindow(); |
92 // Returns true if the host window exists. | 91 // Returns true if the host window exists. |
93 bool HostWindowExists(); | 92 bool HostWindowExists(); |
94 // It's overlapped and visible by default. For Incognito mode test though we | 93 // It's overlapped and visible by default. For Incognito mode test though we |
95 // want invisible window since SetCookie is a sync call and a deadlock is | 94 // want invisible window since SetCookie is a sync call and a deadlock is |
96 // very possible. | 95 // very possible. |
97 unsigned long host_window_style_; | 96 unsigned long host_window_style_; |
98 | 97 |
99 static const IPC::AutomationURLResponse http_200; | 98 static const AutomationURLResponse http_200; |
100 static const IPC::ExternalTabSettings default_settings; | 99 static const ExternalTabSettings default_settings; |
101 protected: | 100 protected: |
102 gfx::NativeWindow host_window_; | 101 gfx::NativeWindow host_window_; |
103 | 102 |
104 // Simple dispatcher to above OnXXX methods. | 103 // Simple dispatcher to above OnXXX methods. |
105 virtual void OnMessageReceived(const IPC::Message& msg); | 104 virtual void OnMessageReceived(const IPC::Message& msg); |
106 virtual void InvalidateHandle(const IPC::Message& message); | 105 virtual void InvalidateHandle(const IPC::Message& message); |
107 }; | 106 }; |
108 | 107 |
109 // Base your external tab UI tests on this. | 108 // Base your external tab UI tests on this. |
110 class ExternalTabUITest : public UITest { | 109 class ExternalTabUITest : public UITest { |
111 public: | 110 public: |
112 ExternalTabUITest() : UITest(MessageLoop::TYPE_UI) {} | 111 ExternalTabUITest() : UITest(MessageLoop::TYPE_UI) {} |
113 // Override UITest's CreateAutomationProxy to provide the unit test | 112 // Override UITest's CreateAutomationProxy to provide the unit test |
114 // with our special implementation of AutomationProxy. | 113 // with our special implementation of AutomationProxy. |
115 // This function is called from within UITest::LaunchBrowserAndServer. | 114 // This function is called from within UITest::LaunchBrowserAndServer. |
116 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); | 115 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); |
117 protected: | 116 protected: |
118 // Filtered Inet will override automation callbacks for network resources. | 117 // Filtered Inet will override automation callbacks for network resources. |
119 virtual bool ShouldFilterInet() { | 118 virtual bool ShouldFilterInet() { |
120 return false; | 119 return false; |
121 } | 120 } |
122 ExternalTabUITestMockClient* mock_; | 121 ExternalTabUITestMockClient* mock_; |
123 }; | 122 }; |
124 | 123 |
125 #endif // CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_UITEST_H_ | 124 #endif // CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_UITEST_H_ |
OLD | NEW |