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

Side by Side Diff: components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc

Issue 2204263003: arc: bluetooth: Use UUID 16 bits in advertising data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test + rebase to crrev.com/2244703005 Created 4 years, 4 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 | « components/arc/bluetooth/arc_bluetooth_bridge.cc ('k') | components/arc/common/bluetooth.mojom » ('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 "components/arc/bluetooth/arc_bluetooth_bridge.h" 5 #include "components/arc/bluetooth/arc_bluetooth_bridge.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 fake_bluetooth_instance_->le_device_found_data().back()->adv_data(); 134 fake_bluetooth_instance_->le_device_found_data().back()->adv_data();
135 135
136 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress), 136 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress),
137 addr->To<std::string>()); 137 addr->To<std::string>());
138 EXPECT_EQ(2u, adv_data.size()); 138 EXPECT_EQ(2u, adv_data.size());
139 139
140 EXPECT_TRUE(adv_data[0]->is_local_name()); 140 EXPECT_TRUE(adv_data[0]->is_local_name());
141 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyName), 141 EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyName),
142 adv_data[0]->get_local_name().To<std::string>()); 142 adv_data[0]->get_local_name().To<std::string>());
143 143
144 EXPECT_TRUE(adv_data[1]->is_service_uuids()); 144 EXPECT_TRUE(adv_data[1]->is_service_uuids_16());
145 EXPECT_EQ(1u, adv_data[1]->get_service_uuids().size()); 145 EXPECT_EQ(1u, adv_data[1]->get_service_uuids_16().size());
146 EXPECT_EQ(device::BluetoothUUID( 146
147 bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID), 147 char uuid16_str[5];
148 adv_data[1]->get_service_uuids()[0].To<device::BluetoothUUID>()); 148 snprintf(uuid16_str, sizeof(uuid16_str), "%04x",
Luis Héctor Chávez 2016/08/15 22:47:13 nit: prefer base::StringPrintf("%04x", ...) over s
puthik_chromium 2016/08/15 23:19:20 Done.
149 adv_data[1]->get_service_uuids_16()[0]);
150 EXPECT_EQ(bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID,
151 device::BluetoothUUID(uuid16_str).canonical_value());
149 } 152 }
150 153
151 // Invoke GetGattDB and check correctness of the GattDB sent via arc bridge. 154 // Invoke GetGattDB and check correctness of the GattDB sent via arc bridge.
152 TEST_F(ArcBluetoothBridgeTest, GetGattDB) { 155 TEST_F(ArcBluetoothBridgeTest, GetGattDB) {
153 AddTestDevice(); 156 AddTestDevice();
154 157
155 arc_bluetooth_bridge_->GetGattDB(mojom::BluetoothAddress::From( 158 arc_bluetooth_bridge_->GetGattDB(mojom::BluetoothAddress::From(
156 std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress))); 159 std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress)));
157 EXPECT_EQ(1u, fake_bluetooth_instance_->gatt_db_result().size()); 160 EXPECT_EQ(1u, fake_bluetooth_instance_->gatt_db_result().size());
158 161
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 EXPECT_EQ(device::BluetoothUUID(bluez::FakeBluetoothGattCharacteristicClient:: 205 EXPECT_EQ(device::BluetoothUUID(bluez::FakeBluetoothGattCharacteristicClient::
203 kHeartRateControlPointUUID), 206 kHeartRateControlPointUUID),
204 db[4]->uuid.To<device::BluetoothUUID>()); 207 db[4]->uuid.To<device::BluetoothUUID>());
205 EXPECT_EQ(mojom::BluetoothGattDBAttributeType::BTGATT_DB_CHARACTERISTIC, 208 EXPECT_EQ(mojom::BluetoothGattDBAttributeType::BTGATT_DB_CHARACTERISTIC,
206 db[4]->type); 209 db[4]->type);
207 EXPECT_EQ(device::BluetoothGattCharacteristic::PROPERTY_WRITE, 210 EXPECT_EQ(device::BluetoothGattCharacteristic::PROPERTY_WRITE,
208 db[4]->properties); 211 db[4]->properties);
209 } 212 }
210 213
211 } // namespace arc 214 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/bluetooth/arc_bluetooth_bridge.cc ('k') | components/arc/common/bluetooth.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698