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

Unified Diff: blimp/net/client_connection_manager_unittest.cc

Issue 1551583003: Implementation and fixes for Blimp client/engine E2E communication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dtrainor-linux-cl1528243002
Patch Set: Fixed misplaced EXPORT directive Created 4 years, 12 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
« no previous file with comments | « blimp/net/client_connection_manager.cc ('k') | blimp/net/common.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/net/client_connection_manager_unittest.cc
diff --git a/blimp/net/client_connection_manager_unittest.cc b/blimp/net/client_connection_manager_unittest.cc
index 3aba2c849d8e86caef60f5f2ca4174ae4ca15352..3a424ff5e04e2e37b3f24f63833ddf9457802531 100644
--- a/blimp/net/client_connection_manager_unittest.cc
+++ b/blimp/net/client_connection_manager_unittest.cc
@@ -26,6 +26,9 @@ using testing::Return;
using testing::SaveArg;
namespace blimp {
+namespace {
+const char kDummyClientToken[] = "dummy-client-token";
+} // namespace
class ClientConnectionManagerTest : public testing::Test {
public:
@@ -38,7 +41,9 @@ class ClientConnectionManagerTest : public testing::Test {
connection_(new BlimpConnection(make_scoped_ptr(reader_),
make_scoped_ptr(writer_))),
start_connection_message_(
- CreateStartConnectionMessage("", kProtocolVersion)) {}
+ CreateStartConnectionMessage(kDummyClientToken, kProtocolVersion)) {
+ manager_->set_client_token(kDummyClientToken);
+ }
~ClientConnectionManagerTest() override {}
@@ -56,11 +61,13 @@ class ClientConnectionManagerTest : public testing::Test {
// The 1st transport connects, and the 2nd transport is not used.
TEST_F(ClientConnectionManagerTest, FirstTransportConnects) {
+ net::CompletionCallback write_cb;
net::CompletionCallback connect_cb_1;
EXPECT_CALL(*transport1_, Connect(_)).WillOnce(SaveArg<0>(&connect_cb_1));
EXPECT_CALL(connection_handler_, HandleConnectionPtr(Eq(connection_.get())));
EXPECT_CALL(*writer_,
- WritePacket(BufferEqualsProto(*start_connection_message_), _));
+ WritePacket(BufferEqualsProto(*start_connection_message_), _))
+ .WillOnce(SaveArg<1>(&write_cb));
EXPECT_CALL(*transport1_, TakeConnectionPtr())
.WillOnce(Return(connection_.release()));
@@ -70,16 +77,19 @@ TEST_F(ClientConnectionManagerTest, FirstTransportConnects) {
manager_->Connect();
ASSERT_FALSE(connect_cb_1.is_null());
base::ResetAndReturn(&connect_cb_1).Run(net::OK);
+ base::ResetAndReturn(&write_cb).Run(net::OK);
}
// The 1st transport fails to connect, and the 2nd transport connects.
TEST_F(ClientConnectionManagerTest, SecondTransportConnects) {
+ net::CompletionCallback write_cb;
net::CompletionCallback connect_cb_1;
EXPECT_CALL(*transport1_, Connect(_)).WillOnce(SaveArg<0>(&connect_cb_1));
net::CompletionCallback connect_cb_2;
EXPECT_CALL(*transport2_, Connect(_)).WillOnce(SaveArg<0>(&connect_cb_2));
EXPECT_CALL(*writer_,
- WritePacket(BufferEqualsProto(*start_connection_message_), _));
+ WritePacket(BufferEqualsProto(*start_connection_message_), _))
+ .WillOnce(SaveArg<1>(&write_cb));
EXPECT_CALL(connection_handler_, HandleConnectionPtr(Eq(connection_.get())));
EXPECT_CALL(*transport2_, TakeConnectionPtr())
.WillOnce(Return(connection_.release()));
@@ -93,6 +103,7 @@ TEST_F(ClientConnectionManagerTest, SecondTransportConnects) {
base::ResetAndReturn(&connect_cb_1).Run(net::ERR_FAILED);
ASSERT_FALSE(connect_cb_2.is_null());
base::ResetAndReturn(&connect_cb_2).Run(net::OK);
+ base::ResetAndReturn(&write_cb).Run(net::OK);
}
// Both transports fail to connect.
« no previous file with comments | « blimp/net/client_connection_manager.cc ('k') | blimp/net/common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698