1 // Copyright (c) 2013 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_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ 6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ 7 8 #include "base/bind.h" 9 #include "base/callback.h" 10 #include "base/memory/scoped_ptr.h" 11 #include "chromeos/chromeos_export.h" 12 #include "chromeos/dbus/bluetooth_profile_service_provider.h" 13 #include "chromeos/dbus/dbus_client_implementation_type.h" 14 #include "dbus/file_descriptor.h" 15 #include "dbus/object_path.h" 16 17 namespace chromeos { 18 19 // FakeBluetoothProfileServiceProvider simulates the behavior of a local 20 // Bluetooth agent object and is used both in test cases in place of a 21 // mock and on the Linux desktop. 22 class CHROMEOS_EXPORT FakeBluetoothProfileServiceProvider 23 : public BluetoothProfileServiceProvider { 24 public: 25 FakeBluetoothProfileServiceProvider(const dbus::ObjectPath& object_path, 26 Delegate *delegate); 27 virtual ~FakeBluetoothProfileServiceProvider(); 28 29 // Each of these calls the equivalent 30 // BluetoothProfileServiceProvider::Delegate method on the object passed on 31 // construction. 32 virtual void Release(); 33 virtual void NewConnection( 34 const dbus::ObjectPath& device_path, 35 scoped_ptr<dbus::FileDescriptor> fd, 36 const Delegate::Options& options, 37 const Delegate::ConfirmationCallback& callback); 38 virtual void RequestDisconnection( 39 const dbus::ObjectPath& device_path, 40 const Delegate::ConfirmationCallback& callback); 41 virtual void Cancel(); 42 43 private: 44 friend class FakeBluetoothProfileManagerClient; 45 46 // D-Bus object path we are faking. 47 dbus::ObjectPath object_path_; 48 49 // All incoming method calls are passed on to the Delegate and a callback 50 // passed to generate the reply. |delegate_| is generally the object that 51 // owns this one, and must outlive it. 52 Delegate* delegate_; 53 }; 54 55 } // namespace chromeos 56 57 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_PROFILE_SERVICE_PROVIDER_H_ 58