OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_PROXIMITY_AUTH_FAKE_CONNECTION_H |
| 6 #define COMPONENTS_PROXIMITY_AUTH_FAKE_CONNECTION_H |
| 7 |
| 8 #include "components/proximity_auth/connection.h" |
| 9 |
| 10 namespace proximity_auth { |
| 11 |
| 12 // A fake implementation of Connection to use in tests. |
| 13 class FakeConnection : public Connection { |
| 14 public: |
| 15 FakeConnection(const RemoteDevice& remote_device); |
| 16 ~FakeConnection() override; |
| 17 |
| 18 // Connection: |
| 19 void Connect() override; |
| 20 void Disconnect() override; |
| 21 |
| 22 // Completes the current send operation with success |success|. |
| 23 void FinishSendingMessageWithSuccess(bool success); |
| 24 |
| 25 // Simulates receiving a wire message with the given |payload|, bypassing the |
| 26 // container WireMessage format. |
| 27 void ReceiveMessageWithPayload(const std::string& payload); |
| 28 |
| 29 // Returns the current message in progress of being sent. |
| 30 WireMessage* current_message() { return current_message_.get(); } |
| 31 |
| 32 using Connection::SetStatus; |
| 33 |
| 34 private: |
| 35 // Connection: |
| 36 void SendMessageImpl(scoped_ptr<WireMessage> message) override; |
| 37 scoped_ptr<WireMessage> DeserializeWireMessage( |
| 38 bool* is_incomplete_message) override; |
| 39 |
| 40 // The message currently being sent. Only set between a call to |
| 41 // SendMessageImpl() and FinishSendingMessageWithSuccess(). |
| 42 scoped_ptr<WireMessage> current_message_; |
| 43 |
| 44 // The payload that should be returned when DeserializeWireMessage() is |
| 45 // called. |
| 46 std::string pending_payload_; |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(FakeConnection); |
| 49 }; |
| 50 |
| 51 } // namespace proximity_auth |
| 52 |
| 53 #endif // COMPONENTS_PROXIMITY_AUTH_FAKE_CONNECTION_H |
OLD | NEW |