OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_FRAME_TEST_AUTOMATION_CLIENT_MOCK_H_ | 5 #ifndef CHROME_FRAME_TEST_AUTOMATION_CLIENT_MOCK_H_ |
5 #define CHROME_FRAME_TEST_AUTOMATION_CLIENT_MOCK_H_ | 6 #define CHROME_FRAME_TEST_AUTOMATION_CLIENT_MOCK_H_ |
6 | 7 |
7 #include <windows.h> | 8 #include <windows.h> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "chrome_frame/chrome_frame_automation.h" | 11 #include "chrome_frame/chrome_frame_automation.h" |
11 #include "chrome_frame/test/chrome_frame_test_utils.h" | 12 #include "chrome_frame/test/chrome_frame_test_utils.h" |
12 #include "chrome_frame/test/proxy_factory_mock.h" | 13 #include "chrome_frame/test/proxy_factory_mock.h" |
13 #include "gmock/gmock.h" | 14 #include "gmock/gmock.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 MOCK_METHOD3(OnMessageFromChromeFrame, void( | 47 MOCK_METHOD3(OnMessageFromChromeFrame, void( |
47 const std::string& message, | 48 const std::string& message, |
48 const std::string& origin, | 49 const std::string& origin, |
49 const std::string& target)); | 50 const std::string& target)); |
50 MOCK_METHOD3(OnHandleContextMenu, void(HANDLE menu_handle, | 51 MOCK_METHOD3(OnHandleContextMenu, void(HANDLE menu_handle, |
51 int align_flags, const MiniContextMenuParams& params)); | 52 int align_flags, const MiniContextMenuParams& params)); |
52 MOCK_METHOD2(OnRequestStart, void(int request_id, | 53 MOCK_METHOD2(OnRequestStart, void(int request_id, |
53 const AutomationURLRequest& request)); | 54 const AutomationURLRequest& request)); |
54 MOCK_METHOD2(OnRequestRead, void(int request_id, int bytes_to_read)); | 55 MOCK_METHOD2(OnRequestRead, void(int request_id, int bytes_to_read)); |
55 MOCK_METHOD2(OnRequestEnd, void(int request_id, | 56 MOCK_METHOD2(OnRequestEnd, void(int request_id, |
56 const URLRequestStatus& status)); | 57 const net::URLRequestStatus& status)); |
57 MOCK_METHOD2(OnSetCookieAsync, void(const GURL& url, | 58 MOCK_METHOD2(OnSetCookieAsync, void(const GURL& url, |
58 const std::string& cookie)); | 59 const std::string& cookie)); |
59 | 60 |
60 // Use for sending network responses | 61 // Use for sending network responses |
61 void SetRequestDelegate(PluginUrlRequestDelegate* request_delegate) { | 62 void SetRequestDelegate(PluginUrlRequestDelegate* request_delegate) { |
62 request_delegate_ = request_delegate; | 63 request_delegate_ = request_delegate; |
63 } | 64 } |
64 | 65 |
65 void ReplyStarted(int request_id, const char* headers) { | 66 void ReplyStarted(int request_id, const char* headers) { |
66 request_delegate_->OnResponseStarted(request_id, "text/html", headers, | 67 request_delegate_->OnResponseStarted(request_id, "text/html", headers, |
67 0, base::Time::Now(), EmptyString(), 0); | 68 0, base::Time::Now(), EmptyString(), 0); |
68 } | 69 } |
69 | 70 |
70 void ReplyData(int request_id, const std::string* data) { | 71 void ReplyData(int request_id, const std::string* data) { |
71 request_delegate_->OnReadComplete(request_id, *data); | 72 request_delegate_->OnReadComplete(request_id, *data); |
72 } | 73 } |
73 | 74 |
74 void Reply(const URLRequestStatus& status, int request_id) { | 75 void Reply(const net::URLRequestStatus& status, int request_id) { |
75 request_delegate_->OnResponseEnd(request_id, status); | 76 request_delegate_->OnResponseEnd(request_id, status); |
76 } | 77 } |
77 | 78 |
78 void Reply404(int request_id) { | 79 void Reply404(int request_id) { |
79 ReplyStarted(request_id, "HTTP/1.1 404\r\n\r\n"); | 80 ReplyStarted(request_id, "HTTP/1.1 404\r\n\r\n"); |
80 Reply(URLRequestStatus(), request_id); | 81 Reply(net::URLRequestStatus(), request_id); |
81 } | 82 } |
82 | 83 |
83 PluginUrlRequestDelegate* request_delegate_; | 84 PluginUrlRequestDelegate* request_delegate_; |
84 }; | 85 }; |
85 | 86 |
86 class MockAutomationProxy : public ChromeFrameAutomationProxy { | 87 class MockAutomationProxy : public ChromeFrameAutomationProxy { |
87 public: | 88 public: |
88 MOCK_METHOD1(Send, bool(IPC::Message*)); | 89 MOCK_METHOD1(Send, bool(IPC::Message*)); |
89 MOCK_METHOD3(SendAsAsync, | 90 MOCK_METHOD3(SendAsAsync, |
90 void(IPC::SyncMessage* msg, | 91 void(IPC::SyncMessage* msg, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 174 |
174 virtual void SetUp() { | 175 virtual void SetUp() { |
175 dummy_sender_.ForwardTo(&mock_proxy_); | 176 dummy_sender_.ForwardTo(&mock_proxy_); |
176 tracker_.reset(new AutomationHandleTracker()); | 177 tracker_.reset(new AutomationHandleTracker()); |
177 | 178 |
178 client_ = new ChromeFrameAutomationClient; | 179 client_ = new ChromeFrameAutomationClient; |
179 client_->set_proxy_factory(&factory_); | 180 client_->set_proxy_factory(&factory_); |
180 } | 181 } |
181 }; | 182 }; |
182 | 183 |
183 | |
184 #endif // CHROME_FRAME_TEST_AUTOMATION_CLIENT_MOCK_H_ | 184 #endif // CHROME_FRAME_TEST_AUTOMATION_CLIENT_MOCK_H_ |
185 | |
OLD | NEW |