Index: device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc |
diff --git a/device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc b/device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc |
index f5fe946674888dc81f043d3de086079fee505507..6cebf6021d935bc32331191ca3465524278de3e2 100644 |
--- a/device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc |
+++ b/device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc |
@@ -1,8 +1,6 @@ |
// 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. |
- |
-#include <tuple> |
#include "base/memory/weak_ptr.h" |
#include "device/bluetooth/bluetooth_local_gatt_characteristic.h" |
@@ -46,19 +44,6 @@ |
EXPECT_LT(0u, write_characteristic_->GetIdentifier().size()); |
EXPECT_LT(0u, notify_characteristic_->GetIdentifier().size()); |
CompleteGattSetup(); |
- } |
- |
- void CheckNotification( |
- const BluetoothDevice* expected_device, |
- uint64_t expected_value, |
- bool expected_indicate_flag, |
- const BluetoothTestBase::NotificationType& actual_notification) { |
- if (expected_device) { |
- EXPECT_EQ(expected_device->GetIdentifier(), |
- actual_notification.device_path); |
- } |
- EXPECT_EQ(GetValue(expected_value), actual_notification.value); |
- EXPECT_EQ(expected_indicate_flag, actual_notification.indicate); |
} |
protected: |
@@ -172,94 +157,64 @@ |
#if defined(OS_CHROMEOS) || defined(OS_LINUX) |
TEST_F(BluetoothLocalGattCharacteristicTest, SendNotifications) { |
- BluetoothDevice* device = SimulateLowEnergyDevice(1); |
- const uint64_t kNotifyValue = 0x7331ul; |
- EXPECT_EQ(BluetoothLocalGattCharacteristic::NOTIFICATION_SUCCESS, |
- notify_characteristic_->NotifyValueChanged( |
- device, GetValue(kNotifyValue), false)); |
- CheckNotification( |
- device, kNotifyValue, false, |
- LastNotifactionValueForCharacteristic(notify_characteristic_.get())); |
- |
- const uint64_t kIndicateValue = 0x1337ul; |
- EXPECT_EQ(BluetoothLocalGattCharacteristic::NOTIFICATION_SUCCESS, |
- indicate_characteristic_->NotifyValueChanged( |
- device, GetValue(kIndicateValue), true)); |
- CheckNotification( |
- device, kIndicateValue, true, |
- LastNotifactionValueForCharacteristic(indicate_characteristic_.get())); |
-} |
-#endif // defined(OS_CHROMEOS) || defined(OS_LINUX) |
- |
-#if defined(OS_CHROMEOS) || defined(OS_LINUX) |
-TEST_F(BluetoothLocalGattCharacteristicTest, SendNotificationsToNullDevice) { |
const uint64_t kNotifyValue = 0x7331ul; |
EXPECT_EQ(BluetoothLocalGattCharacteristic::NOTIFICATION_SUCCESS, |
notify_characteristic_->NotifyValueChanged( |
nullptr, GetValue(kNotifyValue), false)); |
- CheckNotification( |
- nullptr, kNotifyValue, false, |
- LastNotifactionValueForCharacteristic(notify_characteristic_.get())); |
+ EXPECT_EQ(kNotifyValue, GetInteger(LastNotifactionValueForCharacteristic( |
+ notify_characteristic_.get()))); |
const uint64_t kIndicateValue = 0x1337ul; |
EXPECT_EQ(BluetoothLocalGattCharacteristic::NOTIFICATION_SUCCESS, |
indicate_characteristic_->NotifyValueChanged( |
nullptr, GetValue(kIndicateValue), true)); |
- CheckNotification( |
- nullptr, kIndicateValue, true, |
- LastNotifactionValueForCharacteristic(indicate_characteristic_.get())); |
+ EXPECT_EQ(kIndicateValue, GetInteger(LastNotifactionValueForCharacteristic( |
+ indicate_characteristic_.get()))); |
} |
#endif // defined(OS_CHROMEOS) || defined(OS_LINUX) |
#if defined(OS_CHROMEOS) || defined(OS_LINUX) |
TEST_F(BluetoothLocalGattCharacteristicTest, SendNotificationsWrongProperties) { |
- BluetoothDevice* device = SimulateLowEnergyDevice(1); |
const uint64_t kNewValue = 0x3334ul; |
EXPECT_EQ(BluetoothLocalGattCharacteristic::NOTIFY_PROPERTY_NOT_SET, |
read_characteristic_->NotifyValueChanged( |
- device, GetValue(kNewValue), false)); |
+ nullptr, GetValue(kNewValue), false)); |
EXPECT_NE(kNewValue, GetInteger(LastNotifactionValueForCharacteristic( |
- read_characteristic_.get()) |
- .value)); |
+ read_characteristic_.get()))); |
EXPECT_EQ(BluetoothLocalGattCharacteristic::NOTIFY_PROPERTY_NOT_SET, |
write_characteristic_->NotifyValueChanged( |
- device, GetValue(kNewValue), false)); |
+ nullptr, GetValue(kNewValue), false)); |
EXPECT_NE(kNewValue, GetInteger(LastNotifactionValueForCharacteristic( |
- write_characteristic_.get()) |
- .value)); |
+ write_characteristic_.get()))); |
const uint64_t kNotifyValue = 0x7331ul; |
EXPECT_EQ(BluetoothLocalGattCharacteristic::INDICATE_PROPERTY_NOT_SET, |
notify_characteristic_->NotifyValueChanged( |
- device, GetValue(kNotifyValue), true)); |
+ nullptr, GetValue(kNotifyValue), true)); |
EXPECT_NE(kNotifyValue, GetInteger(LastNotifactionValueForCharacteristic( |
- notify_characteristic_.get()) |
- .value)); |
+ notify_characteristic_.get()))); |
const uint64_t kIndicateValue = 0x1337ul; |
EXPECT_EQ(BluetoothLocalGattCharacteristic::NOTIFY_PROPERTY_NOT_SET, |
indicate_characteristic_->NotifyValueChanged( |
- device, GetValue(kIndicateValue), false)); |
+ nullptr, GetValue(kIndicateValue), false)); |
EXPECT_NE(kIndicateValue, GetInteger(LastNotifactionValueForCharacteristic( |
- indicate_characteristic_.get()) |
- .value)); |
+ indicate_characteristic_.get()))); |
} |
#endif // defined(OS_CHROMEOS) || defined(OS_LINUX) |
#if defined(OS_CHROMEOS) || defined(OS_LINUX) |
TEST_F(BluetoothLocalGattCharacteristicTest, |
SendNotificationsServiceNotRegistered) { |
- BluetoothDevice* device = SimulateLowEnergyDevice(1); |
service_->Unregister(GetCallback(Call::EXPECTED), |
GetGattErrorCallback(Call::NOT_EXPECTED)); |
const uint64_t kNotifyValue = 0x7331ul; |
EXPECT_EQ(BluetoothLocalGattCharacteristic::SERVICE_NOT_REGISTERED, |
notify_characteristic_->NotifyValueChanged( |
- device, GetValue(kNotifyValue), false)); |
+ nullptr, GetValue(kNotifyValue), false)); |
EXPECT_NE(kNotifyValue, GetInteger(LastNotifactionValueForCharacteristic( |
- notify_characteristic_.get()) |
- .value)); |
+ notify_characteristic_.get()))); |
} |
#endif // defined(OS_CHROMEOS) || defined(OS_LINUX) |