| 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_SECURITY_KEY_IPC_CLIENT_H_ | 5 #ifndef REMOTING_HOST_SECURITY_KEY_FAKE_SECURITY_KEY_IPC_CLIENT_H_ |
| 6 #define REMOTING_HOST_SECURITY_KEY_FAKE_SECURITY_KEY_IPC_CLIENT_H_ | 6 #define REMOTING_HOST_SECURITY_KEY_FAKE_SECURITY_KEY_IPC_CLIENT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "remoting/host/security_key/remote_security_key_ipc_client.h" | 14 #include "remoting/host/security_key/security_key_ipc_client.h" |
| 15 | 15 |
| 16 namespace IPC { | 16 namespace IPC { |
| 17 class Channel; | 17 class Channel; |
| 18 class Message; | 18 class Message; |
| 19 } // IPC | 19 } // IPC |
| 20 | 20 |
| 21 namespace remoting { | 21 namespace remoting { |
| 22 | 22 |
| 23 // Simulates the RemoteSecurityKeyIpcClient and provides access to data members | 23 // Simulates the SecurityKeyIpcClient and provides access to data members |
| 24 // for testing. This class is used for scenarios which require an IPC channel | 24 // for testing. This class is used for scenarios which require an IPC channel |
| 25 // as well as for tests which only need callbacks activated. | 25 // as well as for tests which only need callbacks activated. |
| 26 class FakeRemoteSecurityKeyIpcClient : public RemoteSecurityKeyIpcClient { | 26 class FakeSecurityKeyIpcClient : public SecurityKeyIpcClient { |
| 27 public: | 27 public: |
| 28 explicit FakeRemoteSecurityKeyIpcClient( | 28 explicit FakeSecurityKeyIpcClient( |
| 29 const base::Closure& channel_event_callback); | 29 const base::Closure& channel_event_callback); |
| 30 ~FakeRemoteSecurityKeyIpcClient() override; | 30 ~FakeSecurityKeyIpcClient() override; |
| 31 | 31 |
| 32 // RemoteSecurityKeyIpcClient interface. | 32 // SecurityKeyIpcClient interface. |
| 33 bool WaitForSecurityKeyIpcServerChannel() override; | 33 bool WaitForSecurityKeyIpcServerChannel() override; |
| 34 void EstablishIpcConnection( | 34 void EstablishIpcConnection( |
| 35 const base::Closure& connection_ready_callback, | 35 const base::Closure& connection_ready_callback, |
| 36 const base::Closure& connection_error_callback) override; | 36 const base::Closure& connection_error_callback) override; |
| 37 bool SendSecurityKeyRequest( | 37 bool SendSecurityKeyRequest( |
| 38 const std::string& request_payload, | 38 const std::string& request_payload, |
| 39 const ResponseCallback& response_callback) override; | 39 const ResponseCallback& response_callback) override; |
| 40 void CloseIpcConnection() override; | 40 void CloseIpcConnection() override; |
| 41 | 41 |
| 42 // Connects as a client to the |channel_name| IPC Channel. | 42 // Connects as a client to the |channel_name| IPC Channel. |
| 43 bool ConnectViaIpc(const std::string& channel_name); | 43 bool ConnectViaIpc(const std::string& channel_name); |
| 44 | 44 |
| 45 // Override of SendSecurityKeyRequest() interface method for tests which use | 45 // Override of SendSecurityKeyRequest() interface method for tests which use |
| 46 // an IPC channel for testing. | 46 // an IPC channel for testing. |
| 47 void SendSecurityKeyRequestViaIpc(const std::string& request_payload); | 47 void SendSecurityKeyRequestViaIpc(const std::string& request_payload); |
| 48 | 48 |
| 49 base::WeakPtr<FakeRemoteSecurityKeyIpcClient> AsWeakPtr(); | 49 base::WeakPtr<FakeSecurityKeyIpcClient> AsWeakPtr(); |
| 50 | 50 |
| 51 const std::string& last_message_received() const { | 51 const std::string& last_message_received() const { |
| 52 return last_message_received_; | 52 return last_message_received_; |
| 53 } | 53 } |
| 54 | 54 |
| 55 bool ipc_channel_connected() { return ipc_channel_connected_; } | 55 bool ipc_channel_connected() { return ipc_channel_connected_; } |
| 56 | 56 |
| 57 void set_wait_for_ipc_channel_return_value(bool return_value) { | 57 void set_wait_for_ipc_channel_return_value(bool return_value) { |
| 58 wait_for_ipc_channel_return_value_ = return_value; | 58 wait_for_ipc_channel_return_value_ = return_value; |
| 59 } | 59 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 100 |
| 101 // Value returned by WaitForSecurityKeyIpcServerChannel() method. | 101 // Value returned by WaitForSecurityKeyIpcServerChannel() method. |
| 102 bool wait_for_ipc_channel_return_value_ = true; | 102 bool wait_for_ipc_channel_return_value_ = true; |
| 103 | 103 |
| 104 // Stores whether a connection to the server IPC channel is active. | 104 // Stores whether a connection to the server IPC channel is active. |
| 105 bool ipc_channel_connected_ = false; | 105 bool ipc_channel_connected_ = false; |
| 106 | 106 |
| 107 // Value returned by SendSecurityKeyRequest() method. | 107 // Value returned by SendSecurityKeyRequest() method. |
| 108 std::string security_key_response_payload_; | 108 std::string security_key_response_payload_; |
| 109 | 109 |
| 110 base::WeakPtrFactory<FakeRemoteSecurityKeyIpcClient> weak_factory_; | 110 base::WeakPtrFactory<FakeSecurityKeyIpcClient> weak_factory_; |
| 111 | 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(FakeRemoteSecurityKeyIpcClient); | 112 DISALLOW_COPY_AND_ASSIGN(FakeSecurityKeyIpcClient); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 } // namespace remoting | 115 } // namespace remoting |
| 116 | 116 |
| 117 #endif // REMOTING_HOST_SECURITY_KEY_FAKE_SECURITY_KEY_IPC_CLIENT_H_ | 117 #endif // REMOTING_HOST_SECURITY_KEY_FAKE_SECURITY_KEY_IPC_CLIENT_H_ |
| OLD | NEW |