| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "blimp/net/blimp_connection.h" | 5 #include "blimp/net/blimp_connection.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 EXPECT_CALL(*writer_, | 151 EXPECT_CALL(*writer_, |
| 152 WritePacket(BufferEqualsProto(*CreateInputMessage()), _)) | 152 WritePacket(BufferEqualsProto(*CreateInputMessage()), _)) |
| 153 .WillOnce(SaveArg<1>(&write_packet_cb)) | 153 .WillOnce(SaveArg<1>(&write_packet_cb)) |
| 154 .RetiresOnSaturation(); | 154 .RetiresOnSaturation(); |
| 155 EXPECT_CALL(error_observer1_, OnConnectionError(net::ERR_FAILED)) | 155 EXPECT_CALL(error_observer1_, OnConnectionError(net::ERR_FAILED)) |
| 156 .WillOnce(testing::InvokeWithoutArgs( | 156 .WillOnce(testing::InvokeWithoutArgs( |
| 157 this, &BlimpConnectionTest::DropConnection)); | 157 this, &BlimpConnectionTest::DropConnection)); |
| 158 | 158 |
| 159 BlimpMessageProcessor* sender = connection_->GetOutgoingMessageProcessor(); | 159 BlimpMessageProcessor* sender = connection_->GetOutgoingMessageProcessor(); |
| 160 net::TestCompletionCallback complete_cb_1; | 160 net::TestCompletionCallback complete_cb_1; |
| 161 sender->ProcessMessage(CreateInputMessage(), | 161 sender->ProcessMessage(CreateInputMessage(), complete_cb_1.callback()); |
| 162 complete_cb_1.callback()); | |
| 163 base::ResetAndReturn(&write_packet_cb).Run(net::ERR_FAILED); | 162 base::ResetAndReturn(&write_packet_cb).Run(net::ERR_FAILED); |
| 164 EXPECT_EQ(net::ERR_FAILED, complete_cb_1.WaitForResult()); | 163 EXPECT_EQ(net::ERR_FAILED, complete_cb_1.WaitForResult()); |
| 165 } | 164 } |
| 166 | 165 |
| 167 // Verifies that a ReadPacket error causes ErrorObservers to be notified. | 166 // Verifies that a ReadPacket error causes ErrorObservers to be notified. |
| 168 TEST_F(BlimpConnectionTest, ReadPacketErrorInvokesErrorObservers) { | 167 TEST_F(BlimpConnectionTest, ReadPacketErrorInvokesErrorObservers) { |
| 169 scoped_refptr<net::GrowableIOBuffer> read_packet_buffer; | 168 scoped_refptr<net::GrowableIOBuffer> read_packet_buffer; |
| 170 net::CompletionCallback read_packet_cb; | 169 net::CompletionCallback read_packet_cb; |
| 171 | 170 |
| 172 EXPECT_CALL(*reader_, ReadPacket(_, _)) | 171 EXPECT_CALL(*reader_, ReadPacket(_, _)) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 219 |
| 221 // Put the EndConnection message in the buffer and invoke the read callback. | 220 // Put the EndConnection message in the buffer and invoke the read callback. |
| 222 read_packet_buffer->SetCapacity(message->ByteSize()); | 221 read_packet_buffer->SetCapacity(message->ByteSize()); |
| 223 ASSERT_TRUE(message->SerializeToArray(read_packet_buffer->data(), | 222 ASSERT_TRUE(message->SerializeToArray(read_packet_buffer->data(), |
| 224 message->GetCachedSize())); | 223 message->GetCachedSize())); |
| 225 base::ResetAndReturn(&read_packet_cb).Run(message->ByteSize()); | 224 base::ResetAndReturn(&read_packet_cb).Run(message->ByteSize()); |
| 226 } | 225 } |
| 227 | 226 |
| 228 } // namespace | 227 } // namespace |
| 229 } // namespace blimp | 228 } // namespace blimp |
| OLD | NEW |