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(blacklist.IsExcluded(empty_string_uuid), ""); |
| 65 EXPECT_DEATH_IF_SUPPORTED(blacklist.IsExcludedFromReads(empty_string_uuid), |
| 66 ""); |
| 67 EXPECT_DEATH_IF_SUPPORTED(blacklist.IsExcludedFromWrites(empty_string_uuid), |
| 68 ""); |
| 69 |
| 70 BluetoothUUID invalid_string_uuid("Not a valid UUID string."); |
| 71 EXPECT_DEATH_IF_SUPPORTED(blacklist.IsExcluded(invalid_string_uuid), ""); |
| 72 EXPECT_DEATH_IF_SUPPORTED(blacklist.IsExcludedFromReads(invalid_string_uuid), |
| 73 ""); |
| 74 EXPECT_DEATH_IF_SUPPORTED(blacklist.IsExcludedFromWrites(invalid_string_uuid), |
| 75 ""); |
| 76 } |
| 77 |
61 // Abreviated UUIDs used to create, or test against, the blacklist work | 78 // Abreviated UUIDs used to create, or test against, the blacklist work |
62 // correctly compared to full UUIDs. | 79 // correctly compared to full UUIDs. |
63 TEST_F(BluetoothBlacklistTest, AbreviatedUUIDs) { | 80 TEST_F(BluetoothBlacklistTest, AbreviatedUUIDs) { |
64 BluetoothBlacklist& blacklist = BluetoothBlacklist::Get(); | 81 BluetoothBlacklist& blacklist = BluetoothBlacklist::Get(); |
65 | 82 |
66 blacklist.AddOrDie(BluetoothUUID("aaaa"), BluetoothBlacklist::Value::EXCLUDE); | 83 blacklist.AddOrDie(BluetoothUUID("aaaa"), BluetoothBlacklist::Value::EXCLUDE); |
67 EXPECT_TRUE(blacklist.IsExcluded( | 84 EXPECT_TRUE(blacklist.IsExcluded( |
68 BluetoothUUID("0000aaaa-0000-1000-8000-00805f9b34fb"))); | 85 BluetoothUUID("0000aaaa-0000-1000-8000-00805f9b34fb"))); |
69 | 86 |
70 blacklist.AddOrDie(BluetoothUUID("0000bbbb-0000-1000-8000-00805f9b34fb"), | 87 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"))); | 263 EXPECT_FALSE(blacklist.IsExcludedFromWrites(BluetoothUUID("1801"))); |
247 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("1812"))); | 264 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("1812"))); |
248 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2a02"))); | 265 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2a02"))); |
249 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2a03"))); | 266 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2a03"))); |
250 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2a25"))); | 267 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2a25"))); |
251 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2902"))); | 268 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2902"))); |
252 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2903"))); | 269 EXPECT_TRUE(blacklist.IsExcludedFromWrites(BluetoothUUID("2903"))); |
253 } | 270 } |
254 | 271 |
255 } // namespace content | 272 } // namespace content |
OLD | NEW |