| OLD | NEW |
| 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 "content/browser/bluetooth/bluetooth_blacklist.h" | 5 #include "content/browser/bluetooth/bluetooth_blacklist.h" |
| 6 | 6 |
| 7 #include "content/common/bluetooth/bluetooth_scan_filter.h" | 7 #include "content/common/bluetooth/bluetooth_scan_filter.h" |
| 8 #include "device/bluetooth/bluetooth_uuid.h" | 8 #include "device/bluetooth/bluetooth_uuid.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 TEST_F(BluetoothBlacklistTest, ExcludeWritesUUID) { | 51 TEST_F(BluetoothBlacklistTest, ExcludeWritesUUID) { |
| 52 BluetoothBlacklist& blacklist = BluetoothBlacklist::Get(); | 52 BluetoothBlacklist& blacklist = BluetoothBlacklist::Get(); |
| 53 BluetoothUUID exclude_writes_uuid("eeee"); | 53 BluetoothUUID exclude_writes_uuid("eeee"); |
| 54 blacklist.AddOrDie(exclude_writes_uuid, | 54 blacklist.AddOrDie(exclude_writes_uuid, |
| 55 BluetoothBlacklist::Value::EXCLUDE_WRITES); | 55 BluetoothBlacklist::Value::EXCLUDE_WRITES); |
| 56 EXPECT_FALSE(blacklist.IsExcluded(exclude_writes_uuid)); | 56 EXPECT_FALSE(blacklist.IsExcluded(exclude_writes_uuid)); |
| 57 EXPECT_FALSE(blacklist.IsExcludedFromReads(exclude_writes_uuid)); | 57 EXPECT_FALSE(blacklist.IsExcludedFromReads(exclude_writes_uuid)); |
| 58 EXPECT_TRUE(blacklist.IsExcludedFromWrites(exclude_writes_uuid)); | 58 EXPECT_TRUE(blacklist.IsExcludedFromWrites(exclude_writes_uuid)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 TEST_F(BluetoothBlacklistTest, InvalidUUID) { |
| 62 BluetoothBlacklist& blacklist = BluetoothBlacklist::Get(); |
| 63 BluetoothUUID empty_string_uuid(""); |
| 64 EXPECT_DEATH_IF_SUPPORTED( |
| 65 blacklist.AddOrDie(empty_string_uuid, BluetoothBlacklist::Value::EXCLUDE), |
| 66 ""); |
| 67 EXPECT_DEATH_IF_SUPPORTED(blacklist.IsExcluded(empty_string_uuid), ""); |
| 68 EXPECT_DEATH_IF_SUPPORTED(blacklist.IsExcludedFromReads(empty_string_uuid), |
| 69 ""); |
| 70 EXPECT_DEATH_IF_SUPPORTED(blacklist.IsExcludedFromWrites(empty_string_uuid), |
| 71 ""); |
| 72 |
| 73 BluetoothUUID invalid_string_uuid("Not a valid UUID string."); |
| 74 EXPECT_DEATH_IF_SUPPORTED( |
| 75 blacklist.AddOrDie(invalid_string_uuid, |
| 76 BluetoothBlacklist::Value::EXCLUDE), |
| 77 ""); |
| 78 EXPECT_DEATH_IF_SUPPORTED(blacklist.IsExcluded(invalid_string_uuid), ""); |
| 79 EXPECT_DEATH_IF_SUPPORTED(blacklist.IsExcludedFromReads(invalid_string_uuid), |
| 80 ""); |
| 81 EXPECT_DEATH_IF_SUPPORTED(blacklist.IsExcludedFromWrites(invalid_string_uuid), |
| 82 ""); |
| 83 } |
| 84 |
| 61 // Abreviated UUIDs used to create, or test against, the blacklist work | 85 // Abreviated UUIDs used to create, or test against, the blacklist work |
| 62 // correctly compared to full UUIDs. | 86 // correctly compared to full UUIDs. |
| 63 TEST_F(BluetoothBlacklistTest, AbreviatedUUIDs) { | 87 TEST_F(BluetoothBlacklistTest, AbreviatedUUIDs) { |
| 64 BluetoothBlacklist& blacklist = BluetoothBlacklist::Get(); | 88 BluetoothBlacklist& blacklist = BluetoothBlacklist::Get(); |
| 65 | 89 |
| 66 blacklist.AddOrDie(BluetoothUUID("aaaa"), BluetoothBlacklist::Value::EXCLUDE); | 90 blacklist.AddOrDie(BluetoothUUID("aaaa"), BluetoothBlacklist::Value::EXCLUDE); |
| 67 EXPECT_TRUE(blacklist.IsExcluded( | 91 EXPECT_TRUE(blacklist.IsExcluded( |
| 68 BluetoothUUID("0000aaaa-0000-1000-8000-00805f9b34fb"))); | 92 BluetoothUUID("0000aaaa-0000-1000-8000-00805f9b34fb"))); |
| 69 | 93 |
| 70 blacklist.AddOrDie(BluetoothUUID("0000bbbb-0000-1000-8000-00805f9b34fb"), | 94 blacklist.AddOrDie(BluetoothUUID("0000bbbb-0000-1000-8000-00805f9b34fb"), |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 EXPECT_FALSE(blacklist.IsExcludedFromWrites(BluetoothUUID("1801"))); | 270 EXPECT_FALSE(blacklist.IsExcludedFromWrites(BluetoothUUID("1801"))); |
| 247 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("1812"))); | 271 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("1812"))); |
| 248 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2a02"))); | 272 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2a02"))); |
| 249 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2a03"))); | 273 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2a03"))); |
| 250 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2a25"))); | 274 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2a25"))); |
| 251 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2902"))); | 275 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2902"))); |
| 252 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2903"))); | 276 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2903"))); |
| 253 } | 277 } |
| 254 | 278 |
| 255 } // namespace content | 279 } // namespace content |
| OLD | NEW |