This source file includes following definitions.
- TEST_F
- TEST_F
#include "content/renderer/pepper/pepper_broker.h"
#if defined(OS_POSIX)
#include <fcntl.h>
#include <sys/socket.h>
#endif
#include "content/test/mock_render_process.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
class PepperBrokerTest : public ::testing::Test {
protected:
base::MessageLoopForIO message_loop_;
MockRenderProcess mock_process_;
};
TEST_F(PepperBrokerTest, InitFailure) {
PepperBrokerDispatcherWrapper dispatcher_wrapper;
IPC::ChannelHandle invalid_channel;
EXPECT_FALSE(dispatcher_wrapper.Init(base::kNullProcessId, invalid_channel));
EXPECT_FALSE(dispatcher_wrapper.Init(base::kNullProcessId, invalid_channel));
}
TEST_F(PepperBrokerTest, InitSuccess) {
PepperBrokerDispatcherWrapper dispatcher_wrapper;
const char kChannelName[] = "PepperHelperImplTestChannelName";
#if defined(OS_POSIX)
int fds[2] = {-1, -1};
ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_STREAM, 0, fds));
ASSERT_EQ(0, fcntl(fds[1], F_SETFL, O_NONBLOCK));
base::FileDescriptor file_descriptor(fds[1], true);
IPC::ChannelHandle valid_channel(kChannelName, file_descriptor);
#else
IPC::ChannelHandle valid_channel(kChannelName);
#endif
EXPECT_TRUE(dispatcher_wrapper.Init(base::kNullProcessId, valid_channel));
#if defined(OS_POSIX)
EXPECT_EQ(0, ::close(fds[0]));
#endif
}
}