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/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
8 #include "base/timer.h" | 8 #include "base/timer.h" |
9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
10 #include "content/browser/renderer_host/backing_store.h" | 10 #include "content/browser/renderer_host/backing_store.h" |
11 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 11 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
12 #include "content/browser/renderer_host/gesture_event_filter.h" | 12 #include "content/browser/renderer_host/gesture_event_filter.h" |
13 #include "content/browser/renderer_host/test_render_view_host.h" | 13 #include "content/browser/renderer_host/test_render_view_host.h" |
14 #include "content/browser/renderer_host/touch_event_queue.h" | 14 #include "content/browser/renderer_host/touch_event_queue.h" |
15 #include "content/common/view_messages.h" | 15 #include "content/common/view_messages.h" |
16 #include "content/port/browser/render_widget_host_view_port.h" | 16 #include "content/port/browser/render_widget_host_view_port.h" |
17 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
20 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
21 #include "content/public/browser/notification_types.h" | 21 #include "content/public/browser/notification_types.h" |
22 #include "content/public/test/mock_render_process_host.h" | 22 #include "content/public/test/mock_render_process_host.h" |
23 #include "content/public/test/test_browser_context.h" | 23 #include "content/public/test/test_browser_context.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "ui/base/keycodes/keyboard_codes.h" | 25 #include "ui/base/keycodes/keyboard_codes.h" |
26 #include "ui/gfx/canvas.h" | 26 #include "ui/gfx/canvas.h" |
| 27 #include "ui/gfx/screen.h" |
27 | 28 |
28 #if defined(USE_AURA) | 29 #if defined(USE_AURA) |
29 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 30 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
30 #include "ui/aura/env.h" | 31 #include "ui/aura/env.h" |
| 32 #include "ui/aura/test/test_screen.h" |
31 #endif | 33 #endif |
32 | 34 |
33 #if defined(OS_WIN) || defined(USE_AURA) | 35 #if defined(OS_WIN) || defined(USE_AURA) |
34 #include "content/browser/renderer_host/ui_events_helper.h" | 36 #include "content/browser/renderer_host/ui_events_helper.h" |
35 #include "ui/base/events/event.h" | 37 #include "ui/base/events/event.h" |
36 #endif | 38 #endif |
37 | 39 |
38 using base::TimeDelta; | 40 using base::TimeDelta; |
39 using WebKit::WebGestureEvent; | 41 using WebKit::WebGestureEvent; |
40 using WebKit::WebInputEvent; | 42 using WebKit::WebInputEvent; |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 } | 384 } |
383 ~RenderWidgetHostTest() { | 385 ~RenderWidgetHostTest() { |
384 } | 386 } |
385 | 387 |
386 protected: | 388 protected: |
387 // testing::Test | 389 // testing::Test |
388 void SetUp() { | 390 void SetUp() { |
389 browser_context_.reset(new TestBrowserContext()); | 391 browser_context_.reset(new TestBrowserContext()); |
390 delegate_.reset(new MockRenderWidgetHostDelegate()); | 392 delegate_.reset(new MockRenderWidgetHostDelegate()); |
391 process_ = new RenderWidgetHostProcess(browser_context_.get()); | 393 process_ = new RenderWidgetHostProcess(browser_context_.get()); |
| 394 #if defined(USE_AURA) |
| 395 screen_.reset(new aura::TestScreen); |
| 396 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); |
| 397 #endif |
392 host_.reset( | 398 host_.reset( |
393 new MockRenderWidgetHost(delegate_.get(), process_, MSG_ROUTING_NONE)); | 399 new MockRenderWidgetHost(delegate_.get(), process_, MSG_ROUTING_NONE)); |
394 view_.reset(new TestView(host_.get())); | 400 view_.reset(new TestView(host_.get())); |
395 host_->SetView(view_.get()); | 401 host_->SetView(view_.get()); |
396 host_->Init(); | 402 host_->Init(); |
397 } | 403 } |
398 void TearDown() { | 404 void TearDown() { |
399 view_.reset(); | 405 view_.reset(); |
400 host_.reset(); | 406 host_.reset(); |
401 delegate_.reset(); | 407 delegate_.reset(); |
402 process_ = NULL; | 408 process_ = NULL; |
403 browser_context_.reset(); | 409 browser_context_.reset(); |
404 | 410 |
405 #if defined(USE_AURA) | 411 #if defined(USE_AURA) |
406 aura::Env::DeleteInstance(); | 412 aura::Env::DeleteInstance(); |
| 413 screen_.reset(); |
407 #endif | 414 #endif |
408 | 415 |
409 // Process all pending tasks to avoid leaks. | 416 // Process all pending tasks to avoid leaks. |
410 MessageLoop::current()->RunUntilIdle(); | 417 MessageLoop::current()->RunUntilIdle(); |
411 } | 418 } |
412 | 419 |
413 void SendInputEventACK(WebInputEvent::Type type, bool processed) { | 420 void SendInputEventACK(WebInputEvent::Type type, bool processed) { |
414 scoped_ptr<IPC::Message> response( | 421 scoped_ptr<IPC::Message> response( |
415 new ViewHostMsg_HandleInputEvent_ACK(0, type, processed)); | 422 new ViewHostMsg_HandleInputEvent_ACK(0, type, processed)); |
416 host_->OnMessageReceived(*response); | 423 host_->OnMessageReceived(*response); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 touch_event_.type = WebInputEvent::TouchEnd; | 520 touch_event_.type = WebInputEvent::TouchEnd; |
514 } | 521 } |
515 | 522 |
516 MessageLoopForUI message_loop_; | 523 MessageLoopForUI message_loop_; |
517 | 524 |
518 scoped_ptr<TestBrowserContext> browser_context_; | 525 scoped_ptr<TestBrowserContext> browser_context_; |
519 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. | 526 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. |
520 scoped_ptr<MockRenderWidgetHostDelegate> delegate_; | 527 scoped_ptr<MockRenderWidgetHostDelegate> delegate_; |
521 scoped_ptr<MockRenderWidgetHost> host_; | 528 scoped_ptr<MockRenderWidgetHost> host_; |
522 scoped_ptr<TestView> view_; | 529 scoped_ptr<TestView> view_; |
| 530 scoped_ptr<gfx::Screen> screen_; |
523 | 531 |
524 private: | 532 private: |
525 WebTouchEvent touch_event_; | 533 WebTouchEvent touch_event_; |
526 | 534 |
527 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); | 535 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); |
528 }; | 536 }; |
529 | 537 |
530 } // namespace | 538 } // namespace |
531 | 539 |
532 // ----------------------------------------------------------------------------- | 540 // ----------------------------------------------------------------------------- |
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 process_->InitUpdateRectParams(¶ms); | 1793 process_->InitUpdateRectParams(¶ms); |
1786 params.scale_factor = params.scale_factor * 2; | 1794 params.scale_factor = params.scale_factor * 2; |
1787 | 1795 |
1788 EXPECT_EQ(0, process_->bad_msg_count()); | 1796 EXPECT_EQ(0, process_->bad_msg_count()); |
1789 host_->OnMsgUpdateRect(params); | 1797 host_->OnMsgUpdateRect(params); |
1790 EXPECT_EQ(1, process_->bad_msg_count()); | 1798 EXPECT_EQ(1, process_->bad_msg_count()); |
1791 } | 1799 } |
1792 #endif | 1800 #endif |
1793 | 1801 |
1794 } // namespace content | 1802 } // namespace content |
OLD | NEW |