Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2681)

Unified Diff: blimp/net/engine_connection_manager_unittest.cc

Issue 2439403003: Refactor BlimpConnection to TCPConnection (Closed)
Patch Set: Added missing Engine Transport Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: blimp/net/engine_connection_manager_unittest.cc
diff --git a/blimp/net/engine_connection_manager_unittest.cc b/blimp/net/engine_connection_manager_unittest.cc
index bd67c77e0471143fadc00f9ee4089b05bfcb2864..f9428068066e4d650647a60a149c309e08394b78 100644
--- a/blimp/net/engine_connection_manager_unittest.cc
+++ b/blimp/net/engine_connection_manager_unittest.cc
@@ -13,13 +13,15 @@
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "blimp/net/blimp_connection.h"
#include "blimp/net/blimp_transport.h"
#include "blimp/net/common.h"
#include "blimp/net/connection_error_observer.h"
+#include "blimp/net/tcp_client_transport.h"
+#include "blimp/net/tcp_connection.h"
#include "blimp/net/test_common.h"
#include "net/base/completion_callback.h"
#include "net/base/io_buffer.h"
+#include "net/base/ip_address.h"
#include "net/base/net_errors.h"
#include "net/base/test_completion_callback.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -35,61 +37,29 @@ namespace blimp {
class EngineConnectionManagerTest : public testing::Test {
public:
EngineConnectionManagerTest()
- : manager_(new EngineConnectionManager(&connection_handler_)) {}
+ : manager_(new EngineConnectionManager(&connection_handler_, nullptr)) {}
~EngineConnectionManagerTest() override {}
- std::unique_ptr<BlimpConnection> CreateConnection() {
- return base::MakeUnique<BlimpConnection>(
- base::MakeUnique<MessagePort>(base::MakeUnique<MockPacketReader>(),
- base::MakeUnique<MockPacketWriter>()));
- }
-
protected:
testing::StrictMock<MockConnectionHandler> connection_handler_;
std::unique_ptr<EngineConnectionManager> manager_;
+ base::MessageLoopForIO message_loop_;
};
TEST_F(EngineConnectionManagerTest, ConnectionSucceeds) {
- std::unique_ptr<testing::StrictMock<MockTransport>> transport1(
- new testing::StrictMock<MockTransport>());
- std::unique_ptr<testing::StrictMock<MockTransport>> transport2(
- new testing::StrictMock<MockTransport>());
-
- net::CompletionCallback connect_cb_1;
- net::CompletionCallback connect_cb_2;
- EXPECT_CALL(*transport1, Connect(_))
- .Times(2)
- .WillRepeatedly(SaveArg<0>(&connect_cb_1));
- EXPECT_CALL(*transport2, Connect(_))
- .Times(2)
- .WillRepeatedly(SaveArg<0>(&connect_cb_2));
-
- std::unique_ptr<MessagePort> port1 =
- base::MakeUnique<MessagePort>(base::MakeUnique<MockPacketReader>(),
- base::MakeUnique<MockPacketWriter>());
- std::unique_ptr<MessagePort> port2 =
- base::MakeUnique<MessagePort>(base::MakeUnique<MockPacketReader>(),
- base::MakeUnique<MockPacketWriter>());
- EXPECT_CALL(connection_handler_, HandleConnectionPtr(_)).Times(2);
-
- EXPECT_CALL(*transport1, TakeMessagePortPtr())
- .WillOnce(Return(port1.release()));
- EXPECT_CALL(*transport2, TakeMessagePortPtr())
- .WillOnce(Return(port2.release()));
+ EXPECT_CALL(connection_handler_, HandleConnectionPtr(_)).Times(1);
- ASSERT_TRUE(connect_cb_1.is_null());
- manager_->AddTransport(std::move(transport1));
- ASSERT_FALSE(connect_cb_1.is_null());
+ net::IPAddress ip_addr(net::IPAddress::IPv4Localhost());
+ net::IPEndPoint engine_endpoint(ip_addr, 0);
- ASSERT_TRUE(connect_cb_2.is_null());
- manager_->AddTransport(std::move(transport2));
- ASSERT_FALSE(connect_cb_2.is_null());
+ manager_->ConnectTransport(&engine_endpoint,
+ EngineConnectionManager::EngineTransportType::TCP);
- base::ResetAndReturn(&connect_cb_1).Run(net::OK);
- base::ResetAndReturn(&connect_cb_2).Run(net::OK);
- ASSERT_FALSE(connect_cb_1.is_null());
- ASSERT_FALSE(connect_cb_2.is_null());
+ net::TestCompletionCallback connect_callback;
+ TCPClientTransport client(engine_endpoint, nullptr);
+ client.Connect(connect_callback.callback());
+ EXPECT_EQ(net::OK, connect_callback.WaitForResult());
}
} // namespace blimp

Powered by Google App Engine
This is Rietveld 408576698