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

Side by Side Diff: content/browser/bluetooth/bluetooth_blacklist_unittest.cc

Issue 2554253002: bluetooth: web: Rename Blacklist to Blocklist (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/bluetooth/bluetooth_blacklist.h"
6
7 #include "device/bluetooth/bluetooth_uuid.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 using device::BluetoothUUID;
11
12 namespace content {
13
14 namespace {
15
16 base::Optional<BluetoothUUID> Canonicalize(const std::string& str) {
17 return base::make_optional(device::BluetoothUUID(str));
18 }
19
20 } // namespace
21
22 class BluetoothBlacklistTest : public ::testing::Test {
23 public:
24 BluetoothBlacklistTest() : list_(BluetoothBlacklist::Get()) {
25 // Because BluetoothBlacklist is used via a singleton instance, the data
26 // must be reset for each test.
27 list_.ResetToDefaultValuesForTest();
28 }
29 BluetoothBlacklist& list_;
30 };
31
32 TEST_F(BluetoothBlacklistTest, NonExcludedUUID) {
33 BluetoothUUID non_excluded_uuid("00000000-0000-0000-0000-000000000000");
34 EXPECT_FALSE(list_.IsExcluded(non_excluded_uuid));
35 EXPECT_FALSE(list_.IsExcludedFromReads(non_excluded_uuid));
36 EXPECT_FALSE(list_.IsExcludedFromWrites(non_excluded_uuid));
37 }
38
39 TEST_F(BluetoothBlacklistTest, ExcludeUUID) {
40 BluetoothUUID excluded_uuid("eeee");
41 list_.Add(excluded_uuid, BluetoothBlacklist::Value::EXCLUDE);
42 EXPECT_TRUE(list_.IsExcluded(excluded_uuid));
43 EXPECT_TRUE(list_.IsExcludedFromReads(excluded_uuid));
44 EXPECT_TRUE(list_.IsExcludedFromWrites(excluded_uuid));
45 }
46
47 TEST_F(BluetoothBlacklistTest, ExcludeReadsUUID) {
48 BluetoothUUID exclude_reads_uuid("eeee");
49 list_.Add(exclude_reads_uuid, BluetoothBlacklist::Value::EXCLUDE_READS);
50 EXPECT_FALSE(list_.IsExcluded(exclude_reads_uuid));
51 EXPECT_TRUE(list_.IsExcludedFromReads(exclude_reads_uuid));
52 EXPECT_FALSE(list_.IsExcludedFromWrites(exclude_reads_uuid));
53 }
54
55 TEST_F(BluetoothBlacklistTest, ExcludeWritesUUID) {
56 BluetoothUUID exclude_writes_uuid("eeee");
57 list_.Add(exclude_writes_uuid, BluetoothBlacklist::Value::EXCLUDE_WRITES);
58 EXPECT_FALSE(list_.IsExcluded(exclude_writes_uuid));
59 EXPECT_FALSE(list_.IsExcludedFromReads(exclude_writes_uuid));
60 EXPECT_TRUE(list_.IsExcludedFromWrites(exclude_writes_uuid));
61 }
62
63 TEST_F(BluetoothBlacklistTest, InvalidUUID) {
64 BluetoothUUID empty_string_uuid("");
65 EXPECT_DEATH_IF_SUPPORTED(
66 list_.Add(empty_string_uuid, BluetoothBlacklist::Value::EXCLUDE), "");
67 EXPECT_DEATH_IF_SUPPORTED(list_.IsExcluded(empty_string_uuid), "");
68 EXPECT_DEATH_IF_SUPPORTED(list_.IsExcludedFromReads(empty_string_uuid), "");
69 EXPECT_DEATH_IF_SUPPORTED(list_.IsExcludedFromWrites(empty_string_uuid), "");
70
71 BluetoothUUID invalid_string_uuid("Not a valid UUID string.");
72 EXPECT_DEATH_IF_SUPPORTED(
73 list_.Add(invalid_string_uuid, BluetoothBlacklist::Value::EXCLUDE), "");
74 EXPECT_DEATH_IF_SUPPORTED(list_.IsExcluded(invalid_string_uuid), "");
75 EXPECT_DEATH_IF_SUPPORTED(list_.IsExcludedFromReads(invalid_string_uuid), "");
76 EXPECT_DEATH_IF_SUPPORTED(list_.IsExcludedFromWrites(invalid_string_uuid),
77 "");
78 }
79
80 // Abreviated UUIDs used to create, or test against, the blacklist work
81 // correctly compared to full UUIDs.
82 TEST_F(BluetoothBlacklistTest, AbreviatedUUIDs) {
83 list_.Add(BluetoothUUID("aaaa"), BluetoothBlacklist::Value::EXCLUDE);
84 EXPECT_TRUE(
85 list_.IsExcluded(BluetoothUUID("0000aaaa-0000-1000-8000-00805f9b34fb")));
86
87 list_.Add(BluetoothUUID("0000bbbb-0000-1000-8000-00805f9b34fb"),
88 BluetoothBlacklist::Value::EXCLUDE);
89 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("bbbb")));
90 }
91
92 // Tests permutations of previous values and then Add() with a new value,
93 // requiring result to be strictest result of the combination.
94 TEST_F(BluetoothBlacklistTest, Add_MergingExcludeValues) {
95 list_.Add(BluetoothUUID("ee01"), BluetoothBlacklist::Value::EXCLUDE);
96 list_.Add(BluetoothUUID("ee01"), BluetoothBlacklist::Value::EXCLUDE);
97 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("ee01")));
98
99 list_.Add(BluetoothUUID("ee02"), BluetoothBlacklist::Value::EXCLUDE);
100 list_.Add(BluetoothUUID("ee02"), BluetoothBlacklist::Value::EXCLUDE_READS);
101 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("ee02")));
102
103 list_.Add(BluetoothUUID("ee03"), BluetoothBlacklist::Value::EXCLUDE);
104 list_.Add(BluetoothUUID("ee03"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
105 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("ee03")));
106
107 list_.Add(BluetoothUUID("ee04"), BluetoothBlacklist::Value::EXCLUDE_READS);
108 list_.Add(BluetoothUUID("ee04"), BluetoothBlacklist::Value::EXCLUDE);
109 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("ee04")));
110
111 list_.Add(BluetoothUUID("ee05"), BluetoothBlacklist::Value::EXCLUDE_READS);
112 list_.Add(BluetoothUUID("ee05"), BluetoothBlacklist::Value::EXCLUDE_READS);
113 EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("ee05")));
114 EXPECT_TRUE(list_.IsExcludedFromReads(BluetoothUUID("ee05")));
115
116 list_.Add(BluetoothUUID("ee06"), BluetoothBlacklist::Value::EXCLUDE_READS);
117 list_.Add(BluetoothUUID("ee06"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
118 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("ee06")));
119
120 list_.Add(BluetoothUUID("ee07"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
121 list_.Add(BluetoothUUID("ee07"), BluetoothBlacklist::Value::EXCLUDE);
122 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("ee07")));
123
124 list_.Add(BluetoothUUID("ee08"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
125 list_.Add(BluetoothUUID("ee08"), BluetoothBlacklist::Value::EXCLUDE_READS);
126 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("ee08")));
127
128 list_.Add(BluetoothUUID("ee09"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
129 list_.Add(BluetoothUUID("ee09"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
130 EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("ee09")));
131 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("ee09")));
132 }
133
134 // Tests Add() with string that contains many UUID:exclusion value pairs,
135 // checking that the correct blacklist entries are created for them.
136 TEST_F(BluetoothBlacklistTest, Add_StringWithValidEntries) {
137 list_.Add(
138 "0001:e,0002:r,0003:w, " // Single items.
139 "0004:r,0004:r, " // Duplicate items.
140 "0005:r,0005:w, " // Items that merge.
141 "00000006:e, " // 8 char UUID.
142 "00000007-0000-1000-8000-00805f9b34fb:e");
143
144 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("0001")));
145
146 EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("0002")));
147 EXPECT_TRUE(list_.IsExcludedFromReads(BluetoothUUID("0002")));
148
149 EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("0003")));
150 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("0003")));
151
152 EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("0004")));
153 EXPECT_TRUE(list_.IsExcludedFromReads(BluetoothUUID("0004")));
154
155 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("0005")));
156 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("0006")));
157 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("0007")));
158 }
159
160 // Tests Add() with strings that contain no valid UUID:exclusion value.
161 TEST_F(BluetoothBlacklistTest, Add_StringsWithNoValidEntries) {
162 size_t previous_list_size = list_.size();
163 list_.Add("");
164 list_.Add("~!@#$%^&*()-_=+[]{}/*-");
165 list_.Add(":");
166 list_.Add(",");
167 list_.Add(",,");
168 list_.Add(",:,");
169 list_.Add("1234:");
170 list_.Add("1234:q");
171 list_.Add("1234:E");
172 list_.Add("1234:R");
173 list_.Add("1234:W");
174 list_.Add("1234:ee");
175 list_.Add("1234 :e");
176 list_.Add("1234: e");
177 list_.Add("1:e");
178 list_.Add("1:r");
179 list_.Add("1:w");
180 list_.Add("00001800-0000-1000-8000-00805f9b34fb:ee");
181 list_.Add("z0001800-0000-1000-8000-00805f9b34fb:e");
182 list_.Add("☯");
183 EXPECT_EQ(previous_list_size, list_.size());
184 }
185
186 // Tests Add() with strings that contain exactly one valid UUID:exclusion value
187 // pair, and optionally other issues in the string that are ignored.
188 TEST_F(BluetoothBlacklistTest, Add_StringsWithOneValidEntry) {
189 size_t previous_list_size = list_.size();
190 list_.Add("0001:e");
191 EXPECT_EQ(++previous_list_size, list_.size());
192 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("0001")));
193
194 list_.Add("00000002:e");
195 EXPECT_EQ(++previous_list_size, list_.size());
196 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("0002")));
197
198 list_.Add("00000003-0000-1000-8000-00805f9b34fb:e");
199 EXPECT_EQ(++previous_list_size, list_.size());
200 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("0003")));
201
202 list_.Add(" 0004:e ");
203 EXPECT_EQ(++previous_list_size, list_.size());
204 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("0004")));
205
206 list_.Add(", 0005:e ,");
207 EXPECT_EQ(++previous_list_size, list_.size());
208 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("0005")));
209
210 list_.Add(":, 0006:e ,,no");
211 EXPECT_EQ(++previous_list_size, list_.size());
212 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("0006")));
213
214 list_.Add("0007:, 0008:e");
215 EXPECT_EQ(++previous_list_size, list_.size());
216 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("0008")));
217
218 list_.Add("\r\n0009:e\n\r");
219 EXPECT_EQ(++previous_list_size, list_.size());
220 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("0009")));
221 }
222
223 TEST_F(BluetoothBlacklistTest, IsExcluded_BluetoothScanFilter_ReturnsFalse) {
224 list_.Add(BluetoothUUID("eeee"), BluetoothBlacklist::Value::EXCLUDE);
225 list_.Add(BluetoothUUID("ee01"), BluetoothBlacklist::Value::EXCLUDE_READS);
226 list_.Add(BluetoothUUID("ee02"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
227 {
228 mojo::Array<blink::mojom::WebBluetoothScanFilterPtr> empty_filters;
229 EXPECT_FALSE(list_.IsExcluded(empty_filters));
230 }
231 {
232 mojo::Array<blink::mojom::WebBluetoothScanFilterPtr> single_empty_filter(1);
233
234 single_empty_filter[0] = blink::mojom::WebBluetoothScanFilter::New();
235 single_empty_filter[0]->services =
236 mojo::Array<base::Optional<BluetoothUUID>>();
237
238 EXPECT_EQ(0u, single_empty_filter[0]->services.size());
239 EXPECT_FALSE(list_.IsExcluded(single_empty_filter));
240 }
241 {
242 mojo::Array<blink::mojom::WebBluetoothScanFilterPtr>
243 single_non_matching_filter(1);
244
245 single_non_matching_filter[0] = blink::mojom::WebBluetoothScanFilter::New();
246 single_non_matching_filter[0]->services.push_back(Canonicalize("0000"));
247
248 EXPECT_FALSE(list_.IsExcluded(single_non_matching_filter));
249 }
250 {
251 mojo::Array<blink::mojom::WebBluetoothScanFilterPtr>
252 multiple_non_matching_filters(2);
253
254 multiple_non_matching_filters[0] =
255 blink::mojom::WebBluetoothScanFilter::New();
256 multiple_non_matching_filters[0]->services.push_back(Canonicalize("0000"));
257 multiple_non_matching_filters[0]->services.push_back(Canonicalize("ee01"));
258
259 multiple_non_matching_filters[1] =
260 blink::mojom::WebBluetoothScanFilter::New();
261 multiple_non_matching_filters[1]->services.push_back(Canonicalize("ee02"));
262 multiple_non_matching_filters[1]->services.push_back(Canonicalize("0003"));
263
264 EXPECT_FALSE(list_.IsExcluded(multiple_non_matching_filters));
265 }
266 }
267
268 TEST_F(BluetoothBlacklistTest, IsExcluded_BluetoothScanFilter_ReturnsTrue) {
269 list_.Add(BluetoothUUID("eeee"), BluetoothBlacklist::Value::EXCLUDE);
270 {
271 mojo::Array<blink::mojom::WebBluetoothScanFilterPtr> single_matching_filter(
272 1);
273
274 single_matching_filter[0] = blink::mojom::WebBluetoothScanFilter::New();
275 single_matching_filter[0]->services.push_back(Canonicalize("eeee"));
276
277 EXPECT_TRUE(list_.IsExcluded(single_matching_filter));
278 }
279 {
280 mojo::Array<blink::mojom::WebBluetoothScanFilterPtr> first_matching_filter(
281 2);
282
283 first_matching_filter[0] = blink::mojom::WebBluetoothScanFilter::New();
284 first_matching_filter[0]->services.push_back(Canonicalize("eeee"));
285 first_matching_filter[0]->services.push_back(Canonicalize("0001"));
286
287 first_matching_filter[1] = blink::mojom::WebBluetoothScanFilter::New();
288 first_matching_filter[1]->services.push_back(Canonicalize("0002"));
289 first_matching_filter[1]->services.push_back(Canonicalize("0003"));
290
291 EXPECT_TRUE(list_.IsExcluded(first_matching_filter));
292 }
293 {
294 mojo::Array<blink::mojom::WebBluetoothScanFilterPtr> last_matching_filter(
295 2);
296
297 last_matching_filter[0] = blink::mojom::WebBluetoothScanFilter::New();
298 last_matching_filter[0]->services.push_back(Canonicalize("0001"));
299 last_matching_filter[0]->services.push_back(Canonicalize("0001"));
300
301 last_matching_filter[1] = blink::mojom::WebBluetoothScanFilter::New();
302 last_matching_filter[1]->services.push_back(Canonicalize("0002"));
303 last_matching_filter[1]->services.push_back(Canonicalize("eeee"));
304
305 EXPECT_TRUE(list_.IsExcluded(last_matching_filter));
306 }
307 {
308 mojo::Array<blink::mojom::WebBluetoothScanFilterPtr>
309 multiple_matching_filters(2);
310
311 multiple_matching_filters[0] = blink::mojom::WebBluetoothScanFilter::New();
312 multiple_matching_filters[0]->services.push_back(Canonicalize("eeee"));
313 multiple_matching_filters[0]->services.push_back(Canonicalize("eeee"));
314
315 multiple_matching_filters[1] = blink::mojom::WebBluetoothScanFilter::New();
316 multiple_matching_filters[1]->services.push_back(Canonicalize("eeee"));
317 multiple_matching_filters[1]->services.push_back(Canonicalize("eeee"));
318
319 EXPECT_TRUE(list_.IsExcluded(multiple_matching_filters));
320 }
321 }
322
323 TEST_F(BluetoothBlacklistTest, RemoveExcludedUUIDs_NonMatching) {
324 list_.Add(BluetoothUUID("eeee"), BluetoothBlacklist::Value::EXCLUDE);
325 list_.Add(BluetoothUUID("ee01"), BluetoothBlacklist::Value::EXCLUDE_READS);
326 list_.Add(BluetoothUUID("ee02"), BluetoothBlacklist::Value::EXCLUDE_WRITES);
327
328 // options.optional_services should be the same before and after
329 // RemoveExcludedUUIDs().
330 {
331 // Empty optional_services.
332 blink::mojom::WebBluetoothRequestDeviceOptions options;
333 options.optional_services = mojo::Array<base::Optional<BluetoothUUID>>();
334
335 mojo::Array<base::Optional<BluetoothUUID>> expected =
336 options.optional_services.Clone();
337
338 list_.RemoveExcludedUUIDs(&options);
339 EXPECT_TRUE(options.optional_services.Equals(expected));
340 }
341 {
342 // One non-matching service in optional_services.
343 blink::mojom::WebBluetoothRequestDeviceOptions options;
344 options.optional_services.push_back(Canonicalize("0000"));
345
346 mojo::Array<base::Optional<BluetoothUUID>> expected =
347 options.optional_services.Clone();
348
349 list_.RemoveExcludedUUIDs(&options);
350 EXPECT_TRUE(options.optional_services.Equals(expected));
351 }
352 {
353 // Multiple non-matching services in optional_services.
354 blink::mojom::WebBluetoothRequestDeviceOptions options;
355 options.optional_services.push_back(Canonicalize("0000"));
356 options.optional_services.push_back(Canonicalize("ee01"));
357 options.optional_services.push_back(Canonicalize("ee02"));
358 options.optional_services.push_back(Canonicalize("0003"));
359
360 mojo::Array<base::Optional<BluetoothUUID>> expected =
361 options.optional_services.Clone();
362
363 list_.RemoveExcludedUUIDs(&options);
364 EXPECT_TRUE(options.optional_services.Equals(expected));
365 }
366 }
367
368 TEST_F(BluetoothBlacklistTest, RemoveExcludedUuids_Matching) {
369 list_.Add(BluetoothUUID("eeee"), BluetoothBlacklist::Value::EXCLUDE);
370 list_.Add(BluetoothUUID("eee2"), BluetoothBlacklist::Value::EXCLUDE);
371 list_.Add(BluetoothUUID("eee3"), BluetoothBlacklist::Value::EXCLUDE);
372 list_.Add(BluetoothUUID("eee4"), BluetoothBlacklist::Value::EXCLUDE);
373 {
374 // Single matching service in optional_services.
375 blink::mojom::WebBluetoothRequestDeviceOptions options;
376 options.optional_services.push_back(Canonicalize("eeee"));
377
378 mojo::Array<base::Optional<BluetoothUUID>> expected;
379
380 list_.RemoveExcludedUUIDs(&options);
381
382 EXPECT_TRUE(options.optional_services.Equals(expected));
383 }
384 {
385 // Single matching of many services in optional_services.
386 blink::mojom::WebBluetoothRequestDeviceOptions options;
387 options.optional_services.push_back(Canonicalize("0000"));
388 options.optional_services.push_back(Canonicalize("eeee"));
389 options.optional_services.push_back(Canonicalize("0001"));
390
391 mojo::Array<base::Optional<BluetoothUUID>> expected;
392 expected.push_back(Canonicalize("0000"));
393 expected.push_back(Canonicalize("0001"));
394
395 list_.RemoveExcludedUUIDs(&options);
396 EXPECT_TRUE(options.optional_services.Equals(expected));
397 }
398 {
399 // All matching of many services in optional_services.
400 blink::mojom::WebBluetoothRequestDeviceOptions options;
401 options.optional_services.push_back(Canonicalize("eee2"));
402 options.optional_services.push_back(Canonicalize("eee4"));
403 options.optional_services.push_back(Canonicalize("eee3"));
404 options.optional_services.push_back(Canonicalize("eeee"));
405
406 mojo::Array<base::Optional<BluetoothUUID>> expected;
407
408 list_.RemoveExcludedUUIDs(&options);
409 EXPECT_TRUE(options.optional_services.Equals(expected));
410 }
411 }
412
413 TEST_F(BluetoothBlacklistTest, VerifyDefaultBlacklistSize) {
414 // REMINDER: ADD new blacklist items to tests below for each exclusion type.
415 EXPECT_EQ(13u, list_.size());
416 }
417
418 TEST_F(BluetoothBlacklistTest, VerifyDefaultExcludeList) {
419 EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("1800")));
420 EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("1801")));
421 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("1812")));
422 EXPECT_TRUE(
423 list_.IsExcluded(BluetoothUUID("00001530-1212-efde-1523-785feabcd123")));
424 EXPECT_TRUE(
425 list_.IsExcluded(BluetoothUUID("f000ffc0-0451-4000-b000-000000000000")));
426 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("00060000")));
427 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("fffd")));
428 EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("2a02")));
429 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("2a03")));
430 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("2a25")));
431 EXPECT_FALSE(
432 list_.IsExcluded(BluetoothUUID("bad1c9a2-9a5b-4015-8b60-1579bbbf2135")));
433 EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("2902")));
434 EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("2903")));
435 EXPECT_TRUE(
436 list_.IsExcluded(BluetoothUUID("bad2ddcf-60db-45cd-bef9-fd72b153cf7c")));
437 EXPECT_FALSE(
438 list_.IsExcluded(BluetoothUUID("bad3ec61-3cc3-4954-9702-7977df514114")));
439 }
440
441 TEST_F(BluetoothBlacklistTest, VerifyDefaultExcludeReadList) {
442 EXPECT_FALSE(list_.IsExcludedFromReads(BluetoothUUID("1800")));
443 EXPECT_FALSE(list_.IsExcludedFromReads(BluetoothUUID("1801")));
444 EXPECT_TRUE(list_.IsExcludedFromReads(BluetoothUUID("1812")));
445 EXPECT_TRUE(list_.IsExcludedFromReads(
446 BluetoothUUID("00001530-1212-efde-1523-785feabcd123")));
447 EXPECT_TRUE(list_.IsExcludedFromReads(
448 BluetoothUUID("f000ffc0-0451-4000-b000-000000000000")));
449 EXPECT_TRUE(list_.IsExcludedFromReads(BluetoothUUID("00060000")));
450 EXPECT_TRUE(list_.IsExcludedFromReads(BluetoothUUID("fffd")));
451 EXPECT_FALSE(list_.IsExcludedFromReads(BluetoothUUID("2a02")));
452 EXPECT_TRUE(list_.IsExcludedFromReads(BluetoothUUID("2a03")));
453 EXPECT_TRUE(list_.IsExcludedFromReads(BluetoothUUID("2a25")));
454 EXPECT_TRUE(list_.IsExcludedFromReads(
455 BluetoothUUID("bad1c9a2-9a5b-4015-8b60-1579bbbf2135")));
456 EXPECT_FALSE(list_.IsExcludedFromReads(BluetoothUUID("2902")));
457 EXPECT_FALSE(list_.IsExcludedFromReads(BluetoothUUID("2903")));
458 EXPECT_TRUE(list_.IsExcludedFromReads(
459 BluetoothUUID("bad2ddcf-60db-45cd-bef9-fd72b153cf7c")));
460 EXPECT_TRUE(list_.IsExcludedFromReads(
461 BluetoothUUID("bad3ec61-3cc3-4954-9702-7977df514114")));
462 }
463
464 TEST_F(BluetoothBlacklistTest, VerifyDefaultExcludeWriteList) {
465 EXPECT_FALSE(list_.IsExcludedFromWrites(BluetoothUUID("1800")));
466 EXPECT_FALSE(list_.IsExcludedFromWrites(BluetoothUUID("1801")));
467 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("1812")));
468 EXPECT_TRUE(list_.IsExcludedFromWrites(
469 BluetoothUUID("00001530-1212-efde-1523-785feabcd123")));
470 EXPECT_TRUE(list_.IsExcludedFromWrites(
471 BluetoothUUID("f000ffc0-0451-4000-b000-000000000000")));
472 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("00060000")));
473 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("fffd")));
474 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2a02")));
475 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2a03")));
476 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2a25")));
477 EXPECT_FALSE(list_.IsExcludedFromWrites(
478 BluetoothUUID("bad1c9a2-9a5b-4015-8b60-1579bbbf2135")));
479 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2902")));
480 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2903")));
481 EXPECT_TRUE(list_.IsExcludedFromWrites(
482 BluetoothUUID("bad2ddcf-60db-45cd-bef9-fd72b153cf7c")));
483 EXPECT_FALSE(list_.IsExcludedFromWrites(
484 BluetoothUUID("bad3ec61-3cc3-4954-9702-7977df514114")));
485 }
486
487 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/bluetooth/bluetooth_blacklist.cc ('k') | content/browser/bluetooth/bluetooth_blocklist.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698