| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 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 "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 protected: |
| 11 MessageLoopForIO message_loop_; |
| 12 // We need a render process for ppapi::proxy::ProxyChannel to work. |
| 13 MockRenderProcess mock_process_; |
| 14 }; |
| 15 |
| 16 // Try to initialize BrokerDispatcherWrapper with invalid ChannelHandle. |
| 17 // Initialization should fail. |
| 18 TEST_F(PepperPluginDelegateImplTest, BrokerDispatcherWrapperInitFailure) { |
| 19 BrokerDispatcherWrapper dispatcher_wrapper; |
| 20 base::ProcessHandle broker_process_handle = base::kNullProcessHandle; |
| 21 IPC::ChannelHandle channel_handle; // Invalid by default. |
| 22 |
| 23 // Try BrokerDispatcherWrapper.Init() TWICE to trigger the LOG(FATAL) |
| 24 // of "Denying attempt to reuse initial IPC channel for ..." in |
| 25 // IPC::Channel::ChannelImpl::CreatePipe() in case invalid ChannelHandle is |
| 26 // not checked properly. If invalid ChannelHandle is not checked and passed |
| 27 // all the way down to IPC::Channel::ChannelImpl::CreatePipe(), CreatePipe |
| 28 // will be called in client mode with channel_handle.socket.fd == -1. There |
| 29 // is a static variable "bool used_initial_channel = false" in this function. |
| 30 // In the first test it will be set to true. In the second test the |
| 31 // LOG(FATAL) error will be triggered. |
| 32 EXPECT_FALSE(dispatcher_wrapper.Init(broker_process_handle, channel_handle)); |
| 33 EXPECT_FALSE(dispatcher_wrapper.Init(broker_process_handle, channel_handle)); |
| 34 } |
| OLD | NEW |