Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / device / bluetooth / test / mock_bluetooth_device.h
blob0a67a13d1d0628447e7c560e3795f0f3e5f9a7d4
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(GetIdentifier, std::string());
35 MOCK_CONST_METHOD0(GetAddress, std::string());
36 MOCK_CONST_METHOD0(GetVendorIDSource, BluetoothDevice::VendorIDSource());
37 MOCK_CONST_METHOD0(GetVendorID, uint16());
38 MOCK_CONST_METHOD0(GetProductID, uint16());
39 MOCK_CONST_METHOD0(GetDeviceID, uint16());
40 MOCK_CONST_METHOD0(GetName, base::string16());
41 MOCK_CONST_METHOD0(GetDeviceType, BluetoothDevice::DeviceType());
42 MOCK_CONST_METHOD0(IsPaired, bool());
43 MOCK_CONST_METHOD0(IsConnected, bool());
44 MOCK_CONST_METHOD0(IsConnectable, bool());
45 MOCK_CONST_METHOD0(IsConnecting, bool());
46 MOCK_CONST_METHOD0(GetUUIDs, UUIDList());
47 MOCK_CONST_METHOD0(GetInquiryRSSI, int16());
48 MOCK_CONST_METHOD0(GetInquiryTxPower, int16());
49 MOCK_CONST_METHOD0(ExpectingPinCode, bool());
50 MOCK_CONST_METHOD0(ExpectingPasskey, bool());
51 MOCK_CONST_METHOD0(ExpectingConfirmation, bool());
52 MOCK_METHOD1(GetConnectionInfo, void(const ConnectionInfoCallback& callback));
53 MOCK_METHOD3(Connect,
54 void(BluetoothDevice::PairingDelegate* pairing_delegate,
55 const base::Closure& callback,
56 const BluetoothDevice::ConnectErrorCallback&
57 error_callback));
58 MOCK_METHOD1(SetPinCode, void(const std::string&));
59 MOCK_METHOD1(SetPasskey, void(uint32));
60 MOCK_METHOD0(ConfirmPairing, void());
61 MOCK_METHOD0(RejectPairing, void());
62 MOCK_METHOD0(CancelPairing, void());
63 MOCK_METHOD2(Disconnect,
64 void(const base::Closure& callback,
65 const BluetoothDevice::ErrorCallback& error_callback));
66 MOCK_METHOD1(Forget, void(const BluetoothDevice::ErrorCallback&));
67 MOCK_METHOD3(ConnectToService,
68 void(const BluetoothUUID& uuid,
69 const ConnectToServiceCallback& callback,
70 const ConnectToServiceErrorCallback& error_callback));
71 MOCK_METHOD3(ConnectToServiceInsecurely,
72 void(const BluetoothUUID& uuid,
73 const ConnectToServiceCallback& callback,
74 const ConnectToServiceErrorCallback& error_callback));
75 MOCK_METHOD2(CreateGattConnection,
76 void(const GattConnectionCallback& callback,
77 const ConnectErrorCallback& error_callback));
79 MOCK_METHOD2(StartConnectionMonitor,
80 void(const base::Closure& callback,
81 const BluetoothDevice::ErrorCallback& error_callback));
83 MOCK_CONST_METHOD0(GetGattServices, std::vector<BluetoothGattService*>());
84 MOCK_CONST_METHOD1(GetGattService, BluetoothGattService*(const std::string&));
86 // BluetoothDevice manages the lifetime of its BluetoothGATTServices.
87 // This method takes ownership of the MockBluetoothGATTServices. This is only
88 // for convenience as far as testing is concerned, and it's possible to write
89 // test cases without using these functions.
90 // Example:
91 // ON_CALL(*mock_device, GetGattServices))
92 // .WillByDefault(Invoke(*mock_device,
93 // &MockBluetoothDevice::GetMockServices));
94 void AddMockService(scoped_ptr<MockBluetoothGattService> mock_device);
95 std::vector<BluetoothGattService*> GetMockServices() const;
96 BluetoothGattService* GetMockService(const std::string& identifier) const;
98 private:
99 uint32 bluetooth_class_;
100 std::string name_;
101 std::string address_;
102 BluetoothDevice::UUIDList uuids_;
104 ScopedVector<MockBluetoothGattService> mock_services_;
107 } // namespace device
109 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_