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

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

Issue 1984493002: Address property removals of GATT service and characteristic interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | device/bluetooth/bluez/bluetooth_remote_gatt_service_bluez.cc » ('j') | 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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count()); 443 EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
444 EXPECT_TRUE(service->GetCharacteristics().empty()); 444 EXPECT_TRUE(service->GetCharacteristics().empty());
445 445
446 // Run the message loop so that the characteristics appear. 446 // Run the message loop so that the characteristics appear.
447 base::MessageLoop::current()->Run(); 447 base::MessageLoop::current()->Run();
448 448
449 // 3 characteristics should appear. Only 1 of the characteristics sends 449 // 3 characteristics should appear. Only 1 of the characteristics sends
450 // value changed signals. Service changed should be fired once for 450 // value changed signals. Service changed should be fired once for
451 // descriptor added. 451 // descriptor added.
452 EXPECT_EQ(0, observer.gatt_service_changed_count()); 452 EXPECT_EQ(0, observer.gatt_service_changed_count());
453 EXPECT_EQ(1, observer.gatt_discovery_complete_count());
454 EXPECT_EQ(3, observer.gatt_characteristic_added_count()); 453 EXPECT_EQ(3, observer.gatt_characteristic_added_count());
455 EXPECT_EQ(0, observer.gatt_characteristic_removed_count()); 454 EXPECT_EQ(0, observer.gatt_characteristic_removed_count());
456 EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count()); 455 EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
457 EXPECT_EQ(3U, service->GetCharacteristics().size()); 456 EXPECT_EQ(3U, service->GetCharacteristics().size());
458 457
459 // Hide the characteristics. 3 removed signals should be received. 458 // Hide the characteristics. 3 removed signals should be received.
460 fake_bluetooth_gatt_characteristic_client_->HideHeartRateCharacteristics(); 459 fake_bluetooth_gatt_characteristic_client_->HideHeartRateCharacteristics();
461 EXPECT_EQ(0, observer.gatt_service_changed_count()); 460 EXPECT_EQ(0, observer.gatt_service_changed_count());
462 EXPECT_EQ(3, observer.gatt_characteristic_added_count()); 461 EXPECT_EQ(3, observer.gatt_characteristic_added_count());
463 EXPECT_EQ(3, observer.gatt_characteristic_removed_count()); 462 EXPECT_EQ(3, observer.gatt_characteristic_removed_count());
464 EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count()); 463 EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
465 EXPECT_TRUE(service->GetCharacteristics().empty()); 464 EXPECT_TRUE(service->GetCharacteristics().empty());
466 465
467 // Re-expose the heart rate characteristics. We shouldn't get another 466 // Re-expose the heart rate characteristics. We shouldn't get another
468 // GattDiscoveryCompleteForService call, since the service thinks that 467 // GattDiscoveryCompleteForService call, since the service thinks that
469 // discovery is done. On the bluetoothd side, characteristics will be removed 468 // discovery is done. On the bluetoothd side, characteristics will be removed
470 // only if the service will also be subsequently removed. 469 // only if the service will also be subsequently removed.
471 fake_bluetooth_gatt_characteristic_client_->ExposeHeartRateCharacteristics( 470 fake_bluetooth_gatt_characteristic_client_->ExposeHeartRateCharacteristics(
472 fake_bluetooth_gatt_service_client_->GetHeartRateServicePath()); 471 fake_bluetooth_gatt_service_client_->GetHeartRateServicePath());
473 EXPECT_EQ(0, observer.gatt_service_changed_count()); 472 EXPECT_EQ(0, observer.gatt_service_changed_count());
474 EXPECT_EQ(1, observer.gatt_discovery_complete_count());
475 EXPECT_EQ(6, observer.gatt_characteristic_added_count()); 473 EXPECT_EQ(6, observer.gatt_characteristic_added_count());
476 EXPECT_EQ(3, observer.gatt_characteristic_removed_count()); 474 EXPECT_EQ(3, observer.gatt_characteristic_removed_count());
477 EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count()); 475 EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
478 EXPECT_EQ(3U, service->GetCharacteristics().size()); 476 EXPECT_EQ(3U, service->GetCharacteristics().size());
479 477
480 // Hide the service. All characteristics should disappear. 478 // Hide the service. All characteristics should disappear.
481 fake_bluetooth_gatt_service_client_->HideHeartRateService(); 479 fake_bluetooth_gatt_service_client_->HideHeartRateService();
482 EXPECT_EQ(0, observer.gatt_service_changed_count()); 480 EXPECT_EQ(0, observer.gatt_service_changed_count());
483 EXPECT_EQ(6, observer.gatt_characteristic_added_count()); 481 EXPECT_EQ(6, observer.gatt_characteristic_added_count());
484 EXPECT_EQ(6, observer.gatt_characteristic_removed_count()); 482 EXPECT_EQ(6, observer.gatt_characteristic_removed_count());
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 // Expose the fake Heart Rate service. This will asynchronously expose 918 // Expose the fake Heart Rate service. This will asynchronously expose
921 // characteristics. 919 // characteristics.
922 fake_bluetooth_gatt_service_client_->ExposeHeartRateService( 920 fake_bluetooth_gatt_service_client_->ExposeHeartRateService(
923 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); 921 dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
924 ASSERT_EQ(1, observer.gatt_service_added_count()); 922 ASSERT_EQ(1, observer.gatt_service_added_count());
925 923
926 BluetoothRemoteGattService* service = 924 BluetoothRemoteGattService* service =
927 device->GetGattService(observer.last_gatt_service_id()); 925 device->GetGattService(observer.last_gatt_service_id());
928 926
929 EXPECT_EQ(0, observer.gatt_service_changed_count()); 927 EXPECT_EQ(0, observer.gatt_service_changed_count());
930 EXPECT_EQ(0, observer.gatt_discovery_complete_count());
931 EXPECT_EQ(0, observer.gatt_descriptor_value_changed_count()); 928 EXPECT_EQ(0, observer.gatt_descriptor_value_changed_count());
932 EXPECT_TRUE(service->GetCharacteristics().empty()); 929 EXPECT_TRUE(service->GetCharacteristics().empty());
933 930
934 // Run the message loop so that the characteristics appear. 931 // Run the message loop so that the characteristics appear.
935 base::MessageLoop::current()->Run(); 932 base::MessageLoop::current()->Run();
936 EXPECT_EQ(0, observer.gatt_service_changed_count()); 933 EXPECT_EQ(0, observer.gatt_service_changed_count());
937 EXPECT_EQ(1, observer.gatt_discovery_complete_count());
938 934
939 // Only the Heart Rate Measurement characteristic has a descriptor. 935 // Only the Heart Rate Measurement characteristic has a descriptor.
940 BluetoothRemoteGattCharacteristic* characteristic = 936 BluetoothRemoteGattCharacteristic* characteristic =
941 service->GetCharacteristic(fake_bluetooth_gatt_characteristic_client_ 937 service->GetCharacteristic(fake_bluetooth_gatt_characteristic_client_
942 ->GetHeartRateMeasurementPath() 938 ->GetHeartRateMeasurementPath()
943 .value()); 939 .value());
944 ASSERT_TRUE(characteristic); 940 ASSERT_TRUE(characteristic);
945 EXPECT_EQ(1U, characteristic->GetDescriptors().size()); 941 EXPECT_EQ(1U, characteristic->GetDescriptors().size());
946 EXPECT_FALSE(characteristic->IsNotifying()); 942 EXPECT_FALSE(characteristic->IsNotifying());
947 943
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 1289
1294 EXPECT_EQ(1, success_callback_count_); 1290 EXPECT_EQ(1, success_callback_count_);
1295 EXPECT_EQ(0, error_callback_count_); 1291 EXPECT_EQ(0, error_callback_count_);
1296 EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count()); 1292 EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count());
1297 EXPECT_TRUE(characteristic->IsNotifying()); 1293 EXPECT_TRUE(characteristic->IsNotifying());
1298 EXPECT_EQ(1U, update_sessions_.size()); 1294 EXPECT_EQ(1U, update_sessions_.size());
1299 EXPECT_TRUE(update_sessions_[0]->IsActive()); 1295 EXPECT_TRUE(update_sessions_[0]->IsActive());
1300 } 1296 }
1301 1297
1302 } // namespace bluez 1298 } // namespace bluez
OLDNEW
« no previous file with comments | « no previous file | device/bluetooth/bluez/bluetooth_remote_gatt_service_bluez.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698