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

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

Issue 2051333004: Implement BluetoothGattNotifySession::Stop on Android, 2nd attempt (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address new review comments Created 4 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_GATT_NOTIFY_SESSION_H_ 5 #ifndef DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_NOTIFY_SESSION_H_
6 #define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_NOTIFY_SESSION_H_ 6 #define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_NOTIFY_SESSION_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
15 #include "device/bluetooth/bluetooth_gatt_notify_session.h" 15 #include "device/bluetooth/bluetooth_gatt_notify_session.h"
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 17
18 namespace device { 18 namespace device {
19 19
20 class MockBluetoothAdapter; 20 class MockBluetoothAdapter;
21 class MockBluetoothGattCharacteristic; 21 class MockBluetoothGattCharacteristic;
22 22
23 class MockBluetoothGattNotifySession : public BluetoothGattNotifySession { 23 class MockBluetoothGattNotifySession : public BluetoothGattNotifySession {
24 public: 24 public:
25 explicit MockBluetoothGattNotifySession( 25 explicit MockBluetoothGattNotifySession(
26 const std::string& characteristic_identifier); 26 base::WeakPtr<BluetoothRemoteGattCharacteristic> characteristic);
27 virtual ~MockBluetoothGattNotifySession(); 27 virtual ~MockBluetoothGattNotifySession();
28 28
29 MOCK_CONST_METHOD0(GetCharacteristicIdentifier, std::string());
30 MOCK_METHOD0(IsActive, bool()); 29 MOCK_METHOD0(IsActive, bool());
31 MOCK_METHOD1(Stop, void(const base::Closure&)); 30 MOCK_METHOD1(Stop, void(const base::Closure&));
32 31
33 // Starts notifying the adapter's observers that the characteristic's value 32 // Starts notifying the adapter's observers that the characteristic's value
34 // changed. 33 // changed.
35 // TODO(ortuno): Remove the following 3 functions. This is a temporary hack to 34 // TODO(ortuno): Remove the following 3 functions. This is a temporary hack to
36 // get layout tests working with Notifications. 35 // get layout tests working with Notifications.
37 // http://crbug.com/543884 36 // http://crbug.com/543884
38 void StartTestNotifications(MockBluetoothAdapter* adapter, 37 void StartTestNotifications(MockBluetoothAdapter* adapter,
39 MockBluetoothGattCharacteristic* characteristic, 38 MockBluetoothGattCharacteristic* characteristic,
40 const std::vector<uint8_t>& value); 39 const std::vector<uint8_t>& value);
41 void StopTestNotifications(); 40 void StopTestNotifications();
42 41
43 private: 42 private:
44 void DoNotify(MockBluetoothAdapter* adapter, 43 void DoNotify(MockBluetoothAdapter* adapter,
45 MockBluetoothGattCharacteristic* characteristic, 44 MockBluetoothGattCharacteristic* characteristic,
46 const std::vector<uint8_t>& value); 45 const std::vector<uint8_t>& value);
47 46
48 base::RepeatingTimer test_notifications_timer_; 47 base::RepeatingTimer test_notifications_timer_;
49 48
50 DISALLOW_COPY_AND_ASSIGN(MockBluetoothGattNotifySession); 49 DISALLOW_COPY_AND_ASSIGN(MockBluetoothGattNotifySession);
51 }; 50 };
52 51
53 } // namespace device 52 } // namespace device
54 53
55 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_NOTIFY_SESSION_H_ 54 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_GATT_NOTIFY_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698