| Index: content/browser/bluetooth/bluetooth_blocklist_unittest.cc
|
| diff --git a/content/browser/bluetooth/bluetooth_blacklist_unittest.cc b/content/browser/bluetooth/bluetooth_blocklist_unittest.cc
|
| similarity index 81%
|
| rename from content/browser/bluetooth/bluetooth_blacklist_unittest.cc
|
| rename to content/browser/bluetooth/bluetooth_blocklist_unittest.cc
|
| index d07121b77ff8c9c2afc4e3a3ec0c077d9479c895..ad348d0f2e6aa1a8b5d3b77a8e7dec375203732e 100644
|
| --- a/content/browser/bluetooth/bluetooth_blacklist_unittest.cc
|
| +++ b/content/browser/bluetooth/bluetooth_blocklist_unittest.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "content/browser/bluetooth/bluetooth_blacklist.h"
|
| +#include "content/browser/bluetooth/bluetooth_blocklist.h"
|
|
|
| #include "device/bluetooth/bluetooth_uuid.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| @@ -19,121 +19,121 @@ base::Optional<BluetoothUUID> Canonicalize(const std::string& str) {
|
|
|
| } // namespace
|
|
|
| -class BluetoothBlacklistTest : public ::testing::Test {
|
| +class BluetoothBlocklistTest : public ::testing::Test {
|
| public:
|
| - BluetoothBlacklistTest() : list_(BluetoothBlacklist::Get()) {
|
| - // Because BluetoothBlacklist is used via a singleton instance, the data
|
| + BluetoothBlocklistTest() : list_(BluetoothBlocklist::Get()) {
|
| + // Because BluetoothBlocklist is used via a singleton instance, the data
|
| // must be reset for each test.
|
| list_.ResetToDefaultValuesForTest();
|
| }
|
| - BluetoothBlacklist& list_;
|
| + BluetoothBlocklist& list_;
|
| };
|
|
|
| -TEST_F(BluetoothBlacklistTest, NonExcludedUUID) {
|
| +TEST_F(BluetoothBlocklistTest, NonExcludedUUID) {
|
| BluetoothUUID non_excluded_uuid("00000000-0000-0000-0000-000000000000");
|
| EXPECT_FALSE(list_.IsExcluded(non_excluded_uuid));
|
| EXPECT_FALSE(list_.IsExcludedFromReads(non_excluded_uuid));
|
| EXPECT_FALSE(list_.IsExcludedFromWrites(non_excluded_uuid));
|
| }
|
|
|
| -TEST_F(BluetoothBlacklistTest, ExcludeUUID) {
|
| +TEST_F(BluetoothBlocklistTest, ExcludeUUID) {
|
| BluetoothUUID excluded_uuid("eeee");
|
| - list_.Add(excluded_uuid, BluetoothBlacklist::Value::EXCLUDE);
|
| + list_.Add(excluded_uuid, BluetoothBlocklist::Value::EXCLUDE);
|
| EXPECT_TRUE(list_.IsExcluded(excluded_uuid));
|
| EXPECT_TRUE(list_.IsExcludedFromReads(excluded_uuid));
|
| EXPECT_TRUE(list_.IsExcludedFromWrites(excluded_uuid));
|
| }
|
|
|
| -TEST_F(BluetoothBlacklistTest, ExcludeReadsUUID) {
|
| +TEST_F(BluetoothBlocklistTest, ExcludeReadsUUID) {
|
| BluetoothUUID exclude_reads_uuid("eeee");
|
| - list_.Add(exclude_reads_uuid, BluetoothBlacklist::Value::EXCLUDE_READS);
|
| + list_.Add(exclude_reads_uuid, BluetoothBlocklist::Value::EXCLUDE_READS);
|
| EXPECT_FALSE(list_.IsExcluded(exclude_reads_uuid));
|
| EXPECT_TRUE(list_.IsExcludedFromReads(exclude_reads_uuid));
|
| EXPECT_FALSE(list_.IsExcludedFromWrites(exclude_reads_uuid));
|
| }
|
|
|
| -TEST_F(BluetoothBlacklistTest, ExcludeWritesUUID) {
|
| +TEST_F(BluetoothBlocklistTest, ExcludeWritesUUID) {
|
| BluetoothUUID exclude_writes_uuid("eeee");
|
| - list_.Add(exclude_writes_uuid, BluetoothBlacklist::Value::EXCLUDE_WRITES);
|
| + list_.Add(exclude_writes_uuid, BluetoothBlocklist::Value::EXCLUDE_WRITES);
|
| EXPECT_FALSE(list_.IsExcluded(exclude_writes_uuid));
|
| EXPECT_FALSE(list_.IsExcludedFromReads(exclude_writes_uuid));
|
| EXPECT_TRUE(list_.IsExcludedFromWrites(exclude_writes_uuid));
|
| }
|
|
|
| -TEST_F(BluetoothBlacklistTest, InvalidUUID) {
|
| +TEST_F(BluetoothBlocklistTest, InvalidUUID) {
|
| BluetoothUUID empty_string_uuid("");
|
| EXPECT_DEATH_IF_SUPPORTED(
|
| - list_.Add(empty_string_uuid, BluetoothBlacklist::Value::EXCLUDE), "");
|
| + list_.Add(empty_string_uuid, BluetoothBlocklist::Value::EXCLUDE), "");
|
| EXPECT_DEATH_IF_SUPPORTED(list_.IsExcluded(empty_string_uuid), "");
|
| EXPECT_DEATH_IF_SUPPORTED(list_.IsExcludedFromReads(empty_string_uuid), "");
|
| EXPECT_DEATH_IF_SUPPORTED(list_.IsExcludedFromWrites(empty_string_uuid), "");
|
|
|
| BluetoothUUID invalid_string_uuid("Not a valid UUID string.");
|
| EXPECT_DEATH_IF_SUPPORTED(
|
| - list_.Add(invalid_string_uuid, BluetoothBlacklist::Value::EXCLUDE), "");
|
| + list_.Add(invalid_string_uuid, BluetoothBlocklist::Value::EXCLUDE), "");
|
| EXPECT_DEATH_IF_SUPPORTED(list_.IsExcluded(invalid_string_uuid), "");
|
| EXPECT_DEATH_IF_SUPPORTED(list_.IsExcludedFromReads(invalid_string_uuid), "");
|
| EXPECT_DEATH_IF_SUPPORTED(list_.IsExcludedFromWrites(invalid_string_uuid),
|
| "");
|
| }
|
|
|
| -// Abreviated UUIDs used to create, or test against, the blacklist work
|
| +// Abreviated UUIDs used to create, or test against, the blocklist work
|
| // correctly compared to full UUIDs.
|
| -TEST_F(BluetoothBlacklistTest, AbreviatedUUIDs) {
|
| - list_.Add(BluetoothUUID("aaaa"), BluetoothBlacklist::Value::EXCLUDE);
|
| +TEST_F(BluetoothBlocklistTest, AbreviatedUUIDs) {
|
| + list_.Add(BluetoothUUID("aaaa"), BluetoothBlocklist::Value::EXCLUDE);
|
| EXPECT_TRUE(
|
| list_.IsExcluded(BluetoothUUID("0000aaaa-0000-1000-8000-00805f9b34fb")));
|
|
|
| list_.Add(BluetoothUUID("0000bbbb-0000-1000-8000-00805f9b34fb"),
|
| - BluetoothBlacklist::Value::EXCLUDE);
|
| + BluetoothBlocklist::Value::EXCLUDE);
|
| EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("bbbb")));
|
| }
|
|
|
| // Tests permutations of previous values and then Add() with a new value,
|
| // requiring result to be strictest result of the combination.
|
| -TEST_F(BluetoothBlacklistTest, Add_MergingExcludeValues) {
|
| - list_.Add(BluetoothUUID("ee01"), BluetoothBlacklist::Value::EXCLUDE);
|
| - list_.Add(BluetoothUUID("ee01"), BluetoothBlacklist::Value::EXCLUDE);
|
| +TEST_F(BluetoothBlocklistTest, Add_MergingExcludeValues) {
|
| + list_.Add(BluetoothUUID("ee01"), BluetoothBlocklist::Value::EXCLUDE);
|
| + list_.Add(BluetoothUUID("ee01"), BluetoothBlocklist::Value::EXCLUDE);
|
| EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("ee01")));
|
|
|
| - list_.Add(BluetoothUUID("ee02"), BluetoothBlacklist::Value::EXCLUDE);
|
| - list_.Add(BluetoothUUID("ee02"), BluetoothBlacklist::Value::EXCLUDE_READS);
|
| + list_.Add(BluetoothUUID("ee02"), BluetoothBlocklist::Value::EXCLUDE);
|
| + list_.Add(BluetoothUUID("ee02"), BluetoothBlocklist::Value::EXCLUDE_READS);
|
| EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("ee02")));
|
|
|
| - list_.Add(BluetoothUUID("ee03"), BluetoothBlacklist::Value::EXCLUDE);
|
| - list_.Add(BluetoothUUID("ee03"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
|
| + list_.Add(BluetoothUUID("ee03"), BluetoothBlocklist::Value::EXCLUDE);
|
| + list_.Add(BluetoothUUID("ee03"), BluetoothBlocklist::Value::EXCLUDE_WRITES);
|
| EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("ee03")));
|
|
|
| - list_.Add(BluetoothUUID("ee04"), BluetoothBlacklist::Value::EXCLUDE_READS);
|
| - list_.Add(BluetoothUUID("ee04"), BluetoothBlacklist::Value::EXCLUDE);
|
| + list_.Add(BluetoothUUID("ee04"), BluetoothBlocklist::Value::EXCLUDE_READS);
|
| + list_.Add(BluetoothUUID("ee04"), BluetoothBlocklist::Value::EXCLUDE);
|
| EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("ee04")));
|
|
|
| - list_.Add(BluetoothUUID("ee05"), BluetoothBlacklist::Value::EXCLUDE_READS);
|
| - list_.Add(BluetoothUUID("ee05"), BluetoothBlacklist::Value::EXCLUDE_READS);
|
| + list_.Add(BluetoothUUID("ee05"), BluetoothBlocklist::Value::EXCLUDE_READS);
|
| + list_.Add(BluetoothUUID("ee05"), BluetoothBlocklist::Value::EXCLUDE_READS);
|
| EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("ee05")));
|
| EXPECT_TRUE(list_.IsExcludedFromReads(BluetoothUUID("ee05")));
|
|
|
| - list_.Add(BluetoothUUID("ee06"), BluetoothBlacklist::Value::EXCLUDE_READS);
|
| - list_.Add(BluetoothUUID("ee06"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
|
| + list_.Add(BluetoothUUID("ee06"), BluetoothBlocklist::Value::EXCLUDE_READS);
|
| + list_.Add(BluetoothUUID("ee06"), BluetoothBlocklist::Value::EXCLUDE_WRITES);
|
| EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("ee06")));
|
|
|
| - list_.Add(BluetoothUUID("ee07"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
|
| - list_.Add(BluetoothUUID("ee07"), BluetoothBlacklist::Value::EXCLUDE);
|
| + list_.Add(BluetoothUUID("ee07"), BluetoothBlocklist::Value::EXCLUDE_WRITES);
|
| + list_.Add(BluetoothUUID("ee07"), BluetoothBlocklist::Value::EXCLUDE);
|
| EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("ee07")));
|
|
|
| - list_.Add(BluetoothUUID("ee08"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
|
| - list_.Add(BluetoothUUID("ee08"), BluetoothBlacklist::Value::EXCLUDE_READS);
|
| + list_.Add(BluetoothUUID("ee08"), BluetoothBlocklist::Value::EXCLUDE_WRITES);
|
| + list_.Add(BluetoothUUID("ee08"), BluetoothBlocklist::Value::EXCLUDE_READS);
|
| EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("ee08")));
|
|
|
| - list_.Add(BluetoothUUID("ee09"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
|
| - list_.Add(BluetoothUUID("ee09"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
|
| + list_.Add(BluetoothUUID("ee09"), BluetoothBlocklist::Value::EXCLUDE_WRITES);
|
| + list_.Add(BluetoothUUID("ee09"), BluetoothBlocklist::Value::EXCLUDE_WRITES);
|
| EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("ee09")));
|
| EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("ee09")));
|
| }
|
|
|
| // Tests Add() with string that contains many UUID:exclusion value pairs,
|
| -// checking that the correct blacklist entries are created for them.
|
| -TEST_F(BluetoothBlacklistTest, Add_StringWithValidEntries) {
|
| +// checking that the correct blocklist entries are created for them.
|
| +TEST_F(BluetoothBlocklistTest, Add_StringWithValidEntries) {
|
| list_.Add(
|
| "0001:e,0002:r,0003:w, " // Single items.
|
| "0004:r,0004:r, " // Duplicate items.
|
| @@ -158,7 +158,7 @@ TEST_F(BluetoothBlacklistTest, Add_StringWithValidEntries) {
|
| }
|
|
|
| // Tests Add() with strings that contain no valid UUID:exclusion value.
|
| -TEST_F(BluetoothBlacklistTest, Add_StringsWithNoValidEntries) {
|
| +TEST_F(BluetoothBlocklistTest, Add_StringsWithNoValidEntries) {
|
| size_t previous_list_size = list_.size();
|
| list_.Add("");
|
| list_.Add("~!@#$%^&*()-_=+[]{}/*-");
|
| @@ -185,7 +185,7 @@ TEST_F(BluetoothBlacklistTest, Add_StringsWithNoValidEntries) {
|
|
|
| // Tests Add() with strings that contain exactly one valid UUID:exclusion value
|
| // pair, and optionally other issues in the string that are ignored.
|
| -TEST_F(BluetoothBlacklistTest, Add_StringsWithOneValidEntry) {
|
| +TEST_F(BluetoothBlocklistTest, Add_StringsWithOneValidEntry) {
|
| size_t previous_list_size = list_.size();
|
| list_.Add("0001:e");
|
| EXPECT_EQ(++previous_list_size, list_.size());
|
| @@ -220,10 +220,10 @@ TEST_F(BluetoothBlacklistTest, Add_StringsWithOneValidEntry) {
|
| EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("0009")));
|
| }
|
|
|
| -TEST_F(BluetoothBlacklistTest, IsExcluded_BluetoothScanFilter_ReturnsFalse) {
|
| - list_.Add(BluetoothUUID("eeee"), BluetoothBlacklist::Value::EXCLUDE);
|
| - list_.Add(BluetoothUUID("ee01"), BluetoothBlacklist::Value::EXCLUDE_READS);
|
| - list_.Add(BluetoothUUID("ee02"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
|
| +TEST_F(BluetoothBlocklistTest, IsExcluded_BluetoothScanFilter_ReturnsFalse) {
|
| + list_.Add(BluetoothUUID("eeee"), BluetoothBlocklist::Value::EXCLUDE);
|
| + list_.Add(BluetoothUUID("ee01"), BluetoothBlocklist::Value::EXCLUDE_READS);
|
| + list_.Add(BluetoothUUID("ee02"), BluetoothBlocklist::Value::EXCLUDE_WRITES);
|
| {
|
| mojo::Array<blink::mojom::WebBluetoothScanFilterPtr> empty_filters;
|
| EXPECT_FALSE(list_.IsExcluded(empty_filters));
|
| @@ -265,8 +265,8 @@ TEST_F(BluetoothBlacklistTest, IsExcluded_BluetoothScanFilter_ReturnsFalse) {
|
| }
|
| }
|
|
|
| -TEST_F(BluetoothBlacklistTest, IsExcluded_BluetoothScanFilter_ReturnsTrue) {
|
| - list_.Add(BluetoothUUID("eeee"), BluetoothBlacklist::Value::EXCLUDE);
|
| +TEST_F(BluetoothBlocklistTest, IsExcluded_BluetoothScanFilter_ReturnsTrue) {
|
| + list_.Add(BluetoothUUID("eeee"), BluetoothBlocklist::Value::EXCLUDE);
|
| {
|
| mojo::Array<blink::mojom::WebBluetoothScanFilterPtr> single_matching_filter(
|
| 1);
|
| @@ -320,10 +320,10 @@ TEST_F(BluetoothBlacklistTest, IsExcluded_BluetoothScanFilter_ReturnsTrue) {
|
| }
|
| }
|
|
|
| -TEST_F(BluetoothBlacklistTest, RemoveExcludedUUIDs_NonMatching) {
|
| - list_.Add(BluetoothUUID("eeee"), BluetoothBlacklist::Value::EXCLUDE);
|
| - list_.Add(BluetoothUUID("ee01"), BluetoothBlacklist::Value::EXCLUDE_READS);
|
| - list_.Add(BluetoothUUID("ee02"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
|
| +TEST_F(BluetoothBlocklistTest, RemoveExcludedUUIDs_NonMatching) {
|
| + list_.Add(BluetoothUUID("eeee"), BluetoothBlocklist::Value::EXCLUDE);
|
| + list_.Add(BluetoothUUID("ee01"), BluetoothBlocklist::Value::EXCLUDE_READS);
|
| + list_.Add(BluetoothUUID("ee02"), BluetoothBlocklist::Value::EXCLUDE_WRITES);
|
|
|
| // options.optional_services should be the same before and after
|
| // RemoveExcludedUUIDs().
|
| @@ -365,11 +365,11 @@ TEST_F(BluetoothBlacklistTest, RemoveExcludedUUIDs_NonMatching) {
|
| }
|
| }
|
|
|
| -TEST_F(BluetoothBlacklistTest, RemoveExcludedUuids_Matching) {
|
| - list_.Add(BluetoothUUID("eeee"), BluetoothBlacklist::Value::EXCLUDE);
|
| - list_.Add(BluetoothUUID("eee2"), BluetoothBlacklist::Value::EXCLUDE);
|
| - list_.Add(BluetoothUUID("eee3"), BluetoothBlacklist::Value::EXCLUDE);
|
| - list_.Add(BluetoothUUID("eee4"), BluetoothBlacklist::Value::EXCLUDE);
|
| +TEST_F(BluetoothBlocklistTest, RemoveExcludedUuids_Matching) {
|
| + list_.Add(BluetoothUUID("eeee"), BluetoothBlocklist::Value::EXCLUDE);
|
| + list_.Add(BluetoothUUID("eee2"), BluetoothBlocklist::Value::EXCLUDE);
|
| + list_.Add(BluetoothUUID("eee3"), BluetoothBlocklist::Value::EXCLUDE);
|
| + list_.Add(BluetoothUUID("eee4"), BluetoothBlocklist::Value::EXCLUDE);
|
| {
|
| // Single matching service in optional_services.
|
| blink::mojom::WebBluetoothRequestDeviceOptions options;
|
| @@ -410,12 +410,12 @@ TEST_F(BluetoothBlacklistTest, RemoveExcludedUuids_Matching) {
|
| }
|
| }
|
|
|
| -TEST_F(BluetoothBlacklistTest, VerifyDefaultBlacklistSize) {
|
| - // REMINDER: ADD new blacklist items to tests below for each exclusion type.
|
| +TEST_F(BluetoothBlocklistTest, VerifyDefaultBlocklistSize) {
|
| + // REMINDER: ADD new blocklist items to tests below for each exclusion type.
|
| EXPECT_EQ(13u, list_.size());
|
| }
|
|
|
| -TEST_F(BluetoothBlacklistTest, VerifyDefaultExcludeList) {
|
| +TEST_F(BluetoothBlocklistTest, VerifyDefaultExcludeList) {
|
| EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("1800")));
|
| EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("1801")));
|
| EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("1812")));
|
| @@ -438,7 +438,7 @@ TEST_F(BluetoothBlacklistTest, VerifyDefaultExcludeList) {
|
| list_.IsExcluded(BluetoothUUID("bad3ec61-3cc3-4954-9702-7977df514114")));
|
| }
|
|
|
| -TEST_F(BluetoothBlacklistTest, VerifyDefaultExcludeReadList) {
|
| +TEST_F(BluetoothBlocklistTest, VerifyDefaultExcludeReadList) {
|
| EXPECT_FALSE(list_.IsExcludedFromReads(BluetoothUUID("1800")));
|
| EXPECT_FALSE(list_.IsExcludedFromReads(BluetoothUUID("1801")));
|
| EXPECT_TRUE(list_.IsExcludedFromReads(BluetoothUUID("1812")));
|
| @@ -461,7 +461,7 @@ TEST_F(BluetoothBlacklistTest, VerifyDefaultExcludeReadList) {
|
| BluetoothUUID("bad3ec61-3cc3-4954-9702-7977df514114")));
|
| }
|
|
|
| -TEST_F(BluetoothBlacklistTest, VerifyDefaultExcludeWriteList) {
|
| +TEST_F(BluetoothBlocklistTest, VerifyDefaultExcludeWriteList) {
|
| EXPECT_FALSE(list_.IsExcludedFromWrites(BluetoothUUID("1800")));
|
| EXPECT_FALSE(list_.IsExcludedFromWrites(BluetoothUUID("1801")));
|
| EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("1812")));
|
|
|