OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
Paweł Hajdan Jr.
2011/11/04 08:05:15
nit: 2011 not 2009.
xhwang
2011/11/04 15:44:48
Done.
| |
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 "content/renderer/pepper_plugin_delegate_impl.h" | |
6 #include "content/test/mock_render_process.h" | |
7 #include "testing/gtest/include/gtest/gtest.h" | |
8 | |
9 class PepperPluginDelegateImplTest : public ::testing::Test { | |
10 public: | |
11 PepperPluginDelegateImplTest() {} | |
Paweł Hajdan Jr.
2011/11/04 08:05:15
nit: Is the ctor needed here? Is the dtor needed?
xhwang
2011/11/04 15:44:48
Done.
| |
12 virtual ~PepperPluginDelegateImplTest() {} | |
13 | |
14 virtual void SetUp() { | |
15 mock_process_.reset(new MockRenderProcess); | |
16 } | |
17 | |
18 virtual void TearDown() { | |
19 mock_process_.reset(); | |
20 } | |
21 | |
22 protected: | |
23 MessageLoopForIO message_loop_; | |
24 // ppapi::proxy::ProxyChannel needs to be initialized on the render process. | |
25 scoped_ptr<MockRenderProcess> mock_process_; | |
Paweł Hajdan Jr.
2011/11/04 08:05:15
nit: I think you can just declare MockRenderProces
xhwang
2011/11/04 15:44:48
Great to know that. Thanks!
| |
26 | |
27 private: | |
28 DISALLOW_COPY_AND_ASSIGN(PepperPluginDelegateImplTest); | |
Paweł Hajdan Jr.
2011/11/04 08:05:15
nit: No need for this in test fixtures.
xhwang
2011/11/04 15:44:48
Done.
| |
29 }; | |
30 | |
31 // Try to initialize BrokerDispatcherWrapper with invalid ChannelHandle. | |
32 // Initialization should fail. | |
33 TEST_F(PepperPluginDelegateImplTest, BrokerDispatcherWrapperInitFailure) { | |
34 BrokerDispatcherWrapper dispatcher_wrapper; | |
35 base::ProcessHandle broker_process_handle = base::kNullProcessHandle; | |
36 IPC::ChannelHandle channel_handle; // Invalid by default. | |
Paweł Hajdan Jr.
2011/11/04 08:05:15
nit: Two spaces between code and comment please.
xhwang
2011/11/04 15:44:48
Done.
| |
37 | |
38 // Try BrokerDispatcherWrapper.Init() TWICE to trigger the LOG(FATAL) | |
39 // of "Denying attempt to reuse initial IPC channel for ..." in | |
40 // IPC::Channel::ChannelImpl::CreatePipe() in case invalid ChannelHandle is | |
41 // not checked properly. If invalid ChannelHandle is not checked and passed | |
42 // all the way down to IPC::Channel::ChannelImpl::CreatePipe(), CreatePipe | |
43 // will be called in client mode with channel_handle.socket.fd == -1. There | |
44 // is a static variable "bool used_initial_channel = false" in this function. | |
45 // In the first test it will be set to true. In the second test the | |
46 // LOG(FATAL) error will be triggered. | |
47 EXPECT_FALSE(dispatcher_wrapper.Init(broker_process_handle, channel_handle)); | |
48 EXPECT_FALSE(dispatcher_wrapper.Init(broker_process_handle, channel_handle)); | |
49 } | |
OLD | NEW |