 Chromium Code Reviews
 Chromium Code Reviews Issue 1382743002:
  bluetooth: Add characteristicvaluechanged event  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-notifications-1
    
  
    Issue 1382743002:
  bluetooth: Add characteristicvaluechanged event  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-notifications-1| OLD | NEW | 
|---|---|
| 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 #include "device/bluetooth/test/mock_bluetooth_gatt_notify_session.h" | 5 #include "device/bluetooth/test/mock_bluetooth_gatt_notify_session.h" | 
| 6 #include "device/bluetooth/test/mock_bluetooth_adapter.h" | |
| 7 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" | |
| 6 | 8 | 
| 7 using testing::Return; | 9 using testing::Return; | 
| 8 | 10 | 
| 9 namespace device { | 11 namespace device { | 
| 10 | 12 | 
| 11 MockBluetoothGattNotifySession::MockBluetoothGattNotifySession( | 13 MockBluetoothGattNotifySession::MockBluetoothGattNotifySession( | 
| 12 const std::string& characteristic_identifier) { | 14 const std::string& characteristic_identifier) { | 
| 13 ON_CALL(*this, GetCharacteristicIdentifier()) | 15 ON_CALL(*this, GetCharacteristicIdentifier()) | 
| 14 .WillByDefault(Return(characteristic_identifier)); | 16 .WillByDefault(Return(characteristic_identifier)); | 
| 15 ON_CALL(*this, IsActive()).WillByDefault(Return(true)); | 17 ON_CALL(*this, IsActive()).WillByDefault(Return(true)); | 
| 16 } | 18 } | 
| 17 | 19 | 
| 18 MockBluetoothGattNotifySession::~MockBluetoothGattNotifySession() { | 20 MockBluetoothGattNotifySession::~MockBluetoothGattNotifySession() { | 
| 19 } | 21 } | 
| 20 | 22 | 
| 23 void MockBluetoothGattNotifySession::StartTestNotifications( | |
| 24 MockBluetoothAdapter* adapter, | |
| 25 MockBluetoothGattCharacteristic* characteristic, | |
| 26 const std::vector<uint8_t>& value) { | |
| 27 test_notifications_timer_.Start( | |
| 28 FROM_HERE, base::TimeDelta::FromMilliseconds(10), | |
| 29 base::Bind(&MockBluetoothGattNotifySession::TestNotify, | |
| 30 // base::Timer guarantees it won't call back after its | |
| 31 // destructor starts. | |
| 32 base::Unretained(this), base::Unretained(adapter), | |
| 33 characteristic, value)); | |
| 34 } | |
| 35 | |
| 36 void MockBluetoothGattNotifySession::StopTestNotifications() { | |
| 37 test_notifications_timer_.Stop(); | |
| 38 } | |
| 39 | |
| 40 void MockBluetoothGattNotifySession::TestNotify( | |
| 
Jeffrey Yasskin
2015/10/15 23:00:51
Maybe "DoNotify" since this actually notifies the
 
ortuno
2015/10/16 01:24:21
Done.
 | |
| 41 MockBluetoothAdapter* adapter, | |
| 42 MockBluetoothGattCharacteristic* characteristic, | |
| 43 const std::vector<uint8_t>& value) { | |
| 44 FOR_EACH_OBSERVER( | |
| 45 BluetoothAdapter::Observer, adapter->GetObservers(), | |
| 46 GattCharacteristicValueChanged(adapter, characteristic, value)); | |
| 47 } | |
| 48 | |
| 21 } // namespace device | 49 } // namespace device | 
| OLD | NEW |