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

Unified Diff: device/bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc

Issue 2394683007: Reland "components/arc: implement multi advertising" (Closed)
Patch Set: 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: device/bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc
diff --git a/device/bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc b/device/bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc
index bc10c5f14de2a63f4c9a12cd6c18b1c1c124af02..bbf8b36d27fb78d13bb72410a3a04bfd6e81d53c 100644
--- a/device/bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc
+++ b/device/bluetooth/bluez/bluetooth_advertisement_bluez_unittest.cc
@@ -19,6 +19,7 @@
#include "device/bluetooth/bluetooth_advertisement.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
#include "device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider.h"
+#include "device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.h"
#include "testing/gtest/include/gtest/gtest.h"
using device::BluetoothAdapter;
@@ -207,15 +208,35 @@ TEST_F(BluetoothAdvertisementBlueZTest, RegisterSucceeded) {
ExpectSuccess();
}
-TEST_F(BluetoothAdvertisementBlueZTest, DoubleRegisterFailed) {
+TEST_F(BluetoothAdvertisementBlueZTest, DoubleRegisterSucceeded) {
scoped_refptr<BluetoothAdvertisement> advertisement = CreateAdvertisement();
ExpectSuccess();
EXPECT_TRUE(advertisement);
- // Creating a second advertisement should give us an error.
+ // Creating a second advertisement should still be fine.
scoped_refptr<BluetoothAdvertisement> advertisement2 = CreateAdvertisement();
+ ExpectSuccess();
+ EXPECT_TRUE(advertisement2);
+}
+
+TEST_F(BluetoothAdvertisementBlueZTest, RegisterTooManyFailed) {
+ // Register the maximum available number of advertisements.
+ constexpr size_t kMaxBluezAdvertisements =
+ bluez::FakeBluetoothLEAdvertisingManagerClient::kMaxBluezAdvertisements;
+
+ std::vector<scoped_refptr<BluetoothAdvertisement>> advertisements;
+ scoped_refptr<BluetoothAdvertisement> current_advertisement;
+ for (size_t i = 0; i < kMaxBluezAdvertisements; i++) {
+ current_advertisement = CreateAdvertisement();
+ ExpectSuccess();
+ EXPECT_TRUE(current_advertisement);
+ advertisements.emplace_back(std::move(current_advertisement));
+ }
+
+ // The next advertisement should fail to register.
+ current_advertisement = CreateAdvertisement();
ExpectError(BluetoothAdvertisement::ERROR_ADVERTISEMENT_ALREADY_EXISTS);
- EXPECT_FALSE(advertisement2);
+ EXPECT_FALSE(current_advertisement);
}
TEST_F(BluetoothAdvertisementBlueZTest, DoubleUnregisterFailed) {

Powered by Google App Engine
This is Rietveld 408576698