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