Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: device/bluetooth/test/mock_bluetooth_device.h

Issue 1159523002: bluetooth: Browser side partial implementation of getPrimaryService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed order of gypi Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ 5 #ifndef DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_
6 #define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ 6 #define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_vector.h"
10 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
11 #include "device/bluetooth/bluetooth_device.h" 12 #include "device/bluetooth/bluetooth_device.h"
12 #include "device/bluetooth/bluetooth_uuid.h" 13 #include "device/bluetooth/bluetooth_uuid.h"
14 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h"
13 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
14 16
15 namespace device { 17 namespace device {
16 18
19 class BluetoothGattService;
17 class MockBluetoothAdapter; 20 class MockBluetoothAdapter;
18 21
19 class MockBluetoothDevice : public BluetoothDevice { 22 class MockBluetoothDevice : public BluetoothDevice {
20 public: 23 public:
21 MockBluetoothDevice(MockBluetoothAdapter* adapter, 24 MockBluetoothDevice(MockBluetoothAdapter* adapter,
22 uint32 bluetooth_class, 25 uint32 bluetooth_class,
23 const std::string& name, 26 const std::string& name,
24 const std::string& address, 27 const std::string& address,
25 bool paired, 28 bool paired,
26 bool connected); 29 bool connected);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 void(const GattConnectionCallback& callback, 75 void(const GattConnectionCallback& callback,
73 const ConnectErrorCallback& error_callback)); 76 const ConnectErrorCallback& error_callback));
74 77
75 MOCK_METHOD2(StartConnectionMonitor, 78 MOCK_METHOD2(StartConnectionMonitor,
76 void(const base::Closure& callback, 79 void(const base::Closure& callback,
77 const BluetoothDevice::ErrorCallback& error_callback)); 80 const BluetoothDevice::ErrorCallback& error_callback));
78 81
79 MOCK_CONST_METHOD0(GetGattServices, std::vector<BluetoothGattService*>()); 82 MOCK_CONST_METHOD0(GetGattServices, std::vector<BluetoothGattService*>());
80 MOCK_CONST_METHOD1(GetGattService, BluetoothGattService*(const std::string&)); 83 MOCK_CONST_METHOD1(GetGattService, BluetoothGattService*(const std::string&));
81 84
85 // BluetoothDevice manages the lifetime of its BluetoothGATTServices.
86 // This methods takes ownership of the BluetoothGATTServices. This is only for
87 // convenience as far as testing is concerned, and it's possible to write test
88 // cases without using these functions.
89 // Example:
scheib 2015/05/31 19:48:41 I should have been clearer, include a more complet
ortuno 2015/06/01 18:27:03 Done.
90 // .WillByDefault(Invoke(*mock_device,
91 // &MockBluetoothDevice::GetMockServices));
92 void AddMockService(scoped_ptr<MockBluetoothGattService> mock_device);
93 std::vector<BluetoothGattService*> GetMockServices();
94
82 private: 95 private:
83 uint32 bluetooth_class_; 96 uint32 bluetooth_class_;
84 std::string name_; 97 std::string name_;
85 std::string address_; 98 std::string address_;
86 BluetoothDevice::UUIDList uuids_; 99 BluetoothDevice::UUIDList uuids_;
100
101 ScopedVector<MockBluetoothGattService> mock_services_;
87 }; 102 };
88 103
89 } // namespace device 104 } // namespace device
90 105
91 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_ 106 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698