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

Side by Side Diff: device/bluetooth/test/test_bluetooth_adapter_observer.cc

Issue 1341103004: Handle change of BLE address after pairing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased onto latest master Created 5 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/test_bluetooth_adapter_observer.h" 5 #include "device/bluetooth/test/test_bluetooth_adapter_observer.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "device/bluetooth/bluetooth_gatt_characteristic.h" 8 #include "device/bluetooth/bluetooth_gatt_characteristic.h"
9 #include "device/bluetooth/bluetooth_gatt_descriptor.h" 9 #include "device/bluetooth/bluetooth_gatt_descriptor.h"
10 #include "device/bluetooth/bluetooth_gatt_service.h" 10 #include "device/bluetooth/bluetooth_gatt_service.h"
(...skipping 15 matching lines...) Expand all
26 void TestBluetoothAdapterObserver::Reset() { 26 void TestBluetoothAdapterObserver::Reset() {
27 present_changed_count_ = 0; 27 present_changed_count_ = 0;
28 powered_changed_count_ = 0; 28 powered_changed_count_ = 0;
29 discoverable_changed_count_ = 0; 29 discoverable_changed_count_ = 0;
30 discovering_changed_count_ = 0; 30 discovering_changed_count_ = 0;
31 last_present_ = false; 31 last_present_ = false;
32 last_powered_ = false; 32 last_powered_ = false;
33 last_discovering_ = false; 33 last_discovering_ = false;
34 device_added_count_ = 0; 34 device_added_count_ = 0;
35 device_changed_count_ = 0; 35 device_changed_count_ = 0;
36 device_address_changed_count_ = 0;
36 device_removed_count_ = 0; 37 device_removed_count_ = 0;
37 last_device_ = NULL; 38 last_device_ = NULL;
38 last_device_address_.clear(); 39 last_device_address_.clear();
39 gatt_service_added_count_ = 0; 40 gatt_service_added_count_ = 0;
40 gatt_service_removed_count_ = 0; 41 gatt_service_removed_count_ = 0;
41 gatt_service_changed_count_ = 0; 42 gatt_service_changed_count_ = 0;
42 gatt_discovery_complete_count_ = 0; 43 gatt_discovery_complete_count_ = 0;
43 gatt_characteristic_added_count_ = 0; 44 gatt_characteristic_added_count_ = 0;
44 gatt_characteristic_removed_count_ = 0; 45 gatt_characteristic_removed_count_ = 0;
45 gatt_characteristic_value_changed_count_ = 0; 46 gatt_characteristic_value_changed_count_ = 0;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 BluetoothDevice* device) { 107 BluetoothDevice* device) {
107 EXPECT_EQ(adapter_.get(), adapter); 108 EXPECT_EQ(adapter_.get(), adapter);
108 109
109 ++device_changed_count_; 110 ++device_changed_count_;
110 last_device_ = device; 111 last_device_ = device;
111 last_device_address_ = device->GetAddress(); 112 last_device_address_ = device->GetAddress();
112 113
113 QuitMessageLoop(); 114 QuitMessageLoop();
114 } 115 }
115 116
117 void TestBluetoothAdapterObserver::DeviceAddressChanged(
118 device::BluetoothAdapter* adapter,
119 device::BluetoothDevice* device,
120 const std::string& old_address) {
121 ++device_address_changed_count_;
122 last_device_ = device;
123 last_device_address_ = device->GetAddress();
124
125 QuitMessageLoop();
126 }
127
116 void TestBluetoothAdapterObserver::DeviceRemoved(BluetoothAdapter* adapter, 128 void TestBluetoothAdapterObserver::DeviceRemoved(BluetoothAdapter* adapter,
117 BluetoothDevice* device) { 129 BluetoothDevice* device) {
118 EXPECT_EQ(adapter_.get(), adapter); 130 EXPECT_EQ(adapter_.get(), adapter);
119 131
120 ++device_removed_count_; 132 ++device_removed_count_;
121 // Can't save device, it may be freed 133 // Can't save device, it may be freed
122 last_device_address_ = device->GetAddress(); 134 last_device_address_ = device->GetAddress();
123 135
124 QuitMessageLoop(); 136 QuitMessageLoop();
125 } 137 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 QuitMessageLoop(); 299 QuitMessageLoop();
288 } 300 }
289 301
290 void TestBluetoothAdapterObserver::QuitMessageLoop() { 302 void TestBluetoothAdapterObserver::QuitMessageLoop() {
291 if (base::MessageLoop::current() && 303 if (base::MessageLoop::current() &&
292 base::MessageLoop::current()->is_running()) 304 base::MessageLoop::current()->is_running())
293 base::MessageLoop::current()->Quit(); 305 base::MessageLoop::current()->Quit();
294 } 306 }
295 307
296 } // namespace device 308 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698