OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 REMOTING_HOST_SECURITY_KEY_FAKE_REMOTE_SECURITY_KEY_MESSAGE_WRITER_H_ |
| 6 #define REMOTING_HOST_SECURITY_KEY_FAKE_REMOTE_SECURITY_KEY_MESSAGE_WRITER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "remoting/host/security_key/remote_security_key_message_writer.h" |
| 14 #include "remoting/host/security_key/security_key_message.h" |
| 15 |
| 16 namespace remoting { |
| 17 |
| 18 // Simulates the RemoteSecurityKeyMessageWriter and provides access to data |
| 19 // members for testing. |
| 20 class FakeRemoteSecurityKeyMessageWriter |
| 21 : public RemoteSecurityKeyMessageWriter { |
| 22 public: |
| 23 explicit FakeRemoteSecurityKeyMessageWriter( |
| 24 const base::Closure& write_callback); |
| 25 ~FakeRemoteSecurityKeyMessageWriter() override; |
| 26 |
| 27 // RemoteSecurityKeyMessageWriter interface. |
| 28 bool WriteMessage(RemoteSecurityKeyMessageType message_type) override; |
| 29 bool WriteMessageWithPayload(RemoteSecurityKeyMessageType message_type, |
| 30 const std::string& message_payload) override; |
| 31 |
| 32 base::WeakPtr<FakeRemoteSecurityKeyMessageWriter> AsWeakPtr(); |
| 33 |
| 34 RemoteSecurityKeyMessageType last_message_type() { |
| 35 return last_message_type_; |
| 36 } |
| 37 |
| 38 const std::string& last_message_payload() { return last_message_payload_; } |
| 39 |
| 40 void set_write_request_succeeded(bool should_succeed) { |
| 41 write_request_succeeded_ = should_succeed; |
| 42 } |
| 43 |
| 44 private: |
| 45 // Tracks the last message_type value written. |
| 46 RemoteSecurityKeyMessageType last_message_type_ = |
| 47 RemoteSecurityKeyMessageType::INVALID; |
| 48 |
| 49 // Tracks the last message_payload value written. |
| 50 std::string last_message_payload_; |
| 51 |
| 52 // This value is returned by the WriteMessage* functions above. |
| 53 bool write_request_succeeded_ = true; |
| 54 |
| 55 // Signaled whenever a write is requested. |
| 56 base::Closure write_callback_; |
| 57 |
| 58 base::WeakPtrFactory<FakeRemoteSecurityKeyMessageWriter> weak_factory_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(FakeRemoteSecurityKeyMessageWriter); |
| 61 }; |
| 62 |
| 63 } // namespace remoting |
| 64 |
| 65 #endif // REMOTING_HOST_SECURITY_KEY_FAKE_REMOTE_SECURITY_KEY_MESSAGE_WRITER_H_ |
OLD | NEW |