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 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 }; | 195 }; |
196 | 196 |
197 namespace { | 197 namespace { |
198 | 198 |
199 // RenderWidgetHostProcess ----------------------------------------------------- | 199 // RenderWidgetHostProcess ----------------------------------------------------- |
200 | 200 |
201 class RenderWidgetHostProcess : public MockRenderProcessHost { | 201 class RenderWidgetHostProcess : public MockRenderProcessHost { |
202 public: | 202 public: |
203 explicit RenderWidgetHostProcess(BrowserContext* browser_context) | 203 explicit RenderWidgetHostProcess(BrowserContext* browser_context) |
204 : MockRenderProcessHost(browser_context), | 204 : MockRenderProcessHost(browser_context), |
205 update_msg_should_reply_(false), | |
206 update_msg_reply_flags_(0) { | 205 update_msg_reply_flags_(0) { |
207 } | 206 } |
208 virtual ~RenderWidgetHostProcess() { | 207 virtual ~RenderWidgetHostProcess() { |
209 } | 208 } |
210 | 209 |
211 void set_update_msg_should_reply(bool reply) { | |
212 update_msg_should_reply_ = reply; | |
213 } | |
214 void set_update_msg_reply_flags(int flags) { | 210 void set_update_msg_reply_flags(int flags) { |
215 update_msg_reply_flags_ = flags; | 211 update_msg_reply_flags_ = flags; |
216 } | 212 } |
217 | 213 |
218 // Fills the given update parameters with resonable default values. | 214 // Fills the given update parameters with resonable default values. |
219 void InitUpdateRectParams(ViewHostMsg_UpdateRect_Params* params); | 215 void InitUpdateRectParams(ViewHostMsg_UpdateRect_Params* params); |
220 | 216 |
221 virtual bool HasConnection() const OVERRIDE { return true; } | 217 virtual bool HasConnection() const OVERRIDE { return true; } |
222 | 218 |
223 protected: | 219 protected: |
224 virtual bool WaitForBackingStoreMsg(int render_widget_id, | |
225 const base::TimeDelta& max_delay, | |
226 IPC::Message* msg) OVERRIDE; | |
227 | |
228 // Set to true when WaitForBackingStoreMsg should return a successful update | |
229 // message reply. False implies timeout. | |
230 bool update_msg_should_reply_; | |
231 | |
232 // Indicates the flags that should be sent with a repaint request. This | 220 // Indicates the flags that should be sent with a repaint request. This |
233 // only has an effect when update_msg_should_reply_ is true. | 221 // only has an effect when update_msg_should_reply_ is true. |
234 int update_msg_reply_flags_; | 222 int update_msg_reply_flags_; |
235 | 223 |
236 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostProcess); | 224 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostProcess); |
237 }; | 225 }; |
238 | 226 |
239 void RenderWidgetHostProcess::InitUpdateRectParams( | 227 void RenderWidgetHostProcess::InitUpdateRectParams( |
240 ViewHostMsg_UpdateRect_Params* params) { | 228 ViewHostMsg_UpdateRect_Params* params) { |
241 const int w = 100, h = 100; | 229 const int w = 100, h = 100; |
242 | 230 |
243 params->view_size = gfx::Size(w, h); | 231 params->view_size = gfx::Size(w, h); |
244 params->flags = update_msg_reply_flags_; | 232 params->flags = update_msg_reply_flags_; |
245 } | 233 } |
246 | 234 |
247 bool RenderWidgetHostProcess::WaitForBackingStoreMsg( | |
248 int render_widget_id, | |
249 const base::TimeDelta& max_delay, | |
250 IPC::Message* msg) { | |
251 if (!update_msg_should_reply_) | |
252 return false; | |
253 | |
254 // Construct a fake update reply. | |
255 ViewHostMsg_UpdateRect_Params params; | |
256 InitUpdateRectParams(¶ms); | |
257 | |
258 ViewHostMsg_UpdateRect message(render_widget_id, params); | |
259 *msg = message; | |
260 return true; | |
261 } | |
262 | |
263 // TestView -------------------------------------------------------------------- | 235 // TestView -------------------------------------------------------------------- |
264 | 236 |
265 // This test view allows us to specify the size, and keep track of acked | 237 // This test view allows us to specify the size, and keep track of acked |
266 // touch-events. | 238 // touch-events. |
267 class TestView : public TestRenderWidgetHostView { | 239 class TestView : public TestRenderWidgetHostView { |
268 public: | 240 public: |
269 explicit TestView(RenderWidgetHostImpl* rwh) | 241 explicit TestView(RenderWidgetHostImpl* rwh) |
270 : TestRenderWidgetHostView(rwh), | 242 : TestRenderWidgetHostView(rwh), |
271 unhandled_wheel_event_count_(0), | 243 unhandled_wheel_event_count_(0), |
272 acked_event_count_(0), | 244 acked_event_count_(0), |
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 | 1393 |
1422 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). | 1394 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). |
1423 PressTouchPoint(0, 1); | 1395 PressTouchPoint(0, 1); |
1424 SendTouchEvent(); | 1396 SendTouchEvent(); |
1425 CheckLatencyInfoComponentInMessage( | 1397 CheckLatencyInfoComponentInMessage( |
1426 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); | 1398 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); |
1427 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); | 1399 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); |
1428 } | 1400 } |
1429 | 1401 |
1430 } // namespace content | 1402 } // namespace content |
OLD | NEW |