OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/command_line.h" |
| 6 #include "content/public/common/content_switches.h" |
| 7 #include "content/public/renderer/content_renderer_client.h" |
| 8 #include "content/renderer/render_process_impl.h" |
| 9 #include "content/renderer/render_thread_impl.h" |
| 10 #include "content/test/mock_render_process.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 namespace content { |
| 14 namespace { |
| 15 |
| 16 class RenderThreadImplBrowserTest : public testing::Test { |
| 17 public: |
| 18 virtual ~RenderThreadImplBrowserTest() {} |
| 19 }; |
| 20 |
| 21 class DummyListener : public IPC::Listener { |
| 22 public: |
| 23 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { |
| 24 return true; |
| 25 } |
| 26 }; |
| 27 |
| 28 void CheckRenderThreadInputHandlerManager(RenderThreadImpl* thread) { |
| 29 ASSERT_TRUE(thread->input_handler_manager()); |
| 30 } |
| 31 |
| 32 // Check that InputHandlerManager outlives compositor thread because it uses |
| 33 // raw pointers to post tasks. |
| 34 TEST_F(RenderThreadImplBrowserTest, |
| 35 InputHandlerManagerDestroyedAfterCompositorThread) { |
| 36 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 37 switches::kEnableThreadedCompositing); |
| 38 |
| 39 ContentRendererClient content_renderer_client; |
| 40 SetRendererClientForTesting(&content_renderer_client); |
| 41 MessageLoopForIO message_loop_; |
| 42 |
| 43 std::string channel_id = IPC::Channel::GenerateVerifiedChannelID( |
| 44 std::string()); |
| 45 DummyListener dummy_listener; |
| 46 IPC::Channel channel(channel_id, IPC::Channel::MODE_SERVER, &dummy_listener); |
| 47 ASSERT_TRUE(channel.Connect()); |
| 48 |
| 49 scoped_ptr<MockRenderProcess> mock_process(new MockRenderProcess); |
| 50 // Owned by mock_process. |
| 51 RenderThreadImpl* thread = new RenderThreadImpl(channel_id); |
| 52 thread->EnsureWebKitInitialized(); |
| 53 |
| 54 ASSERT_TRUE(thread->input_handler_manager()); |
| 55 |
| 56 thread->compositor_message_loop_proxy()->PostTask( |
| 57 FROM_HERE, |
| 58 base::Bind(&CheckRenderThreadInputHandlerManager, thread)); |
| 59 } |
| 60 |
| 61 } // namespace |
| 62 } // namespace content |
OLD | NEW |