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

Unified Diff: device/bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc

Issue 1898643002: Refactor device::BluetoothGattXXX classes to split into remote/local. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc
diff --git a/device/bluetooth/bluetooth_gatt_bluez_unittest.cc b/device/bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc
similarity index 92%
rename from device/bluetooth/bluetooth_gatt_bluez_unittest.cc
rename to device/bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc
index 8f0c69a3a46b85e291d9f644781c9a70510e307c..905b53a3ee5cb598948d1c9651d115921d13c96f 100644
--- a/device/bluetooth/bluetooth_gatt_bluez_unittest.cc
+++ b/device/bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
+// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -15,11 +15,11 @@
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/bluetooth_device.h"
-#include "device/bluetooth/bluetooth_gatt_characteristic.h"
#include "device/bluetooth/bluetooth_gatt_connection.h"
-#include "device/bluetooth/bluetooth_gatt_descriptor.h"
#include "device/bluetooth/bluetooth_gatt_notify_session.h"
-#include "device/bluetooth/bluetooth_gatt_service.h"
+#include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
+#include "device/bluetooth/bluetooth_remote_gatt_descriptor.h"
+#include "device/bluetooth/bluetooth_remote_gatt_service.h"
#include "device/bluetooth/bluetooth_uuid.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
#include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h"
@@ -34,10 +34,10 @@
using device::BluetoothAdapter;
using device::BluetoothDevice;
-using device::BluetoothGattCharacteristic;
+using device::BluetoothRemoteGattCharacteristic;
using device::BluetoothGattConnection;
-using device::BluetoothGattDescriptor;
-using device::BluetoothGattService;
+using device::BluetoothRemoteGattDescriptor;
+using device::BluetoothRemoteGattService;
using device::BluetoothGattNotifySession;
using device::BluetoothUUID;
using device::TestBluetoothAdapterObserver;
@@ -156,7 +156,7 @@ class BluetoothGattBlueZTest : public testing::Test {
QuitMessageLoop();
}
- void ServiceErrorCallback(BluetoothGattService::GattErrorCode err) {
+ void ServiceErrorCallback(BluetoothRemoteGattService::GattErrorCode err) {
++error_callback_count_;
last_service_error_ = err;
}
@@ -194,7 +194,7 @@ class BluetoothGattBlueZTest : public testing::Test {
int success_callback_count_;
int error_callback_count_;
std::vector<uint8_t> last_read_value_;
- BluetoothGattService::GattErrorCode last_service_error_;
+ BluetoothRemoteGattService::GattErrorCode last_service_error_;
};
TEST_F(BluetoothGattBlueZTest, GattConnection) {
@@ -297,9 +297,8 @@ TEST_F(BluetoothGattBlueZTest, GattServiceAddedAndRemoved) {
bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID),
observer.last_gatt_service_uuid());
- BluetoothGattService* service =
+ BluetoothRemoteGattService* service =
device->GetGattService(observer.last_gatt_service_id());
- EXPECT_FALSE(service->IsLocal());
EXPECT_TRUE(service->IsPrimary());
EXPECT_EQ(service, device->GetGattServices()[0]);
EXPECT_EQ(service, device->GetGattService(service->GetIdentifier()));
@@ -338,7 +337,6 @@ TEST_F(BluetoothGattBlueZTest, GattServiceAddedAndRemoved) {
// should contain a brand new instance.
service = device->GetGattService(observer.last_gatt_service_id());
EXPECT_EQ(service, device->GetGattServices()[0]);
- EXPECT_FALSE(service->IsLocal());
EXPECT_TRUE(service->IsPrimary());
EXPECT_EQ(observer.last_gatt_service_uuid(), service->GetUUID());
@@ -439,7 +437,7 @@ TEST_F(BluetoothGattBlueZTest, GattCharacteristicAddedAndRemoved) {
dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
ASSERT_EQ(1, observer.gatt_service_added_count());
- BluetoothGattService* service =
+ BluetoothRemoteGattService* service =
device->GetGattService(observer.last_gatt_service_id());
EXPECT_EQ(0, observer.gatt_service_changed_count());
@@ -507,7 +505,7 @@ TEST_F(BluetoothGattBlueZTest, GattDescriptorAddedAndRemoved) {
dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
ASSERT_EQ(1, observer.gatt_service_added_count());
- BluetoothGattService* service =
+ BluetoothRemoteGattService* service =
device->GetGattService(observer.last_gatt_service_id());
EXPECT_EQ(0, observer.gatt_service_changed_count());
@@ -526,9 +524,10 @@ TEST_F(BluetoothGattBlueZTest, GattDescriptorAddedAndRemoved) {
EXPECT_EQ(0, observer.gatt_descriptor_removed_count());
EXPECT_EQ(0, observer.gatt_descriptor_value_changed_count());
- BluetoothGattCharacteristic* characteristic = service->GetCharacteristic(
- fake_bluetooth_gatt_characteristic_client_->GetBodySensorLocationPath()
- .value());
+ BluetoothRemoteGattCharacteristic* characteristic =
+ service->GetCharacteristic(fake_bluetooth_gatt_characteristic_client_
+ ->GetBodySensorLocationPath()
+ .value());
ASSERT_TRUE(characteristic);
EXPECT_TRUE(characteristic->GetDescriptors().empty());
@@ -544,10 +543,11 @@ TEST_F(BluetoothGattBlueZTest, GattDescriptorAddedAndRemoved) {
ASSERT_TRUE(characteristic);
EXPECT_EQ(1U, characteristic->GetDescriptors().size());
- BluetoothGattDescriptor* descriptor = characteristic->GetDescriptors()[0];
- EXPECT_FALSE(descriptor->IsLocal());
- EXPECT_EQ(BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid(),
- descriptor->GetUUID());
+ BluetoothRemoteGattDescriptor* descriptor =
+ characteristic->GetDescriptors()[0];
+ EXPECT_EQ(
+ BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid(),
+ descriptor->GetUUID());
EXPECT_EQ(descriptor->GetUUID(), observer.last_gatt_descriptor_uuid());
EXPECT_EQ(descriptor->GetIdentifier(), observer.last_gatt_descriptor_id());
@@ -574,9 +574,9 @@ TEST_F(BluetoothGattBlueZTest, GattDescriptorAddedAndRemoved) {
EXPECT_EQ(0, observer.gatt_descriptor_value_changed_count());
descriptor = characteristic->GetDescriptors()[0];
- EXPECT_FALSE(descriptor->IsLocal());
- EXPECT_EQ(BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid(),
- descriptor->GetUUID());
+ EXPECT_EQ(
+ BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid(),
+ descriptor->GetUUID());
EXPECT_EQ(descriptor->GetUUID(), observer.last_gatt_descriptor_uuid());
EXPECT_EQ(descriptor->GetIdentifier(), observer.last_gatt_descriptor_id());
}
@@ -605,26 +605,24 @@ TEST_F(BluetoothGattBlueZTest, AdapterAddedAfterGattService) {
ASSERT_TRUE(device);
EXPECT_EQ(1U, device->GetGattServices().size());
- BluetoothGattService* service = device->GetGattServices()[0];
+ BluetoothRemoteGattService* service = device->GetGattServices()[0];
ASSERT_TRUE(service);
- EXPECT_FALSE(service->IsLocal());
EXPECT_TRUE(service->IsPrimary());
EXPECT_EQ(BluetoothUUID(
bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID),
service->GetUUID());
EXPECT_EQ(service, device->GetGattServices()[0]);
EXPECT_EQ(service, device->GetGattService(service->GetIdentifier()));
- EXPECT_FALSE(service->IsLocal());
EXPECT_EQ(3U, service->GetCharacteristics().size());
- BluetoothGattCharacteristic* characteristic = service->GetCharacteristic(
- fake_bluetooth_gatt_characteristic_client_->GetBodySensorLocationPath()
- .value());
+ BluetoothRemoteGattCharacteristic* characteristic =
+ service->GetCharacteristic(fake_bluetooth_gatt_characteristic_client_
+ ->GetBodySensorLocationPath()
+ .value());
ASSERT_TRUE(characteristic);
EXPECT_EQ(BluetoothUUID(bluez::FakeBluetoothGattCharacteristicClient::
kBodySensorLocationUUID),
characteristic->GetUUID());
- EXPECT_FALSE(characteristic->IsLocal());
EXPECT_TRUE(characteristic->GetDescriptors().empty());
characteristic = service->GetCharacteristic(
@@ -634,7 +632,6 @@ TEST_F(BluetoothGattBlueZTest, AdapterAddedAfterGattService) {
EXPECT_EQ(BluetoothUUID(bluez::FakeBluetoothGattCharacteristicClient::
kHeartRateControlPointUUID),
characteristic->GetUUID());
- EXPECT_FALSE(characteristic->IsLocal());
EXPECT_TRUE(characteristic->GetDescriptors().empty());
characteristic = service->GetCharacteristic(
@@ -644,14 +641,14 @@ TEST_F(BluetoothGattBlueZTest, AdapterAddedAfterGattService) {
EXPECT_EQ(BluetoothUUID(bluez::FakeBluetoothGattCharacteristicClient::
kHeartRateMeasurementUUID),
characteristic->GetUUID());
- EXPECT_FALSE(characteristic->IsLocal());
EXPECT_EQ(1U, characteristic->GetDescriptors().size());
- BluetoothGattDescriptor* descriptor = characteristic->GetDescriptors()[0];
+ BluetoothRemoteGattDescriptor* descriptor =
+ characteristic->GetDescriptors()[0];
ASSERT_TRUE(descriptor);
- EXPECT_EQ(BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid(),
- descriptor->GetUUID());
- EXPECT_FALSE(descriptor->IsLocal());
+ EXPECT_EQ(
+ BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid(),
+ descriptor->GetUUID());
}
TEST_F(BluetoothGattBlueZTest, GattCharacteristicValue) {
@@ -670,7 +667,7 @@ TEST_F(BluetoothGattBlueZTest, GattCharacteristicValue) {
dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
ASSERT_EQ(1, observer.gatt_service_added_count());
- BluetoothGattService* service =
+ BluetoothRemoteGattService* service =
device->GetGattService(observer.last_gatt_service_id());
EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
@@ -683,9 +680,10 @@ TEST_F(BluetoothGattBlueZTest, GattCharacteristicValue) {
std::vector<uint8_t> write_value;
write_value.push_back(0x01);
- BluetoothGattCharacteristic* characteristic = service->GetCharacteristic(
- fake_bluetooth_gatt_characteristic_client_->GetHeartRateMeasurementPath()
- .value());
+ BluetoothRemoteGattCharacteristic* characteristic =
+ service->GetCharacteristic(fake_bluetooth_gatt_characteristic_client_
+ ->GetHeartRateMeasurementPath()
+ .value());
ASSERT_TRUE(characteristic);
EXPECT_FALSE(characteristic->IsNotifying());
EXPECT_EQ(
@@ -702,7 +700,7 @@ TEST_F(BluetoothGattBlueZTest, GattCharacteristicValue) {
EXPECT_FALSE(observer.last_gatt_characteristic_uuid().IsValid());
EXPECT_EQ(0, success_callback_count_);
EXPECT_EQ(1, error_callback_count_);
- EXPECT_EQ(BluetoothGattService::GATT_ERROR_NOT_SUPPORTED,
+ EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED,
last_service_error_);
EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
@@ -724,7 +722,7 @@ TEST_F(BluetoothGattBlueZTest, GattCharacteristicValue) {
EXPECT_FALSE(observer.last_gatt_characteristic_uuid().IsValid());
EXPECT_EQ(0, success_callback_count_);
EXPECT_EQ(2, error_callback_count_);
- EXPECT_EQ(BluetoothGattService::GATT_ERROR_NOT_PERMITTED,
+ EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_NOT_PERMITTED,
last_service_error_);
EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
@@ -765,7 +763,7 @@ TEST_F(BluetoothGattBlueZTest, GattCharacteristicValue) {
base::Unretained(this)));
EXPECT_EQ(1, success_callback_count_);
EXPECT_EQ(3, error_callback_count_);
- EXPECT_EQ(BluetoothGattService::GATT_ERROR_INVALID_LENGTH,
+ EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_INVALID_LENGTH,
last_service_error_);
EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
@@ -778,7 +776,7 @@ TEST_F(BluetoothGattBlueZTest, GattCharacteristicValue) {
base::Unretained(this)));
EXPECT_EQ(1, success_callback_count_);
EXPECT_EQ(4, error_callback_count_);
- EXPECT_EQ(BluetoothGattService::GATT_ERROR_FAILED, last_service_error_);
+ EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_FAILED, last_service_error_);
EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
// Issue a read request. A successful read results in a
@@ -832,7 +830,8 @@ TEST_F(BluetoothGattBlueZTest, GattCharacteristicValue) {
base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback,
base::Unretained(this)));
EXPECT_EQ(5, error_callback_count_);
- EXPECT_EQ(BluetoothGattService::GATT_ERROR_IN_PROGRESS, last_service_error_);
+ EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS,
+ last_service_error_);
// But previous call finished.
EXPECT_EQ(3, success_callback_count_);
@@ -849,7 +848,7 @@ TEST_F(BluetoothGattBlueZTest, GattCharacteristicValue) {
base::Unretained(this)));
EXPECT_EQ(3, success_callback_count_);
EXPECT_EQ(6, error_callback_count_);
- EXPECT_EQ(BluetoothGattService::GATT_ERROR_NOT_AUTHORIZED,
+ EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_NOT_AUTHORIZED,
last_service_error_);
EXPECT_EQ(2, observer.gatt_characteristic_value_changed_count());
fake_bluetooth_gatt_characteristic_client_->SetAuthorized(true);
@@ -863,7 +862,8 @@ TEST_F(BluetoothGattBlueZTest, GattCharacteristicValue) {
base::Unretained(this)));
EXPECT_EQ(3, success_callback_count_);
EXPECT_EQ(7, error_callback_count_);
- EXPECT_EQ(BluetoothGattService::GATT_ERROR_NOT_PAIRED, last_service_error_);
+ EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_NOT_PAIRED,
+ last_service_error_);
EXPECT_EQ(2, observer.gatt_characteristic_value_changed_count());
fake_bluetooth_gatt_characteristic_client_->SetAuthenticated(true);
}
@@ -883,7 +883,7 @@ TEST_F(BluetoothGattBlueZTest, GattCharacteristicProperties) {
fake_bluetooth_gatt_service_client_->ExposeHeartRateService(
dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
- BluetoothGattService* service =
+ BluetoothRemoteGattService* service =
device->GetGattService(observer.last_gatt_service_id());
EXPECT_TRUE(service->GetCharacteristics().empty());
@@ -891,22 +891,23 @@ TEST_F(BluetoothGattBlueZTest, GattCharacteristicProperties) {
// Run the message loop so that the characteristics appear.
base::MessageLoop::current()->Run();
- BluetoothGattCharacteristic* characteristic = service->GetCharacteristic(
- fake_bluetooth_gatt_characteristic_client_->GetBodySensorLocationPath()
- .value());
- EXPECT_EQ(BluetoothGattCharacteristic::PROPERTY_READ,
+ BluetoothRemoteGattCharacteristic* characteristic =
+ service->GetCharacteristic(fake_bluetooth_gatt_characteristic_client_
+ ->GetBodySensorLocationPath()
+ .value());
+ EXPECT_EQ(BluetoothRemoteGattCharacteristic::PROPERTY_READ,
characteristic->GetProperties());
characteristic = service->GetCharacteristic(
fake_bluetooth_gatt_characteristic_client_->GetHeartRateControlPointPath()
.value());
- EXPECT_EQ(BluetoothGattCharacteristic::PROPERTY_WRITE,
+ EXPECT_EQ(BluetoothRemoteGattCharacteristic::PROPERTY_WRITE,
characteristic->GetProperties());
characteristic = service->GetCharacteristic(
fake_bluetooth_gatt_characteristic_client_->GetHeartRateMeasurementPath()
.value());
- EXPECT_EQ(BluetoothGattCharacteristic::PROPERTY_NOTIFY,
+ EXPECT_EQ(BluetoothRemoteGattCharacteristic::PROPERTY_NOTIFY,
characteristic->GetProperties());
}
@@ -926,7 +927,7 @@ TEST_F(BluetoothGattBlueZTest, GattDescriptorValue) {
dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
ASSERT_EQ(1, observer.gatt_service_added_count());
- BluetoothGattService* service =
+ BluetoothRemoteGattService* service =
device->GetGattService(observer.last_gatt_service_id());
EXPECT_EQ(0, observer.gatt_service_changed_count());
@@ -940,17 +941,19 @@ TEST_F(BluetoothGattBlueZTest, GattDescriptorValue) {
EXPECT_EQ(1, observer.gatt_discovery_complete_count());
// Only the Heart Rate Measurement characteristic has a descriptor.
- BluetoothGattCharacteristic* characteristic = service->GetCharacteristic(
- fake_bluetooth_gatt_characteristic_client_->GetHeartRateMeasurementPath()
- .value());
+ BluetoothRemoteGattCharacteristic* characteristic =
+ service->GetCharacteristic(fake_bluetooth_gatt_characteristic_client_
+ ->GetHeartRateMeasurementPath()
+ .value());
ASSERT_TRUE(characteristic);
EXPECT_EQ(1U, characteristic->GetDescriptors().size());
EXPECT_FALSE(characteristic->IsNotifying());
- BluetoothGattDescriptor* descriptor = characteristic->GetDescriptors()[0];
- EXPECT_FALSE(descriptor->IsLocal());
- EXPECT_EQ(BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid(),
- descriptor->GetUUID());
+ BluetoothRemoteGattDescriptor* descriptor =
+ characteristic->GetDescriptors()[0];
+ EXPECT_EQ(
+ BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid(),
+ descriptor->GetUUID());
std::vector<uint8_t> desc_value = {0x00, 0x00};
@@ -985,7 +988,7 @@ TEST_F(BluetoothGattBlueZTest, GattDescriptorValue) {
base::Unretained(this)));
EXPECT_EQ(1, success_callback_count_);
EXPECT_EQ(1, error_callback_count_);
- EXPECT_EQ(BluetoothGattService::GATT_ERROR_NOT_PERMITTED,
+ EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_NOT_PERMITTED,
last_service_error_);
EXPECT_TRUE(ValuesEqual(last_read_value_, descriptor->GetValue()));
EXPECT_FALSE(ValuesEqual(desc_value, descriptor->GetValue()));
@@ -1048,7 +1051,7 @@ TEST_F(BluetoothGattBlueZTest, NotifySessions) {
dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
ASSERT_EQ(1, observer.gatt_service_added_count());
- BluetoothGattService* service =
+ BluetoothRemoteGattService* service =
device->GetGattService(observer.last_gatt_service_id());
EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
@@ -1056,9 +1059,10 @@ TEST_F(BluetoothGattBlueZTest, NotifySessions) {
// Run the message loop so that the characteristics appear.
base::MessageLoop::current()->Run();
- BluetoothGattCharacteristic* characteristic = service->GetCharacteristic(
- fake_bluetooth_gatt_characteristic_client_->GetHeartRateMeasurementPath()
- .value());
+ BluetoothRemoteGattCharacteristic* characteristic =
+ service->GetCharacteristic(fake_bluetooth_gatt_characteristic_client_
+ ->GetHeartRateMeasurementPath()
+ .value());
ASSERT_TRUE(characteristic);
EXPECT_FALSE(characteristic->IsNotifying());
EXPECT_TRUE(update_sessions_.empty());
@@ -1197,7 +1201,7 @@ TEST_F(BluetoothGattBlueZTest, NotifySessionsMadeInactive) {
dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
ASSERT_EQ(1, observer.gatt_service_added_count());
- BluetoothGattService* service =
+ BluetoothRemoteGattService* service =
device->GetGattService(observer.last_gatt_service_id());
EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
@@ -1205,9 +1209,10 @@ TEST_F(BluetoothGattBlueZTest, NotifySessionsMadeInactive) {
// Run the message loop so that the characteristics appear.
base::MessageLoop::current()->Run();
- BluetoothGattCharacteristic* characteristic = service->GetCharacteristic(
- fake_bluetooth_gatt_characteristic_client_->GetHeartRateMeasurementPath()
- .value());
+ BluetoothRemoteGattCharacteristic* characteristic =
+ service->GetCharacteristic(fake_bluetooth_gatt_characteristic_client_
+ ->GetHeartRateMeasurementPath()
+ .value());
ASSERT_TRUE(characteristic);
EXPECT_FALSE(characteristic->IsNotifying());
EXPECT_TRUE(update_sessions_.empty());
« no previous file with comments | « device/bluetooth/bluez/bluetooth_device_bluez.cc ('k') | device/bluetooth/bluez/bluetooth_gatt_characteristic_bluez.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698