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

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

Issue 2438373002: arc: bluetooth: Set advertisement max slot to 1 (Closed)
Patch Set: remove unit test 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 unified diff | Download patch
« no previous file with comments | « components/arc/bluetooth/arc_bluetooth_bridge.h ('k') | no next file » | 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 mojom::BluetoothGattStatus status = 321 mojom::BluetoothGattStatus status =
322 BroadcastAdvertisement(handle, std::move(adv_data)); 322 BroadcastAdvertisement(handle, std::move(adv_data));
323 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status); 323 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status);
324 EXPECT_EQ(1, NumActiveAdvertisements()); 324 EXPECT_EQ(1, NumActiveAdvertisements());
325 325
326 status = ReleaseAdvertisementHandle(handle); 326 status = ReleaseAdvertisementHandle(handle);
327 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status); 327 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status);
328 EXPECT_EQ(0, NumActiveAdvertisements()); 328 EXPECT_EQ(0, NumActiveAdvertisements());
329 } 329 }
330 330
331 // Invoke multi advertisement methods and make sure they are going down to the
332 // D-Bus clients.
333 TEST_F(ArcBluetoothBridgeTest, MultiAdvertisement) {
elijahtaylor1 2016/10/22 04:04:56 For future reference, you could have done the foll
334 int32_t handle = ReserveAdvertisementHandle();
335 EXPECT_NE(kFailureAdvHandle, handle);
336 EXPECT_EQ(0, NumActiveAdvertisements());
337
338 auto adv_data = base::MakeUnique<device::BluetoothAdvertisement::Data>(
339 device::BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST);
340 mojom::BluetoothGattStatus status =
341 BroadcastAdvertisement(handle, std::move(adv_data));
342 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status);
343 EXPECT_EQ(1, NumActiveAdvertisements());
344
345 int32_t handle2 = ReserveAdvertisementHandle();
346 EXPECT_NE(kFailureAdvHandle, handle2);
347 auto adv_data2 = base::MakeUnique<device::BluetoothAdvertisement::Data>(
348 device::BluetoothAdvertisement::ADVERTISEMENT_TYPE_PERIPHERAL);
349 status = BroadcastAdvertisement(handle2, std::move(adv_data2));
350 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status);
351 EXPECT_EQ(2, NumActiveAdvertisements());
352
353 status = ReleaseAdvertisementHandle(handle);
354 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status);
355 EXPECT_EQ(1, NumActiveAdvertisements());
356
357 status = ReleaseAdvertisementHandle(handle2);
358 EXPECT_EQ(mojom::BluetoothGattStatus::GATT_SUCCESS, status);
359 EXPECT_EQ(0, NumActiveAdvertisements());
360 }
361
362 // This tests that we support releasing reserved but unused handles.
363 // TODO(ejcaruso): When Chrome supports more handles, make sure we
364 // will stop reserving handles before we use all of Chrome's.
365 TEST_F(ArcBluetoothBridgeTest, ReleaseUnusedHandles) {
366 constexpr size_t kMaxBluezAdvertisements =
367 bluez::FakeBluetoothLEAdvertisingManagerClient::kMaxBluezAdvertisements;
368 std::vector<int32_t> reserved_handles;
369
370 for (size_t i = 0; i < kMaxBluezAdvertisements; i++) {
371 int32_t handle = ReserveAdvertisementHandle();
372 if (handle == kFailureAdvHandle)
373 break;
374 reserved_handles.push_back(handle);
375 }
376 EXPECT_GT(reserved_handles.size(), 1Ul);
377 EXPECT_LE(reserved_handles.size(), kMaxBluezAdvertisements);
378 EXPECT_EQ(0, NumActiveAdvertisements());
379
380 for (int32_t handle : reserved_handles) {
381 EXPECT_EQ(ReleaseAdvertisementHandle(handle),
382 mojom::BluetoothGattStatus::GATT_SUCCESS);
383 }
384 }
385
386 } // namespace arc 331 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/bluetooth/arc_bluetooth_bridge.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698