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

Side by Side Diff: device/bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc

Issue 2032093002: bluetooth: Fix logic mistake in DeviceChanged (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 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
« no previous file with comments | « device/bluetooth/bluez/bluetooth_device_bluez.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 }; 198 };
199 199
200 TEST_F(BluetoothGattBlueZTest, GattConnection) { 200 TEST_F(BluetoothGattBlueZTest, GattConnection) {
201 fake_bluetooth_device_client_->CreateDevice( 201 fake_bluetooth_device_client_->CreateDevice(
202 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), 202 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath),
203 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 203 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
204 BluetoothDevice* device = 204 BluetoothDevice* device =
205 adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress); 205 adapter_->GetDevice(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress);
206 ASSERT_TRUE(device); 206 ASSERT_TRUE(device);
207 ASSERT_FALSE(device->IsConnected()); 207 ASSERT_FALSE(device->IsConnected());
208 ASSERT_FALSE(device->IsGattConnected());
208 ASSERT_FALSE(gatt_conn_.get()); 209 ASSERT_FALSE(gatt_conn_.get());
209 ASSERT_EQ(0, success_callback_count_); 210 ASSERT_EQ(0, success_callback_count_);
210 ASSERT_EQ(0, error_callback_count_); 211 ASSERT_EQ(0, error_callback_count_);
211 212
212 device->CreateGattConnection( 213 device->CreateGattConnection(
213 base::Bind(&BluetoothGattBlueZTest::GattConnectionCallback, 214 base::Bind(&BluetoothGattBlueZTest::GattConnectionCallback,
214 base::Unretained(this)), 215 base::Unretained(this)),
215 base::Bind(&BluetoothGattBlueZTest::ConnectErrorCallback, 216 base::Bind(&BluetoothGattBlueZTest::ConnectErrorCallback,
216 base::Unretained(this))); 217 base::Unretained(this)));
217 218
218 EXPECT_EQ(1, success_callback_count_); 219 EXPECT_EQ(1, success_callback_count_);
219 EXPECT_EQ(0, error_callback_count_); 220 EXPECT_EQ(0, error_callback_count_);
220 EXPECT_TRUE(device->IsConnected()); 221 EXPECT_TRUE(device->IsConnected());
222 EXPECT_TRUE(device->IsGattConnected());
221 ASSERT_TRUE(gatt_conn_.get()); 223 ASSERT_TRUE(gatt_conn_.get());
222 EXPECT_TRUE(gatt_conn_->IsConnected()); 224 EXPECT_TRUE(gatt_conn_->IsConnected());
223 EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress, 225 EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress,
224 gatt_conn_->GetDeviceAddress()); 226 gatt_conn_->GetDeviceAddress());
225 227
226 gatt_conn_->Disconnect(); 228 gatt_conn_->Disconnect();
227 EXPECT_FALSE(device->IsConnected()); 229 EXPECT_FALSE(device->IsConnected());
230 EXPECT_FALSE(device->IsGattConnected());
228 EXPECT_FALSE(gatt_conn_->IsConnected()); 231 EXPECT_FALSE(gatt_conn_->IsConnected());
229 232
230 device->CreateGattConnection( 233 device->CreateGattConnection(
231 base::Bind(&BluetoothGattBlueZTest::GattConnectionCallback, 234 base::Bind(&BluetoothGattBlueZTest::GattConnectionCallback,
232 base::Unretained(this)), 235 base::Unretained(this)),
233 base::Bind(&BluetoothGattBlueZTest::ConnectErrorCallback, 236 base::Bind(&BluetoothGattBlueZTest::ConnectErrorCallback,
234 base::Unretained(this))); 237 base::Unretained(this)));
235 238
236 EXPECT_EQ(2, success_callback_count_); 239 EXPECT_EQ(2, success_callback_count_);
237 EXPECT_EQ(0, error_callback_count_); 240 EXPECT_EQ(0, error_callback_count_);
238 EXPECT_TRUE(device->IsConnected()); 241 EXPECT_TRUE(device->IsConnected());
242 EXPECT_TRUE(device->IsGattConnected());
239 ASSERT_TRUE(gatt_conn_.get()); 243 ASSERT_TRUE(gatt_conn_.get());
240 EXPECT_TRUE(gatt_conn_->IsConnected()); 244 EXPECT_TRUE(gatt_conn_->IsConnected());
241 245
242 device->Disconnect(base::Bind(&BluetoothGattBlueZTest::SuccessCallback, 246 device->Disconnect(base::Bind(&BluetoothGattBlueZTest::SuccessCallback,
243 base::Unretained(this)), 247 base::Unretained(this)),
244 base::Bind(&BluetoothGattBlueZTest::ErrorCallback, 248 base::Bind(&BluetoothGattBlueZTest::ErrorCallback,
245 base::Unretained(this))); 249 base::Unretained(this)));
246 250
247 EXPECT_EQ(3, success_callback_count_); 251 EXPECT_EQ(3, success_callback_count_);
248 EXPECT_EQ(0, error_callback_count_); 252 EXPECT_EQ(0, error_callback_count_);
249 EXPECT_FALSE(device->IsConnected()); 253 EXPECT_FALSE(device->IsConnected());
254 EXPECT_FALSE(device->IsGattConnected());
250 ASSERT_TRUE(gatt_conn_.get()); 255 ASSERT_TRUE(gatt_conn_.get());
251 EXPECT_FALSE(gatt_conn_->IsConnected()); 256 EXPECT_FALSE(gatt_conn_->IsConnected());
252 257
253 device->CreateGattConnection( 258 device->CreateGattConnection(
254 base::Bind(&BluetoothGattBlueZTest::GattConnectionCallback, 259 base::Bind(&BluetoothGattBlueZTest::GattConnectionCallback,
255 base::Unretained(this)), 260 base::Unretained(this)),
256 base::Bind(&BluetoothGattBlueZTest::ConnectErrorCallback, 261 base::Bind(&BluetoothGattBlueZTest::ConnectErrorCallback,
257 base::Unretained(this))); 262 base::Unretained(this)));
258 263
259 EXPECT_EQ(4, success_callback_count_); 264 EXPECT_EQ(4, success_callback_count_);
260 EXPECT_EQ(0, error_callback_count_); 265 EXPECT_EQ(0, error_callback_count_);
261 EXPECT_TRUE(device->IsConnected()); 266 EXPECT_TRUE(device->IsConnected());
267 EXPECT_TRUE(device->IsGattConnected());
262 EXPECT_TRUE(gatt_conn_->IsConnected()); 268 EXPECT_TRUE(gatt_conn_->IsConnected());
263 269
264 fake_bluetooth_device_client_->RemoveDevice( 270 fake_bluetooth_device_client_->RemoveDevice(
265 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), 271 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath),
266 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 272 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
267 ASSERT_TRUE(gatt_conn_.get()); 273 ASSERT_TRUE(gatt_conn_.get());
268 EXPECT_FALSE(gatt_conn_->IsConnected()); 274 EXPECT_FALSE(gatt_conn_->IsConnected());
269 } 275 }
270 276
271 TEST_F(BluetoothGattBlueZTest, GattServiceAddedAndRemoved) { 277 TEST_F(BluetoothGattBlueZTest, GattServiceAddedAndRemoved) {
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 1352
1347 EXPECT_EQ(1, success_callback_count_); 1353 EXPECT_EQ(1, success_callback_count_);
1348 EXPECT_EQ(0, error_callback_count_); 1354 EXPECT_EQ(0, error_callback_count_);
1349 EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count()); 1355 EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count());
1350 EXPECT_TRUE(characteristic->IsNotifying()); 1356 EXPECT_TRUE(characteristic->IsNotifying());
1351 EXPECT_EQ(1U, update_sessions_.size()); 1357 EXPECT_EQ(1U, update_sessions_.size());
1352 EXPECT_TRUE(update_sessions_[0]->IsActive()); 1358 EXPECT_TRUE(update_sessions_[0]->IsActive());
1353 } 1359 }
1354 1360
1355 } // namespace bluez 1361 } // namespace bluez
OLDNEW
« no previous file with comments | « device/bluetooth/bluez/bluetooth_device_bluez.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698