1 // Copyright 2018 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 CHROMEOS_SERVICES_SECURE_CHANNEL_FAKE_SECURE_CHANNEL_H_ 6 #define CHROMEOS_SERVICES_SECURE_CHANNEL_FAKE_SECURE_CHANNEL_H_ 7 8 #include <memory> 9 #include <string> 10 #include <tuple> 11 #include <vector> 12 13 #include "base/macros.h" 14 #include "chromeos/components/multidevice/remote_device_cache.h" 15 #include "chromeos/services/secure_channel/public/mojom/secure_channel.mojom.h" 16 #include "chromeos/services/secure_channel/secure_channel_base.h" 17 #include "mojo/public/cpp/bindings/pending_remote.h" 18 #include "mojo/public/cpp/bindings/remote.h" 19 20 namespace chromeos { 21 22 namespace secure_channel { 23 24 // Test double SecureChannel implementation. 25 class FakeSecureChannel : public SecureChannelBase { 26 public: 27 FakeSecureChannel(); 28 ~FakeSecureChannel() override; 29 delegate_from_last_listen_call()30 mojo::Remote<mojom::ConnectionDelegate> delegate_from_last_listen_call() { 31 return std::move(delegate_from_last_listen_call_); 32 } 33 delegate_from_last_initiate_call()34 mojo::Remote<mojom::ConnectionDelegate> delegate_from_last_initiate_call() { 35 return std::move(delegate_from_last_initiate_call_); 36 } 37 38 private: 39 // mojom::SecureChannel: 40 void ListenForConnectionFromDevice( 41 const multidevice::RemoteDevice& device_to_connect, 42 const multidevice::RemoteDevice& local_device, 43 const std::string& feature, 44 ConnectionMedium connection_medium, 45 ConnectionPriority connection_priority, 46 mojo::PendingRemote<mojom::ConnectionDelegate> delegate) override; 47 void InitiateConnectionToDevice( 48 const multidevice::RemoteDevice& device_to_connect, 49 const multidevice::RemoteDevice& local_device, 50 const std::string& feature, 51 ConnectionMedium connection_medium, 52 ConnectionPriority connection_priority, 53 mojo::PendingRemote<mojom::ConnectionDelegate> delegate) override; SetNearbyConnector(mojo::PendingRemote<mojom::NearbyConnector> nearby_connector)54 void SetNearbyConnector( 55 mojo::PendingRemote<mojom::NearbyConnector> nearby_connector) override {} 56 57 mojo::Remote<mojom::ConnectionDelegate> delegate_from_last_listen_call_; 58 mojo::Remote<mojom::ConnectionDelegate> delegate_from_last_initiate_call_; 59 60 DISALLOW_COPY_AND_ASSIGN(FakeSecureChannel); 61 }; 62 63 } // namespace secure_channel 64 65 } // namespace chromeos 66 67 #endif // CHROMEOS_SERVICES_SECURE_CHANNEL_FAKE_SECURE_CHANNEL_H_ 68