QUIC - cleanup changes to sync chromium tree with internal source.
[chromium-blink-merge.git] / device / bluetooth / test / mock_bluetooth_device.h
blobb5948f651c12f07b9f7fc51f989554521614885a
1 // Copyright (c) 2012 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.
5 #ifndef DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_
6 #define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_
8 #include <string>
10 #include "base/memory/scoped_vector.h"
11 #include "base/strings/string16.h"
12 #include "device/bluetooth/bluetooth_device.h"
13 #include "device/bluetooth/bluetooth_uuid.h"
14 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h"
15 #include "testing/gmock/include/gmock/gmock.h"
17 namespace device {
19 class BluetoothGattService;
20 class MockBluetoothAdapter;
22 class MockBluetoothDevice : public BluetoothDevice {
23 public:
24 MockBluetoothDevice(MockBluetoothAdapter* adapter,
25 uint32 bluetooth_class,
26 const std::string& name,
27 const std::string& address,
28 bool paired,
29 bool connected);
30 virtual ~MockBluetoothDevice();
32 MOCK_CONST_METHOD0(GetBluetoothClass, uint32());
33 MOCK_CONST_METHOD0(GetDeviceName, std::string());
34 MOCK_CONST_METHOD0(GetAddress, std::string());
35 MOCK_CONST_METHOD0(GetVendorIDSource, BluetoothDevice::VendorIDSource());
36 MOCK_CONST_METHOD0(GetVendorID, uint16());
37 MOCK_CONST_METHOD0(GetProductID, uint16());
38 MOCK_CONST_METHOD0(GetDeviceID, uint16());
39 MOCK_CONST_METHOD0(GetName, base::string16());
40 MOCK_CONST_METHOD0(GetDeviceType, BluetoothDevice::DeviceType());
41 MOCK_CONST_METHOD0(IsPaired, bool());
42 MOCK_CONST_METHOD0(IsConnected, bool());
43 MOCK_CONST_METHOD0(IsConnectable, bool());
44 MOCK_CONST_METHOD0(IsConnecting, bool());
45 MOCK_CONST_METHOD0(GetUUIDs, UUIDList());
46 MOCK_CONST_METHOD0(GetInquiryRSSI, int16());
47 MOCK_CONST_METHOD0(GetInquiryTxPower, int16());
48 MOCK_CONST_METHOD0(ExpectingPinCode, bool());
49 MOCK_CONST_METHOD0(ExpectingPasskey, bool());
50 MOCK_CONST_METHOD0(ExpectingConfirmation, bool());
51 MOCK_METHOD1(GetConnectionInfo, void(const ConnectionInfoCallback& callback));
52 MOCK_METHOD3(Connect,
53 void(BluetoothDevice::PairingDelegate* pairing_delegate,
54 const base::Closure& callback,
55 const BluetoothDevice::ConnectErrorCallback&
56 error_callback));
57 MOCK_METHOD1(SetPinCode, void(const std::string&));
58 MOCK_METHOD1(SetPasskey, void(uint32));
59 MOCK_METHOD0(ConfirmPairing, void());
60 MOCK_METHOD0(RejectPairing, void());
61 MOCK_METHOD0(CancelPairing, void());
62 MOCK_METHOD2(Disconnect,
63 void(const base::Closure& callback,
64 const BluetoothDevice::ErrorCallback& error_callback));
65 MOCK_METHOD1(Forget, void(const BluetoothDevice::ErrorCallback&));
66 MOCK_METHOD3(ConnectToService,
67 void(const BluetoothUUID& uuid,
68 const ConnectToServiceCallback& callback,
69 const ConnectToServiceErrorCallback& error_callback));
70 MOCK_METHOD3(ConnectToServiceInsecurely,
71 void(const BluetoothUUID& uuid,
72 const ConnectToServiceCallback& callback,
73 const ConnectToServiceErrorCallback& error_callback));
74 MOCK_METHOD2(CreateGattConnection,
75 void(const GattConnectionCallback& callback,
76 const ConnectErrorCallback& error_callback));
78 MOCK_METHOD2(StartConnectionMonitor,
79 void(const base::Closure& callback,
80 const BluetoothDevice::ErrorCallback& error_callback));
82 MOCK_CONST_METHOD0(GetGattServices, std::vector<BluetoothGattService*>());
83 MOCK_CONST_METHOD1(GetGattService, BluetoothGattService*(const std::string&));
85 // BluetoothDevice manages the lifetime of its BluetoothGATTServices.
86 // This method takes ownership of the MockBluetoothGATTServices. This is only
87 // for convenience as far as testing is concerned, and it's possible to write
88 // test cases without using these functions.
89 // Example:
90 // ON_CALL(*mock_device, GetGattServices))
91 // .WillByDefault(Invoke(*mock_device,
92 // &MockBluetoothDevice::GetMockServices));
93 void AddMockService(scoped_ptr<MockBluetoothGattService> mock_device);
94 std::vector<BluetoothGattService*> GetMockServices() const;
95 BluetoothGattService* GetMockService(const std::string& identifier) const;
97 private:
98 uint32 bluetooth_class_;
99 std::string name_;
100 std::string address_;
101 BluetoothDevice::UUIDList uuids_;
103 ScopedVector<MockBluetoothGattService> mock_services_;
106 } // namespace device
108 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_