| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 public BlimpMessageProcessor { | 70 public BlimpMessageProcessor { |
| 71 public: | 71 public: |
| 72 FakeBlimpConnection() {} | 72 FakeBlimpConnection() {} |
| 73 ~FakeBlimpConnection() override {} | 73 ~FakeBlimpConnection() override {} |
| 74 | 74 |
| 75 void set_other_end(FakeBlimpConnection* other_end) { other_end_ = other_end; } | 75 void set_other_end(FakeBlimpConnection* other_end) { other_end_ = other_end; } |
| 76 | 76 |
| 77 ConnectionErrorObserver* error_observer() { return error_observer_; } | 77 ConnectionErrorObserver* error_observer() { return error_observer_; } |
| 78 | 78 |
| 79 // BlimpConnection implementation. | 79 // BlimpConnection implementation. |
| 80 void SetConnectionErrorObserver(ConnectionErrorObserver* observer) override { | 80 void AddConnectionErrorObserver(ConnectionErrorObserver* observer) override { |
| 81 error_observer_ = observer; | 81 error_observer_ = observer; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void SetIncomingMessageProcessor(BlimpMessageProcessor* processor) override { | 84 void SetIncomingMessageProcessor(BlimpMessageProcessor* processor) override { |
| 85 incoming_message_processor_ = processor; | 85 incoming_message_processor_ = processor; |
| 86 } | 86 } |
| 87 | 87 |
| 88 BlimpMessageProcessor* GetOutgoingMessageProcessor() override { return this; } | 88 BlimpMessageProcessor* GetOutgoingMessageProcessor() override { return this; } |
| 89 | 89 |
| 90 private: | 90 private: |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 std::move(client_input_message), net::CompletionCallback()); | 202 std::move(client_input_message), net::CompletionCallback()); |
| 203 } | 203 } |
| 204 | 204 |
| 205 TEST_F(BrowserConnectionHandlerTest, ReconnectionAfterError) { | 205 TEST_F(BrowserConnectionHandlerTest, ReconnectionAfterError) { |
| 206 scoped_ptr<BlimpMessage> client_input_message = CreateInputMessage(1); | 206 scoped_ptr<BlimpMessage> client_input_message = CreateInputMessage(1); |
| 207 EXPECT_CALL( | 207 EXPECT_CALL( |
| 208 *(engine_input_feature_->incoming_message_processor()), | 208 *(engine_input_feature_->incoming_message_processor()), |
| 209 MockableProcessMessage(EqualsMessageIgnoringId(*client_input_message), _)) | 209 MockableProcessMessage(EqualsMessageIgnoringId(*client_input_message), _)) |
| 210 .RetiresOnSaturation(); | 210 .RetiresOnSaturation(); |
| 211 | 211 |
| 212 // Simulate a connection failure. |
| 212 client_connection_->error_observer()->OnConnectionError(net::ERR_FAILED); | 213 client_connection_->error_observer()->OnConnectionError(net::ERR_FAILED); |
| 214 engine_connection_->error_observer()->OnConnectionError(net::ERR_FAILED); |
| 215 |
| 213 // Message will be queued to be transmitted when the connection is | 216 // Message will be queued to be transmitted when the connection is |
| 214 // re-established. | 217 // re-established. |
| 215 client_input_feature_->outgoing_message_processor()->ProcessMessage( | 218 client_input_feature_->outgoing_message_processor()->ProcessMessage( |
| 216 std::move(client_input_message), net::CompletionCallback()); | 219 std::move(client_input_message), net::CompletionCallback()); |
| 217 | 220 |
| 218 // Simulates reconnection. | 221 // Simulates reconnection. |
| 219 SetupConnections(); | 222 SetupConnections(); |
| 220 } | 223 } |
| 221 | 224 |
| 222 } // namespace | 225 } // namespace |
| 223 } // namespace blimp | 226 } // namespace blimp |
| OLD | NEW |