From: Nikolay Khlopkov Date: Fri, 14 Mar 2014 07:02:35 +0000 (+0400) Subject: Unneeded static_cast removed X-Git-Tag: 3.5~266 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f043ea952caaffcaac5232fe31bf2fbdb9c67e78;p=profile%2Fivi%2Fsmartdevicelink.git Unneeded static_cast removed No subject for review: trivial change Signed-off-by: Justin Dickow Conflicts: test/components/transport_manager/src/test_tcp_transport_adapter.cc --- diff --git a/test/components/transport_manager/src/test_tcp_transport_adapter.cc b/test/components/transport_manager/src/test_tcp_transport_adapter.cc index 328ce0a..51cc3cc 100644 --- a/test/components/transport_manager/src/test_tcp_transport_adapter.cc +++ b/test/components/transport_manager/src/test_tcp_transport_adapter.cc @@ -16,8 +16,7 @@ namespace transport_manager { namespace transport_adapter { TEST(TcpAdapterBasicTest, Basic) { - TransportAdapter* transport_adapter = - static_cast(new TcpTransportAdapter); + TransportAdapter* transport_adapter = new TcpTransportAdapter(12345); EXPECT_EQ("sdl-tcp", transport_adapter->GetDeviceType()); EXPECT_TRUE(transport_adapter->IsServerOriginatedConnectSupported()); @@ -26,8 +25,7 @@ TEST(TcpAdapterBasicTest, Basic) { } TEST(TcpAdapterBasicTest, NotInitialised) { - TransportAdapter* transport_adapter = - static_cast(new TcpTransportAdapter); + TransportAdapter* transport_adapter = new TcpTransportAdapter(12345); EXPECT_EQ(TransportAdapter::BAD_STATE, transport_adapter->SearchDevices()); EXPECT_EQ(TransportAdapter::OK, @@ -92,13 +90,18 @@ void Disconnect(const TransportAdapter* transport_adapter, class TcpAdapterTest : public ::testing::Test { public: TcpAdapterTest() - : transport_adapter_(static_cast(new TcpTransportAdapter)), + : port_(ChoosePort()), + transport_adapter_(new TcpTransportAdapter(port_)), suspended_(false), finished_(false) { pthread_mutex_init(&suspend_mutex_, 0); pthread_cond_init(&suspend_cond_, 0); } + uint16_t ChoosePort() { + return getpid() % 1000 + 3000; + } + virtual void SetUp() { const TransportAdapter::Error error = transport_adapter_->Init(); ASSERT_EQ(TransportAdapter::OK, error); @@ -140,6 +143,9 @@ class TcpAdapterTest : public ::testing::Test { pthread_mutex_unlock(&suspend_mutex_); } + uint16_t port() const {return port_;} + + const uint16_t port_; TransportAdapter* transport_adapter_; MockTransportAdapterListener mock_dal_; ClientTcpSocket client_; @@ -165,7 +171,7 @@ TEST_F(TcpAdapterTestWithListenerAutoStart, Connect) { EXPECT_CALL(mock_dal_, OnConnectDone(transport_adapter_, _, _)).WillOnce( InvokeWithoutArgs(this, &TcpAdapterTest::wakeUp)); } - EXPECT_TRUE(client_.Connect(TcpTransportAdapter::default_port)); + EXPECT_TRUE(client_.Connect(port())); } TEST_F(TcpAdapterTestWithListenerAutoStart, Receive) { @@ -177,7 +183,7 @@ TEST_F(TcpAdapterTestWithListenerAutoStart, Receive) { OnDataReceiveDone(transport_adapter_, _, _, ContainsMessage("abcd"))). WillOnce(InvokeWithoutArgs(this, &TcpAdapterTest::wakeUp)); } - EXPECT_TRUE(client_.Connect(TcpTransportAdapter::default_port)); + EXPECT_TRUE(client_.Connect(port())); EXPECT_TRUE(client_.Send("abcd")); } @@ -215,7 +221,7 @@ TEST_F(TcpAdapterTestWithListenerAutoStart, Send) { InvokeWithoutArgs(this, &TcpAdapterTest::wakeUp)); } - EXPECT_TRUE(client_.Connect(TcpTransportAdapter::default_port)); + EXPECT_TRUE(client_.Connect(port())); EXPECT_EQ("efgh", client_.receive(4)); } @@ -227,7 +233,7 @@ TEST_F(TcpAdapterTestWithListenerAutoStart, DisconnectFromClient) { EXPECT_CALL(mock_dal_, OnDisconnectDone(transport_adapter_, _, _)).WillOnce( InvokeWithoutArgs(this, &TcpAdapterTest::wakeUp)); } - EXPECT_TRUE(client_.Connect(TcpTransportAdapter::default_port)); + EXPECT_TRUE(client_.Connect(port())); client_.Disconnect(); } @@ -239,7 +245,7 @@ TEST_F(TcpAdapterTestWithListenerAutoStart, DisconnectFromServer) { EXPECT_CALL(mock_dal_, OnDisconnectDone(transport_adapter_, _, _)).WillOnce( InvokeWithoutArgs(this, &TcpAdapterTest::wakeUp)); } - EXPECT_TRUE(client_.Connect(TcpTransportAdapter::default_port)); + EXPECT_TRUE(client_.Connect(port())); } TEST_F(TcpAdapterTestWithListenerAutoStart, SendToDisconnected) { @@ -252,7 +258,7 @@ TEST_F(TcpAdapterTestWithListenerAutoStart, SendToDisconnected) { ::testing::DoAll(Invoke(helper, &SendHelper::sendMessage), InvokeWithoutArgs(this, &TcpAdapterTest::wakeUp))); } - EXPECT_TRUE(client_.Connect(TcpTransportAdapter::default_port)); + EXPECT_TRUE(client_.Connect(port())); } TEST_F(TcpAdapterTestWithListenerAutoStart, SendFailed) { @@ -268,22 +274,22 @@ TEST_F(TcpAdapterTestWithListenerAutoStart, SendFailed) { EXPECT_CALL(mock_dal_, OnDisconnectDone(transport_adapter_, _, _)).WillOnce( InvokeWithoutArgs(this, &TcpAdapterTest::wakeUp)); } - EXPECT_TRUE(client_.Connect(TcpTransportAdapter::default_port)); + EXPECT_TRUE(client_.Connect(port())); client_.receive(2); client_.Disconnect(); } TEST_F(TcpAdapterTest, StartStop) { EXPECT_EQ(TransportAdapter::BAD_STATE, transport_adapter_->StopClientListening()); - EXPECT_FALSE(client_.Connect(TcpTransportAdapter::default_port)); + EXPECT_FALSE(client_.Connect(port())); EXPECT_EQ(TransportAdapter::OK, transport_adapter_->StartClientListening()); - EXPECT_TRUE(client_.Connect(TcpTransportAdapter::default_port)); + EXPECT_TRUE(client_.Connect(port())); client_.Disconnect(); EXPECT_EQ(TransportAdapter::BAD_STATE, transport_adapter_->StartClientListening()); - EXPECT_TRUE(client_.Connect(TcpTransportAdapter::default_port)); + EXPECT_TRUE(client_.Connect(port())); client_.Disconnect(); EXPECT_EQ(TransportAdapter::OK, transport_adapter_->StopClientListening()); - EXPECT_FALSE(client_.Connect(TcpTransportAdapter::default_port)); + EXPECT_FALSE(client_.Connect(port())); wakeUp(); }