| Index: device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
|
| diff --git a/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
|
| similarity index 84%
|
| rename from device/bluetooth/bluetooth_gatt_characteristic_unittest.cc
|
| rename to device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
|
| index a9451b4069d72cf2e9902bea9b8de8185bddd145..d25944ce87b182d6136d55754eb92a652dba17a6 100644
|
| --- a/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc
|
| +++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
|
| @@ -2,14 +2,14 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "device/bluetooth/bluetooth_gatt_characteristic.h"
|
| -
|
| #include <stdint.h>
|
| +#include <utility>
|
|
|
| #include "base/macros.h"
|
| #include "base/run_loop.h"
|
| #include "build/build_config.h"
|
| -#include "device/bluetooth/bluetooth_gatt_service.h"
|
| +#include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
|
| +#include "device/bluetooth/bluetooth_remote_gatt_service.h"
|
| #include "device/bluetooth/test/test_bluetooth_adapter_observer.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -24,7 +24,7 @@
|
| namespace device {
|
|
|
| #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
|
| -class BluetoothGattCharacteristicTest : public BluetoothTest {
|
| +class BluetoothRemoteGattCharacteristicTest : public BluetoothTest {
|
| public:
|
| // Creates adapter_, device_, service_, characteristic1_, & characteristic2_.
|
| // |properties| will be used for each characteristic.
|
| @@ -74,14 +74,14 @@ class BluetoothGattCharacteristicTest : public BluetoothTest {
|
| if (error != StartNotifySetupError::CONFIG_DESCRIPTOR_MISSING) {
|
| SimulateGattDescriptor(
|
| characteristic1_,
|
| - BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid()
|
| + BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid()
|
| .canonical_value());
|
| expected_descriptors_count++;
|
| }
|
| if (error == StartNotifySetupError::CONFIG_DESCRIPTOR_DUPLICATE) {
|
| SimulateGattDescriptor(
|
| characteristic1_,
|
| - BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid()
|
| + BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid()
|
| .canonical_value());
|
| expected_descriptors_count++;
|
| }
|
| @@ -130,14 +130,14 @@ class BluetoothGattCharacteristicTest : public BluetoothTest {
|
| }
|
|
|
| BluetoothDevice* device_ = nullptr;
|
| - BluetoothGattService* service_ = nullptr;
|
| - BluetoothGattCharacteristic* characteristic1_ = nullptr;
|
| - BluetoothGattCharacteristic* characteristic2_ = nullptr;
|
| + BluetoothRemoteGattService* service_ = nullptr;
|
| + BluetoothRemoteGattCharacteristic* characteristic1_ = nullptr;
|
| + BluetoothRemoteGattCharacteristic* characteristic2_ = nullptr;
|
| };
|
| #endif
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| -TEST_F(BluetoothGattCharacteristicTest, GetIdentifier) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, GetIdentifier) {
|
| InitWithFakeAdapter();
|
| StartLowEnergyDiscoverySession();
|
| // 2 devices to verify unique IDs across them.
|
| @@ -159,9 +159,9 @@ TEST_F(BluetoothGattCharacteristicTest, GetIdentifier) {
|
| SimulateGattServicesDiscovered(device1, services);
|
| services.push_back(uuid);
|
| SimulateGattServicesDiscovered(device2, services);
|
| - BluetoothGattService* service1 = device1->GetGattServices()[0];
|
| - BluetoothGattService* service2 = device2->GetGattServices()[0];
|
| - BluetoothGattService* service3 = device2->GetGattServices()[1];
|
| + BluetoothRemoteGattService* service1 = device1->GetGattServices()[0];
|
| + BluetoothRemoteGattService* service2 = device2->GetGattServices()[0];
|
| + BluetoothRemoteGattService* service3 = device2->GetGattServices()[1];
|
| // 6 characteristics (same UUID), 2 on each service.
|
| SimulateGattCharacteristic(service1, uuid, /* properties */ 0);
|
| SimulateGattCharacteristic(service1, uuid, /* properties */ 0);
|
| @@ -169,12 +169,12 @@ TEST_F(BluetoothGattCharacteristicTest, GetIdentifier) {
|
| SimulateGattCharacteristic(service2, uuid, /* properties */ 0);
|
| SimulateGattCharacteristic(service3, uuid, /* properties */ 0);
|
| SimulateGattCharacteristic(service3, uuid, /* properties */ 0);
|
| - BluetoothGattCharacteristic* char1 = service1->GetCharacteristics()[0];
|
| - BluetoothGattCharacteristic* char2 = service1->GetCharacteristics()[1];
|
| - BluetoothGattCharacteristic* char3 = service2->GetCharacteristics()[0];
|
| - BluetoothGattCharacteristic* char4 = service2->GetCharacteristics()[1];
|
| - BluetoothGattCharacteristic* char5 = service3->GetCharacteristics()[0];
|
| - BluetoothGattCharacteristic* char6 = service3->GetCharacteristics()[1];
|
| + BluetoothRemoteGattCharacteristic* char1 = service1->GetCharacteristics()[0];
|
| + BluetoothRemoteGattCharacteristic* char2 = service1->GetCharacteristics()[1];
|
| + BluetoothRemoteGattCharacteristic* char3 = service2->GetCharacteristics()[0];
|
| + BluetoothRemoteGattCharacteristic* char4 = service2->GetCharacteristics()[1];
|
| + BluetoothRemoteGattCharacteristic* char5 = service3->GetCharacteristics()[0];
|
| + BluetoothRemoteGattCharacteristic* char6 = service3->GetCharacteristics()[1];
|
|
|
| // All IDs are unique, even though they have the same UUID.
|
| EXPECT_NE(char1->GetIdentifier(), char2->GetIdentifier());
|
| @@ -200,7 +200,7 @@ TEST_F(BluetoothGattCharacteristicTest, GetIdentifier) {
|
| #endif // defined(OS_ANDROID) || defined(OS_WIN)
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| -TEST_F(BluetoothGattCharacteristicTest, GetUUID) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, GetUUID) {
|
| InitWithFakeAdapter();
|
| StartLowEnergyDiscoverySession();
|
| BluetoothDevice* device = DiscoverLowEnergyDevice(3);
|
| @@ -210,7 +210,7 @@ TEST_F(BluetoothGattCharacteristicTest, GetUUID) {
|
| std::vector<std::string> services;
|
| services.push_back("00000000-0000-1000-8000-00805f9b34fb");
|
| SimulateGattServicesDiscovered(device, services);
|
| - BluetoothGattService* service = device->GetGattServices()[0];
|
| + BluetoothRemoteGattService* service = device->GetGattServices()[0];
|
|
|
| // Create 3 characteristics. Two of them are duplicates.
|
| std::string uuid_str1("11111111-0000-1000-8000-00805f9b34fb");
|
| @@ -220,9 +220,9 @@ TEST_F(BluetoothGattCharacteristicTest, GetUUID) {
|
| SimulateGattCharacteristic(service, uuid_str1, /* properties */ 0);
|
| SimulateGattCharacteristic(service, uuid_str2, /* properties */ 0);
|
| SimulateGattCharacteristic(service, uuid_str2, /* properties */ 0);
|
| - BluetoothGattCharacteristic* char1 = service->GetCharacteristics()[0];
|
| - BluetoothGattCharacteristic* char2 = service->GetCharacteristics()[1];
|
| - BluetoothGattCharacteristic* char3 = service->GetCharacteristics()[2];
|
| + BluetoothRemoteGattCharacteristic* char1 = service->GetCharacteristics()[0];
|
| + BluetoothRemoteGattCharacteristic* char2 = service->GetCharacteristics()[1];
|
| + BluetoothRemoteGattCharacteristic* char3 = service->GetCharacteristics()[2];
|
|
|
| // Swap as needed to have char1 point to the the characteristic with uuid1.
|
| if (char2->GetUUID() == uuid1) {
|
| @@ -238,7 +238,7 @@ TEST_F(BluetoothGattCharacteristicTest, GetUUID) {
|
| #endif // defined(OS_ANDROID) || defined(OS_WIN)
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| -TEST_F(BluetoothGattCharacteristicTest, GetProperties) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, GetProperties) {
|
| InitWithFakeAdapter();
|
| StartLowEnergyDiscoverySession();
|
| BluetoothDevice* device = DiscoverLowEnergyDevice(3);
|
| @@ -249,7 +249,7 @@ TEST_F(BluetoothGattCharacteristicTest, GetProperties) {
|
| std::string uuid("00000000-0000-1000-8000-00805f9b34fb");
|
| services.push_back(uuid);
|
| SimulateGattServicesDiscovered(device, services);
|
| - BluetoothGattService* service = device->GetGattServices()[0];
|
| + BluetoothRemoteGattService* service = device->GetGattServices()[0];
|
|
|
| // Create two characteristics with different properties:
|
| SimulateGattCharacteristic(service, uuid, /* properties */ 0);
|
| @@ -267,7 +267,7 @@ TEST_F(BluetoothGattCharacteristicTest, GetProperties) {
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests GetService.
|
| -TEST_F(BluetoothGattCharacteristicTest, GetService) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, GetService) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
|
|
|
| EXPECT_EQ(service_, characteristic1_->GetService());
|
| @@ -277,9 +277,9 @@ TEST_F(BluetoothGattCharacteristicTest, GetService) {
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests ReadRemoteCharacteristic and GetValue with empty value buffer.
|
| -TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_Empty) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, ReadRemoteCharacteristic_Empty) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_READ));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_READ));
|
|
|
| characteristic1_->ReadRemoteCharacteristic(
|
| GetReadValueCallback(Call::EXPECTED),
|
| @@ -298,9 +298,9 @@ TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_Empty) {
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests WriteRemoteCharacteristic with empty value buffer.
|
| -TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_Empty) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, WriteRemoteCharacteristic_Empty) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_WRITE));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
|
|
|
| std::vector<uint8_t> empty_vector;
|
| characteristic1_->WriteRemoteCharacteristic(
|
| @@ -318,9 +318,10 @@ TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_Empty) {
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests ReadRemoteCharacteristic completing after Chrome objects are deleted.
|
| -TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_AfterDeleted) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| + ReadRemoteCharacteristic_AfterDeleted) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_READ));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_READ));
|
|
|
| characteristic1_->ReadRemoteCharacteristic(
|
| GetReadValueCallback(Call::NOT_EXPECTED),
|
| @@ -338,10 +339,10 @@ TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_AfterDeleted) {
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests WriteRemoteCharacteristic completing after Chrome objects are deleted.
|
| -TEST_F(BluetoothGattCharacteristicTest,
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| WriteRemoteCharacteristic_AfterDeleted) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_WRITE));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
|
|
|
| std::vector<uint8_t> empty_vector;
|
| characteristic1_->WriteRemoteCharacteristic(
|
| @@ -358,9 +359,9 @@ TEST_F(BluetoothGattCharacteristicTest,
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests ReadRemoteCharacteristic and GetValue with non-empty value buffer.
|
| -TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, ReadRemoteCharacteristic) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_READ));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_READ));
|
|
|
| characteristic1_->ReadRemoteCharacteristic(
|
| GetReadValueCallback(Call::EXPECTED),
|
| @@ -382,9 +383,9 @@ TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic) {
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests WriteRemoteCharacteristic with non-empty value buffer.
|
| -TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, WriteRemoteCharacteristic) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_WRITE));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
|
|
|
| uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
|
| std::vector<uint8_t> test_vector(values, values + arraysize(values));
|
| @@ -401,9 +402,9 @@ TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic) {
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests ReadRemoteCharacteristic and GetValue multiple times.
|
| -TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_Twice) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, ReadRemoteCharacteristic_Twice) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_READ));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_READ));
|
|
|
| characteristic1_->ReadRemoteCharacteristic(
|
| GetReadValueCallback(Call::EXPECTED),
|
| @@ -435,9 +436,9 @@ TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_Twice) {
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests WriteRemoteCharacteristic multiple times.
|
| -TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_Twice) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, WriteRemoteCharacteristic_Twice) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_WRITE));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
|
|
|
| uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
|
| std::vector<uint8_t> test_vector(values, values + arraysize(values));
|
| @@ -468,10 +469,10 @@ TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_Twice) {
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests ReadRemoteCharacteristic on two characteristics.
|
| -TEST_F(BluetoothGattCharacteristicTest,
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| ReadRemoteCharacteristic_MultipleCharacteristics) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_READ));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_READ));
|
|
|
| characteristic1_->ReadRemoteCharacteristic(
|
| GetReadValueCallback(Call::EXPECTED),
|
| @@ -502,10 +503,10 @@ TEST_F(BluetoothGattCharacteristicTest,
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests WriteRemoteCharacteristic on two characteristics.
|
| -TEST_F(BluetoothGattCharacteristicTest,
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| WriteRemoteCharacteristic_MultipleCharacteristics) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_WRITE));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
|
|
|
| std::vector<uint8_t> test_vector1;
|
| test_vector1.push_back(111);
|
| @@ -548,45 +549,45 @@ TEST_F(BluetoothGattCharacteristicTest,
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests ReadRemoteCharacteristic asynchronous error.
|
| -TEST_F(BluetoothGattCharacteristicTest, ReadError) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, ReadError) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_READ));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_READ));
|
|
|
| characteristic1_->ReadRemoteCharacteristic(
|
| GetReadValueCallback(Call::NOT_EXPECTED),
|
| GetGattErrorCallback(Call::EXPECTED));
|
| SimulateGattCharacteristicReadError(
|
| - characteristic1_, BluetoothGattService::GATT_ERROR_INVALID_LENGTH);
|
| - SimulateGattCharacteristicReadError(characteristic1_,
|
| - BluetoothGattService::GATT_ERROR_FAILED);
|
| - EXPECT_EQ(BluetoothGattService::GATT_ERROR_INVALID_LENGTH,
|
| + characteristic1_, BluetoothRemoteGattService::GATT_ERROR_INVALID_LENGTH);
|
| + SimulateGattCharacteristicReadError(
|
| + characteristic1_, BluetoothRemoteGattService::GATT_ERROR_FAILED);
|
| + EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_INVALID_LENGTH,
|
| last_gatt_error_code_);
|
| }
|
| #endif // defined(OS_ANDROID) || defined(OS_WIN)
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests WriteRemoteCharacteristic asynchronous error.
|
| -TEST_F(BluetoothGattCharacteristicTest, WriteError) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, WriteError) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_WRITE));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
|
|
|
| std::vector<uint8_t> empty_vector;
|
| characteristic1_->WriteRemoteCharacteristic(
|
| empty_vector, GetCallback(Call::NOT_EXPECTED),
|
| GetGattErrorCallback(Call::EXPECTED));
|
| SimulateGattCharacteristicWriteError(
|
| - characteristic1_, BluetoothGattService::GATT_ERROR_INVALID_LENGTH);
|
| - SimulateGattCharacteristicWriteError(characteristic1_,
|
| - BluetoothGattService::GATT_ERROR_FAILED);
|
| + characteristic1_, BluetoothRemoteGattService::GATT_ERROR_INVALID_LENGTH);
|
| + SimulateGattCharacteristicWriteError(
|
| + characteristic1_, BluetoothRemoteGattService::GATT_ERROR_FAILED);
|
|
|
| - EXPECT_EQ(BluetoothGattService::GATT_ERROR_INVALID_LENGTH,
|
| + EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_INVALID_LENGTH,
|
| last_gatt_error_code_);
|
| }
|
| #endif // defined(OS_ANDROID) || defined(OS_WIN)
|
|
|
| #if defined(OS_ANDROID)
|
| // Tests ReadRemoteCharacteristic synchronous error.
|
| -TEST_F(BluetoothGattCharacteristicTest, ReadSynchronousError) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, ReadSynchronousError) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
|
|
|
| SimulateGattCharacteristicReadWillFailSynchronouslyOnce(characteristic1_);
|
| @@ -597,7 +598,8 @@ TEST_F(BluetoothGattCharacteristicTest, ReadSynchronousError) {
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_EQ(0, callback_count_);
|
| EXPECT_EQ(1, error_callback_count_);
|
| - EXPECT_EQ(BluetoothGattService::GATT_ERROR_FAILED, last_gatt_error_code_);
|
| + EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_FAILED,
|
| + last_gatt_error_code_);
|
|
|
| // After failing once, can succeed:
|
| ResetEventCounts();
|
| @@ -614,7 +616,7 @@ TEST_F(BluetoothGattCharacteristicTest, ReadSynchronousError) {
|
|
|
| #if defined(OS_ANDROID)
|
| // Tests WriteRemoteCharacteristic synchronous error.
|
| -TEST_F(BluetoothGattCharacteristicTest, WriteSynchronousError) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, WriteSynchronousError) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
|
|
|
| SimulateGattCharacteristicWriteWillFailSynchronouslyOnce(characteristic1_);
|
| @@ -626,7 +628,8 @@ TEST_F(BluetoothGattCharacteristicTest, WriteSynchronousError) {
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_EQ(0, callback_count_);
|
| EXPECT_EQ(1, error_callback_count_);
|
| - EXPECT_EQ(BluetoothGattService::GATT_ERROR_FAILED, last_gatt_error_code_);
|
| + EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_FAILED,
|
| + last_gatt_error_code_);
|
|
|
| // After failing once, can succeed:
|
| ResetEventCounts();
|
| @@ -642,9 +645,10 @@ TEST_F(BluetoothGattCharacteristicTest, WriteSynchronousError) {
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests ReadRemoteCharacteristic error with a pending read operation.
|
| -TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_ReadPending) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| + ReadRemoteCharacteristic_ReadPending) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_READ));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_READ));
|
|
|
| characteristic1_->ReadRemoteCharacteristic(
|
| GetReadValueCallback(Call::EXPECTED),
|
| @@ -657,7 +661,7 @@ TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_ReadPending) {
|
|
|
| EXPECT_EQ(0, callback_count_);
|
| EXPECT_EQ(1, error_callback_count_);
|
| - EXPECT_EQ(BluetoothGattService::GATT_ERROR_IN_PROGRESS,
|
| + EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS,
|
| last_gatt_error_code_);
|
|
|
| // Initial read should still succeed:
|
| @@ -671,10 +675,10 @@ TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_ReadPending) {
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests WriteRemoteCharacteristic error with a pending write operation.
|
| -TEST_F(BluetoothGattCharacteristicTest,
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| WriteRemoteCharacteristic_WritePending) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_WRITE));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
|
|
|
| std::vector<uint8_t> empty_vector;
|
| characteristic1_->WriteRemoteCharacteristic(
|
| @@ -688,7 +692,7 @@ TEST_F(BluetoothGattCharacteristicTest,
|
|
|
| EXPECT_EQ(0, callback_count_);
|
| EXPECT_EQ(1, error_callback_count_);
|
| - EXPECT_EQ(BluetoothGattService::GATT_ERROR_IN_PROGRESS,
|
| + EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS,
|
| last_gatt_error_code_);
|
|
|
| // Initial write should still succeed:
|
| @@ -701,10 +705,11 @@ TEST_F(BluetoothGattCharacteristicTest,
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests ReadRemoteCharacteristic error with a pending write operation.
|
| -TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_WritePending) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| + ReadRemoteCharacteristic_WritePending) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_READ |
|
| - BluetoothGattCharacteristic::PROPERTY_WRITE));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_READ |
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
|
|
|
| std::vector<uint8_t> empty_vector;
|
| characteristic1_->WriteRemoteCharacteristic(
|
| @@ -718,7 +723,7 @@ TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_WritePending) {
|
|
|
| EXPECT_EQ(0, callback_count_);
|
| EXPECT_EQ(1, error_callback_count_);
|
| - EXPECT_EQ(BluetoothGattService::GATT_ERROR_IN_PROGRESS,
|
| + EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS,
|
| last_gatt_error_code_);
|
|
|
| // Initial write should still succeed:
|
| @@ -731,10 +736,11 @@ TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_WritePending) {
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests WriteRemoteCharacteristic error with a pending Read operation.
|
| -TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_ReadPending) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| + WriteRemoteCharacteristic_ReadPending) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
|
| - BluetoothGattCharacteristic::PROPERTY_READ |
|
| - BluetoothGattCharacteristic::PROPERTY_WRITE));
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_READ |
|
| + BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
|
|
|
| std::vector<uint8_t> empty_vector;
|
| characteristic1_->ReadRemoteCharacteristic(
|
| @@ -747,7 +753,7 @@ TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_ReadPending) {
|
|
|
| EXPECT_EQ(0, callback_count_);
|
| EXPECT_EQ(1, error_callback_count_);
|
| - EXPECT_EQ(BluetoothGattService::GATT_ERROR_IN_PROGRESS,
|
| + EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS,
|
| last_gatt_error_code_);
|
|
|
| // Initial read should still succeed:
|
| @@ -761,7 +767,8 @@ TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_ReadPending) {
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // StartNotifySession fails if characteristic doesn't have Notify or Indicate
|
| // property.
|
| -TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoNotifyOrIndicate) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| + StartNotifySession_NoNotifyOrIndicate) {
|
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
|
| /* properties: NOTIFY */ 0x10,
|
| /* expected_config_descriptor_value: NOTIFY */ 1,
|
| @@ -773,7 +780,7 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoNotifyOrIndicate) {
|
| EXPECT_EQ(0, error_callback_count_);
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_EQ(1, error_callback_count_);
|
| - EXPECT_EQ(BluetoothGattService::GATT_ERROR_NOT_SUPPORTED,
|
| + EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED,
|
| last_gatt_error_code_);
|
| }
|
| #endif // defined(OS_ANDROID) || defined(OS_WIN)
|
| @@ -781,7 +788,8 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoNotifyOrIndicate) {
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // StartNotifySession fails if the characteristic is missing the Client
|
| // Characteristic Configuration descriptor.
|
| -TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoConfigDescriptor) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| + StartNotifySession_NoConfigDescriptor) {
|
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
|
| /* properties: NOTIFY */ 0x10,
|
| /* expected_config_descriptor_value: NOTIFY */ 1,
|
| @@ -793,7 +801,7 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoConfigDescriptor) {
|
| EXPECT_EQ(0, error_callback_count_);
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_EQ(1, error_callback_count_);
|
| - EXPECT_EQ(BluetoothGattService::GATT_ERROR_NOT_SUPPORTED,
|
| + EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED,
|
| last_gatt_error_code_);
|
| }
|
| #endif // defined(OS_ANDROID) || defined(OS_WIN)
|
| @@ -801,7 +809,7 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoConfigDescriptor) {
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // StartNotifySession fails if the characteristic has multiple Client
|
| // Characteristic Configuration descriptors.
|
| -TEST_F(BluetoothGattCharacteristicTest,
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| StartNotifySession_MultipleConfigDescriptor) {
|
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
|
| /* properties: NOTIFY */ 0x10,
|
| @@ -814,7 +822,8 @@ TEST_F(BluetoothGattCharacteristicTest,
|
| EXPECT_EQ(0, error_callback_count_);
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_EQ(1, error_callback_count_);
|
| - EXPECT_EQ(BluetoothGattService::GATT_ERROR_FAILED, last_gatt_error_code_);
|
| + EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_FAILED,
|
| + last_gatt_error_code_);
|
| }
|
| #endif // defined(OS_ANDROID) || defined(OS_WIN)
|
|
|
| @@ -824,7 +833,7 @@ TEST_F(BluetoothGattCharacteristicTest,
|
| // Android: This is mBluetoothGatt.setCharacteristicNotification failing.
|
| // Windows: Synchronous Test Not Applicable: OS calls are all made
|
| // asynchronously from BluetoothTaskManagerWin.
|
| -TEST_F(BluetoothGattCharacteristicTest,
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| StartNotifySession_FailToSetCharacteristicNotification) {
|
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
|
| /* properties: NOTIFY */ 0x10,
|
| @@ -845,7 +854,7 @@ TEST_F(BluetoothGattCharacteristicTest,
|
| // Tests StartNotifySession descriptor write synchronous failure.
|
| // Windows: Synchronous Test Not Applicable: OS calls are all made
|
| // asynchronously from BluetoothTaskManagerWin.
|
| -TEST_F(BluetoothGattCharacteristicTest,
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| StartNotifySession_WriteDescriptorSynchronousError) {
|
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
|
| /* properties: NOTIFY */ 0x10,
|
| @@ -864,7 +873,7 @@ TEST_F(BluetoothGattCharacteristicTest,
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests StartNotifySession success on a characteristic enabling Notify.
|
| -TEST_F(BluetoothGattCharacteristicTest, StartNotifySession) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, StartNotifySession) {
|
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
|
| /* properties: NOTIFY */ 0x10,
|
| /* expected_config_descriptor_value: NOTIFY */ 1));
|
| @@ -873,7 +882,7 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession) {
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests StartNotifySession success on a characteristic enabling Indicate.
|
| -TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_OnIndicate) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, StartNotifySession_OnIndicate) {
|
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
|
| /* properties: INDICATE */ 0x20,
|
| /* expected_config_descriptor_value: INDICATE */ 2));
|
| @@ -883,7 +892,7 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_OnIndicate) {
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests StartNotifySession success on a characteristic enabling Notify &
|
| // Indicate.
|
| -TEST_F(BluetoothGattCharacteristicTest,
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| StartNotifySession_OnNotifyAndIndicate) {
|
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
|
| /* properties: NOTIFY and INDICATE bits set */ 0x30,
|
| @@ -893,12 +902,12 @@ TEST_F(BluetoothGattCharacteristicTest,
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests multiple StartNotifySession success.
|
| -TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Multiple) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, StartNotifySession_Multiple) {
|
| ASSERT_NO_FATAL_FAILURE(
|
| FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10));
|
| SimulateGattDescriptor(
|
| characteristic1_,
|
| - BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid()
|
| + BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid()
|
| .canonical_value());
|
| ASSERT_EQ(1u, characteristic1_->GetDescriptors().size());
|
|
|
| @@ -927,12 +936,13 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Multiple) {
|
|
|
| #if defined(OS_ANDROID)
|
| // Tests multiple StartNotifySessions pending and then an error.
|
| -TEST_F(BluetoothGattCharacteristicTest, StartNotifySessionError_Multiple) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| + StartNotifySessionError_Multiple) {
|
| ASSERT_NO_FATAL_FAILURE(
|
| FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10));
|
| SimulateGattDescriptor(
|
| characteristic1_,
|
| - BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid()
|
| + BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid()
|
| .canonical_value());
|
| ASSERT_EQ(1u, characteristic1_->GetDescriptors().size());
|
|
|
| @@ -942,23 +952,24 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySessionError_Multiple) {
|
| GetGattErrorCallback(Call::EXPECTED));
|
| EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
|
| EXPECT_EQ(0, callback_count_);
|
| - SimulateGattNotifySessionStartError(characteristic1_,
|
| - BluetoothGattService::GATT_ERROR_FAILED);
|
| + SimulateGattNotifySessionStartError(
|
| + characteristic1_, BluetoothRemoteGattService::GATT_ERROR_FAILED);
|
| EXPECT_EQ(0, callback_count_);
|
| EXPECT_EQ(2, error_callback_count_);
|
| ASSERT_EQ(0u, notify_sessions_.size());
|
| - EXPECT_EQ(BluetoothGattService::GATT_ERROR_FAILED, last_gatt_error_code_);
|
| + EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_FAILED,
|
| + last_gatt_error_code_);
|
| }
|
| #endif // defined(OS_ANDROID)
|
|
|
| #if defined(OS_ANDROID)
|
| // Tests StartNotifySession completing after chrome objects are deleted.
|
| -TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_AfterDeleted) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, StartNotifySession_AfterDeleted) {
|
| ASSERT_NO_FATAL_FAILURE(
|
| FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10));
|
| SimulateGattDescriptor(
|
| characteristic1_,
|
| - BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid()
|
| + BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid()
|
| .canonical_value());
|
| ASSERT_EQ(1u, characteristic1_->GetDescriptors().size());
|
|
|
| @@ -975,13 +986,14 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_AfterDeleted) {
|
| EXPECT_EQ(0, callback_count_);
|
| EXPECT_EQ(1, error_callback_count_);
|
| ASSERT_EQ(0u, notify_sessions_.size());
|
| - EXPECT_EQ(BluetoothGattService::GATT_ERROR_FAILED, last_gatt_error_code_);
|
| + EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_FAILED,
|
| + last_gatt_error_code_);
|
| }
|
| #endif // defined(OS_ANDROID)
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests Characteristic Value changes during a Notify Session.
|
| -TEST_F(BluetoothGattCharacteristicTest, GattCharacteristicValueChanged) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, GattCharacteristicValueChanged) {
|
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
|
| /* properties: NOTIFY */ 0x10,
|
| /* expected_config_descriptor_value: NOTIFY */ 1));
|
| @@ -1005,7 +1017,7 @@ TEST_F(BluetoothGattCharacteristicTest, GattCharacteristicValueChanged) {
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| // Tests Characteristic Value changing after a Notify Session and objects being
|
| // destroyed.
|
| -TEST_F(BluetoothGattCharacteristicTest,
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| GattCharacteristicValueChanged_AfterDeleted) {
|
| ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
|
| /* properties: NOTIFY */ 0x10,
|
| @@ -1024,7 +1036,7 @@ TEST_F(BluetoothGattCharacteristicTest,
|
| #endif // defined(OS_ANDROID) || defined(OS_WIN)
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| -TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_FindNone) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, GetDescriptors_FindNone) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
|
|
|
| EXPECT_EQ(0u, characteristic1_->GetDescriptors().size());
|
| @@ -1032,7 +1044,8 @@ TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_FindNone) {
|
| #endif // defined(OS_ANDROID) || defined(OS_WIN)
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| -TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_and_GetDescriptor) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest,
|
| + GetDescriptors_and_GetDescriptor) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
|
|
|
| // Add several Descriptors:
|
| @@ -1077,7 +1090,7 @@ TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_and_GetDescriptor) {
|
| #endif // defined(OS_ANDROID) || defined(OS_WIN)
|
|
|
| #if defined(OS_ANDROID) || defined(OS_WIN)
|
| -TEST_F(BluetoothGattCharacteristicTest, GetDescriptorsByUUID) {
|
| +TEST_F(BluetoothRemoteGattCharacteristicTest, GetDescriptorsByUUID) {
|
| ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
|
|
|
| // Add several Descriptors:
|
|
|