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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "content/public/browser/notification_types.h" | 28 #include "content/public/browser/notification_types.h" |
29 #include "content/public/test/mock_render_process_host.h" | 29 #include "content/public/test/mock_render_process_host.h" |
30 #include "content/public/test/test_browser_context.h" | 30 #include "content/public/test/test_browser_context.h" |
31 #include "content/test/test_render_view_host.h" | 31 #include "content/test/test_render_view_host.h" |
32 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
33 #include "ui/events/keycodes/keyboard_codes.h" | 33 #include "ui/events/keycodes/keyboard_codes.h" |
34 #include "ui/gfx/canvas.h" | 34 #include "ui/gfx/canvas.h" |
35 #include "ui/gfx/screen.h" | 35 #include "ui/gfx/screen.h" |
36 | 36 |
37 #if defined(USE_AURA) | 37 #if defined(USE_AURA) |
| 38 #include "content/browser/aura/image_transport_factory.h" |
38 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 39 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
39 #include "ui/aura/env.h" | 40 #include "ui/aura/env.h" |
40 #include "ui/aura/test/test_screen.h" | 41 #include "ui/aura/test/test_screen.h" |
| 42 #include "ui/compositor/test/test_context_factory.h" |
41 #endif | 43 #endif |
42 | 44 |
43 #if defined(OS_WIN) || defined(USE_AURA) | 45 #if defined(OS_WIN) || defined(USE_AURA) |
44 #include "content/browser/renderer_host/ui_events_helper.h" | 46 #include "content/browser/renderer_host/ui_events_helper.h" |
45 #include "ui/events/event.h" | 47 #include "ui/events/event.h" |
46 #endif | 48 #endif |
47 | 49 |
48 using base::TimeDelta; | 50 using base::TimeDelta; |
49 using blink::WebGestureEvent; | 51 using blink::WebGestureEvent; |
50 using blink::WebInputEvent; | 52 using blink::WebInputEvent; |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 return handle_mouse_event_; | 613 return handle_mouse_event_; |
612 } | 614 } |
613 | 615 |
614 protected: | 616 protected: |
615 // testing::Test | 617 // testing::Test |
616 virtual void SetUp() { | 618 virtual void SetUp() { |
617 browser_context_.reset(new TestBrowserContext()); | 619 browser_context_.reset(new TestBrowserContext()); |
618 delegate_.reset(new MockRenderWidgetHostDelegate()); | 620 delegate_.reset(new MockRenderWidgetHostDelegate()); |
619 process_ = new RenderWidgetHostProcess(browser_context_.get()); | 621 process_ = new RenderWidgetHostProcess(browser_context_.get()); |
620 #if defined(USE_AURA) | 622 #if defined(USE_AURA) |
| 623 ImageTransportFactory::InitializeForUnitTests( |
| 624 scoped_ptr<ui::ContextFactory>(new ui::TestContextFactory)); |
621 aura::Env::CreateInstance(); | 625 aura::Env::CreateInstance(); |
622 screen_.reset(aura::TestScreen::Create()); | 626 screen_.reset(aura::TestScreen::Create()); |
623 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); | 627 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); |
624 #endif | 628 #endif |
625 host_.reset( | 629 host_.reset( |
626 new MockRenderWidgetHost(delegate_.get(), process_, MSG_ROUTING_NONE)); | 630 new MockRenderWidgetHost(delegate_.get(), process_, MSG_ROUTING_NONE)); |
627 view_.reset(new TestView(host_.get())); | 631 view_.reset(new TestView(host_.get())); |
628 host_->SetView(view_.get()); | 632 host_->SetView(view_.get()); |
629 host_->Init(); | 633 host_->Init(); |
630 } | 634 } |
631 virtual void TearDown() { | 635 virtual void TearDown() { |
632 view_.reset(); | 636 view_.reset(); |
633 host_.reset(); | 637 host_.reset(); |
634 delegate_.reset(); | 638 delegate_.reset(); |
635 process_ = NULL; | 639 process_ = NULL; |
636 browser_context_.reset(); | 640 browser_context_.reset(); |
637 | 641 |
638 #if defined(USE_AURA) | 642 #if defined(USE_AURA) |
639 aura::Env::DeleteInstance(); | 643 aura::Env::DeleteInstance(); |
640 screen_.reset(); | 644 screen_.reset(); |
| 645 ImageTransportFactory::Terminate(); |
641 #endif | 646 #endif |
642 | 647 |
643 // Process all pending tasks to avoid leaks. | 648 // Process all pending tasks to avoid leaks. |
644 base::MessageLoop::current()->RunUntilIdle(); | 649 base::MessageLoop::current()->RunUntilIdle(); |
645 } | 650 } |
646 | 651 |
647 void SendInputEventACK(WebInputEvent::Type type, | 652 void SendInputEventACK(WebInputEvent::Type type, |
648 InputEventAckState ack_result) { | 653 InputEventAckState ack_result) { |
649 scoped_ptr<IPC::Message> response( | 654 scoped_ptr<IPC::Message> response( |
650 new InputHostMsg_HandleInputEvent_ACK(0, type, ack_result, | 655 new InputHostMsg_HandleInputEvent_ACK(0, type, ack_result, |
(...skipping 1847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2498 | 2503 |
2499 TEST_F(RenderWidgetHostTest, InputRouterReceivesHasTouchEventHandlers) { | 2504 TEST_F(RenderWidgetHostTest, InputRouterReceivesHasTouchEventHandlers) { |
2500 host_->SetupForInputRouterTest(); | 2505 host_->SetupForInputRouterTest(); |
2501 | 2506 |
2502 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 2507 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
2503 | 2508 |
2504 EXPECT_TRUE(host_->mock_input_router()->message_received_); | 2509 EXPECT_TRUE(host_->mock_input_router()->message_received_); |
2505 } | 2510 } |
2506 | 2511 |
2507 } // namespace content | 2512 } // namespace content |
OLD | NEW |