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

Unified Diff: content/browser/bluetooth/bluetooth_blacklist_unittest.cc

Issue 2506813003: Use new wrapper types for web_bluetooth.mojom (Closed)
Patch Set: updated web_bluetooth_impl.cc Created 4 years, 1 month 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: content/browser/bluetooth/bluetooth_blacklist_unittest.cc
diff --git a/content/browser/bluetooth/bluetooth_blacklist_unittest.cc b/content/browser/bluetooth/bluetooth_blacklist_unittest.cc
index d07121b77ff8c9c2afc4e3a3ec0c077d9479c895..112715c2aa3f5687b59096849c42cb75ccc42fa3 100644
--- a/content/browser/bluetooth/bluetooth_blacklist_unittest.cc
+++ b/content/browser/bluetooth/bluetooth_blacklist_unittest.cc
@@ -13,8 +13,8 @@ namespace content {
namespace {
-base::Optional<BluetoothUUID> Canonicalize(const std::string& str) {
- return base::make_optional(device::BluetoothUUID(str));
+BluetoothUUID Canonicalize(const std::string& str) {
ortuno 2016/11/21 04:42:31 I think we can get rid of this now. Canonicalize i
juncai 2016/11/21 21:27:05 Done.
+ return device::BluetoothUUID(str);
}
} // namespace
@@ -225,41 +225,43 @@ TEST_F(BluetoothBlacklistTest, IsExcluded_BluetoothScanFilter_ReturnsFalse) {
list_.Add(BluetoothUUID("ee01"), BluetoothBlacklist::Value::EXCLUDE_READS);
list_.Add(BluetoothUUID("ee02"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
{
- mojo::Array<blink::mojom::WebBluetoothScanFilterPtr> empty_filters;
+ std::vector<blink::mojom::WebBluetoothScanFilterPtr> empty_filters;
EXPECT_FALSE(list_.IsExcluded(empty_filters));
}
{
- mojo::Array<blink::mojom::WebBluetoothScanFilterPtr> single_empty_filter(1);
+ std::vector<blink::mojom::WebBluetoothScanFilterPtr> single_empty_filter(1);
single_empty_filter[0] = blink::mojom::WebBluetoothScanFilter::New();
- single_empty_filter[0]->services =
- mojo::Array<base::Optional<BluetoothUUID>>();
+ single_empty_filter[0]->services = std::vector<BluetoothUUID>();
- EXPECT_EQ(0u, single_empty_filter[0]->services.size());
+ EXPECT_EQ(0u, single_empty_filter[0]->services->size());
EXPECT_FALSE(list_.IsExcluded(single_empty_filter));
}
{
- mojo::Array<blink::mojom::WebBluetoothScanFilterPtr>
+ std::vector<blink::mojom::WebBluetoothScanFilterPtr>
single_non_matching_filter(1);
single_non_matching_filter[0] = blink::mojom::WebBluetoothScanFilter::New();
- single_non_matching_filter[0]->services.push_back(Canonicalize("0000"));
+ single_non_matching_filter[0]->services = std::vector<BluetoothUUID>();
+ single_non_matching_filter[0]->services->push_back(Canonicalize("0000"));
EXPECT_FALSE(list_.IsExcluded(single_non_matching_filter));
}
{
- mojo::Array<blink::mojom::WebBluetoothScanFilterPtr>
+ std::vector<blink::mojom::WebBluetoothScanFilterPtr>
multiple_non_matching_filters(2);
multiple_non_matching_filters[0] =
blink::mojom::WebBluetoothScanFilter::New();
- multiple_non_matching_filters[0]->services.push_back(Canonicalize("0000"));
- multiple_non_matching_filters[0]->services.push_back(Canonicalize("ee01"));
+ multiple_non_matching_filters[0]->services = std::vector<BluetoothUUID>();
+ multiple_non_matching_filters[0]->services->push_back(Canonicalize("0000"));
+ multiple_non_matching_filters[0]->services->push_back(Canonicalize("ee01"));
multiple_non_matching_filters[1] =
blink::mojom::WebBluetoothScanFilter::New();
- multiple_non_matching_filters[1]->services.push_back(Canonicalize("ee02"));
- multiple_non_matching_filters[1]->services.push_back(Canonicalize("0003"));
+ multiple_non_matching_filters[1]->services = std::vector<BluetoothUUID>();
+ multiple_non_matching_filters[1]->services->push_back(Canonicalize("ee02"));
+ multiple_non_matching_filters[1]->services->push_back(Canonicalize("0003"));
EXPECT_FALSE(list_.IsExcluded(multiple_non_matching_filters));
}
@@ -272,7 +274,8 @@ TEST_F(BluetoothBlacklistTest, IsExcluded_BluetoothScanFilter_ReturnsTrue) {
1);
single_matching_filter[0] = blink::mojom::WebBluetoothScanFilter::New();
- single_matching_filter[0]->services.push_back(Canonicalize("eeee"));
+ single_matching_filter[0]->services = std::vector<BluetoothUUID>();
+ single_matching_filter[0]->services->push_back(Canonicalize("eeee"));
EXPECT_TRUE(list_.IsExcluded(single_matching_filter));
}
@@ -281,12 +284,14 @@ TEST_F(BluetoothBlacklistTest, IsExcluded_BluetoothScanFilter_ReturnsTrue) {
2);
first_matching_filter[0] = blink::mojom::WebBluetoothScanFilter::New();
- first_matching_filter[0]->services.push_back(Canonicalize("eeee"));
- first_matching_filter[0]->services.push_back(Canonicalize("0001"));
+ first_matching_filter[0]->services = std::vector<BluetoothUUID>();
+ first_matching_filter[0]->services->push_back(Canonicalize("eeee"));
+ first_matching_filter[0]->services->push_back(Canonicalize("0001"));
first_matching_filter[1] = blink::mojom::WebBluetoothScanFilter::New();
- first_matching_filter[1]->services.push_back(Canonicalize("0002"));
- first_matching_filter[1]->services.push_back(Canonicalize("0003"));
+ first_matching_filter[1]->services = std::vector<BluetoothUUID>();
+ first_matching_filter[1]->services->push_back(Canonicalize("0002"));
+ first_matching_filter[1]->services->push_back(Canonicalize("0003"));
EXPECT_TRUE(list_.IsExcluded(first_matching_filter));
}
@@ -295,12 +300,14 @@ TEST_F(BluetoothBlacklistTest, IsExcluded_BluetoothScanFilter_ReturnsTrue) {
2);
last_matching_filter[0] = blink::mojom::WebBluetoothScanFilter::New();
- last_matching_filter[0]->services.push_back(Canonicalize("0001"));
- last_matching_filter[0]->services.push_back(Canonicalize("0001"));
+ last_matching_filter[0]->services = std::vector<BluetoothUUID>();
+ last_matching_filter[0]->services->push_back(Canonicalize("0001"));
+ last_matching_filter[0]->services->push_back(Canonicalize("0001"));
last_matching_filter[1] = blink::mojom::WebBluetoothScanFilter::New();
- last_matching_filter[1]->services.push_back(Canonicalize("0002"));
- last_matching_filter[1]->services.push_back(Canonicalize("eeee"));
+ last_matching_filter[1]->services = std::vector<BluetoothUUID>();
+ last_matching_filter[1]->services->push_back(Canonicalize("0002"));
+ last_matching_filter[1]->services->push_back(Canonicalize("eeee"));
EXPECT_TRUE(list_.IsExcluded(last_matching_filter));
}
@@ -309,12 +316,14 @@ TEST_F(BluetoothBlacklistTest, IsExcluded_BluetoothScanFilter_ReturnsTrue) {
multiple_matching_filters(2);
multiple_matching_filters[0] = blink::mojom::WebBluetoothScanFilter::New();
- multiple_matching_filters[0]->services.push_back(Canonicalize("eeee"));
- multiple_matching_filters[0]->services.push_back(Canonicalize("eeee"));
+ multiple_matching_filters[0]->services = std::vector<BluetoothUUID>();
+ multiple_matching_filters[0]->services->push_back(Canonicalize("eeee"));
+ multiple_matching_filters[0]->services->push_back(Canonicalize("eeee"));
multiple_matching_filters[1] = blink::mojom::WebBluetoothScanFilter::New();
- multiple_matching_filters[1]->services.push_back(Canonicalize("eeee"));
- multiple_matching_filters[1]->services.push_back(Canonicalize("eeee"));
+ multiple_matching_filters[1]->services = std::vector<BluetoothUUID>();
+ multiple_matching_filters[1]->services->push_back(Canonicalize("eeee"));
+ multiple_matching_filters[1]->services->push_back(Canonicalize("eeee"));
EXPECT_TRUE(list_.IsExcluded(multiple_matching_filters));
}
@@ -330,24 +339,21 @@ TEST_F(BluetoothBlacklistTest, RemoveExcludedUUIDs_NonMatching) {
{
// Empty optional_services.
blink::mojom::WebBluetoothRequestDeviceOptions options;
- options.optional_services = mojo::Array<base::Optional<BluetoothUUID>>();
- mojo::Array<base::Optional<BluetoothUUID>> expected =
- options.optional_services.Clone();
+ std::vector<BluetoothUUID> expected = options.optional_services;
list_.RemoveExcludedUUIDs(&options);
- EXPECT_TRUE(options.optional_services.Equals(expected));
+ EXPECT_EQ(expected, options.optional_services);
}
{
// One non-matching service in optional_services.
blink::mojom::WebBluetoothRequestDeviceOptions options;
options.optional_services.push_back(Canonicalize("0000"));
- mojo::Array<base::Optional<BluetoothUUID>> expected =
- options.optional_services.Clone();
+ std::vector<BluetoothUUID> expected = options.optional_services;
list_.RemoveExcludedUUIDs(&options);
- EXPECT_TRUE(options.optional_services.Equals(expected));
+ EXPECT_EQ(expected, options.optional_services);
}
{
// Multiple non-matching services in optional_services.
@@ -357,11 +363,10 @@ TEST_F(BluetoothBlacklistTest, RemoveExcludedUUIDs_NonMatching) {
options.optional_services.push_back(Canonicalize("ee02"));
options.optional_services.push_back(Canonicalize("0003"));
- mojo::Array<base::Optional<BluetoothUUID>> expected =
- options.optional_services.Clone();
+ std::vector<BluetoothUUID> expected = options.optional_services;
list_.RemoveExcludedUUIDs(&options);
- EXPECT_TRUE(options.optional_services.Equals(expected));
+ EXPECT_EQ(expected, options.optional_services);
}
}
@@ -375,11 +380,11 @@ TEST_F(BluetoothBlacklistTest, RemoveExcludedUuids_Matching) {
blink::mojom::WebBluetoothRequestDeviceOptions options;
options.optional_services.push_back(Canonicalize("eeee"));
- mojo::Array<base::Optional<BluetoothUUID>> expected;
+ std::vector<BluetoothUUID> expected;
list_.RemoveExcludedUUIDs(&options);
- EXPECT_TRUE(options.optional_services.Equals(expected));
+ EXPECT_EQ(expected, options.optional_services);
}
{
// Single matching of many services in optional_services.
@@ -388,12 +393,12 @@ TEST_F(BluetoothBlacklistTest, RemoveExcludedUuids_Matching) {
options.optional_services.push_back(Canonicalize("eeee"));
options.optional_services.push_back(Canonicalize("0001"));
- mojo::Array<base::Optional<BluetoothUUID>> expected;
+ std::vector<BluetoothUUID> expected;
expected.push_back(Canonicalize("0000"));
expected.push_back(Canonicalize("0001"));
list_.RemoveExcludedUUIDs(&options);
- EXPECT_TRUE(options.optional_services.Equals(expected));
+ EXPECT_EQ(expected, options.optional_services);
}
{
// All matching of many services in optional_services.
@@ -403,10 +408,10 @@ TEST_F(BluetoothBlacklistTest, RemoveExcludedUuids_Matching) {
options.optional_services.push_back(Canonicalize("eee3"));
options.optional_services.push_back(Canonicalize("eeee"));
- mojo::Array<base::Optional<BluetoothUUID>> expected;
+ std::vector<BluetoothUUID> expected;
list_.RemoveExcludedUUIDs(&options);
- EXPECT_TRUE(options.optional_services.Equals(expected));
+ EXPECT_EQ(expected, options.optional_services);
}
}

Powered by Google App Engine
This is Rietveld 408576698