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

Unified Diff: components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc

Issue 2354933003: arc: bluetooth: Clean up arc_bluetooth_bridge (Closed)
Patch Set: Rebase Created 4 years, 2 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: components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc
diff --git a/components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc b/components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc
index 9274e386378c46fa7bd9c7e280a06f7086e16a3c..b066e93f00918db15ba3fa45db28bc7febbcca2b 100644
--- a/components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc
+++ b/components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc
@@ -24,6 +24,11 @@
#include "mojo/public/cpp/bindings/array.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace {
+constexpr int16_t kTestRssi = -50;
+constexpr int16_t kTestRssi2 = -70;
+}
+
namespace arc {
class ArcBluetoothBridgeTest : public testing::Test {
@@ -47,6 +52,18 @@ class ArcBluetoothBridgeTest : public testing::Test {
dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
fake_bluetooth_gatt_characteristic_client->ExposeHeartRateCharacteristics(
fake_bluetooth_gatt_service_client->GetHeartRateServicePath());
+
+ ChangeTestDeviceRssi(kTestRssi);
+ }
+
+ void ChangeTestDeviceRssi(uint16_t rssi) {
+ bluez::BluezDBusManager* dbus_manager = bluez::BluezDBusManager::Get();
+ auto* fake_bluetooth_device_client =
+ static_cast<bluez::FakeBluetoothDeviceClient*>(
+ dbus_manager->GetBluetoothDeviceClient());
+ fake_bluetooth_device_client->UpdateDeviceRSSI(
+ dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath),
+ rssi);
}
void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter) {
@@ -96,7 +113,7 @@ class ArcBluetoothBridgeTest : public testing::Test {
TEST_F(ArcBluetoothBridgeTest, DeviceFound) {
EXPECT_EQ(0u, fake_bluetooth_instance_->device_found_data().size());
AddTestDevice();
- EXPECT_EQ(1u, fake_bluetooth_instance_->device_found_data().size());
+ EXPECT_EQ(2u, fake_bluetooth_instance_->device_found_data().size());
const mojo::Array<mojom::BluetoothPropertyPtr>& prop =
fake_bluetooth_instance_->device_found_data().back();
@@ -120,19 +137,29 @@ TEST_F(ArcBluetoothBridgeTest, DeviceFound) {
EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyName),
prop[5]->get_remote_friendly_name());
EXPECT_TRUE(prop[6]->is_remote_rssi());
+ EXPECT_EQ(kTestRssi, prop[6]->get_remote_rssi());
+
+ ChangeTestDeviceRssi(kTestRssi2);
+ EXPECT_EQ(3u, fake_bluetooth_instance_->device_found_data().size());
+ const mojo::Array<mojom::BluetoothPropertyPtr>& prop2 =
+ fake_bluetooth_instance_->device_found_data().back();
+ EXPECT_EQ(7u, prop2.size());
+ EXPECT_TRUE(prop2[6]->is_remote_rssi());
+ EXPECT_EQ(kTestRssi2, prop2[6]->get_remote_rssi());
}
// Invoke OnDiscoveryStarted to send cached device to BT instance,
// and check correctness of the Advertising data sent via arc bridge.
TEST_F(ArcBluetoothBridgeTest, LEDeviceFound) {
- EXPECT_EQ(0u, fake_bluetooth_instance_->device_found_data().size());
+ EXPECT_EQ(0u, fake_bluetooth_instance_->le_device_found_data().size());
AddTestDevice();
EXPECT_EQ(1u, fake_bluetooth_instance_->le_device_found_data().size());
- const mojom::BluetoothAddressPtr& addr =
- fake_bluetooth_instance_->le_device_found_data().back()->addr();
+ const auto& le_device_found_data =
+ fake_bluetooth_instance_->le_device_found_data().back();
+ const mojom::BluetoothAddressPtr& addr = le_device_found_data->addr();
const mojo::Array<mojom::BluetoothAdvertisingDataPtr>& adv_data =
- fake_bluetooth_instance_->le_device_found_data().back()->adv_data();
+ le_device_found_data->adv_data();
EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress),
addr->To<std::string>());
@@ -146,6 +173,12 @@ TEST_F(ArcBluetoothBridgeTest, LEDeviceFound) {
EXPECT_EQ(1u, adv_data[1]->get_service_uuids().size());
EXPECT_EQ(bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID,
adv_data[1]->get_service_uuids()[0].canonical_value());
+ EXPECT_EQ(kTestRssi, le_device_found_data->rssi());
+
+ ChangeTestDeviceRssi(kTestRssi2);
+ EXPECT_EQ(2u, fake_bluetooth_instance_->le_device_found_data().size());
+ EXPECT_EQ(kTestRssi2,
+ fake_bluetooth_instance_->le_device_found_data().back()->rssi());
}
// Invoke GetGattDB and check correctness of the GattDB sent via arc bridge.
« no previous file with comments | « components/arc/bluetooth/arc_bluetooth_bridge.cc ('k') | device/bluetooth/dbus/fake_bluetooth_device_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698