| 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_blocklist.h" | 5 #include "content/browser/bluetooth/bluetooth_blocklist.h" |
| 6 | 6 |
| 7 #include "device/bluetooth/bluetooth_uuid.h" | 7 #include "device/bluetooth/bluetooth_uuid.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 using device::BluetoothUUID; | 10 using device::BluetoothUUID; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 multiple_non_matching_filters[1]->services->push_back( | 269 multiple_non_matching_filters[1]->services->push_back( |
| 270 BluetoothUUID("0003")); | 270 BluetoothUUID("0003")); |
| 271 | 271 |
| 272 EXPECT_FALSE(list_.IsExcluded(multiple_non_matching_filters)); | 272 EXPECT_FALSE(list_.IsExcluded(multiple_non_matching_filters)); |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 | 275 |
| 276 TEST_F(BluetoothBlocklistTest, IsExcluded_BluetoothScanFilter_ReturnsTrue) { | 276 TEST_F(BluetoothBlocklistTest, IsExcluded_BluetoothScanFilter_ReturnsTrue) { |
| 277 list_.Add(BluetoothUUID("eeee"), BluetoothBlocklist::Value::EXCLUDE); | 277 list_.Add(BluetoothUUID("eeee"), BluetoothBlocklist::Value::EXCLUDE); |
| 278 { | 278 { |
| 279 mojo::Array<blink::mojom::WebBluetoothScanFilterPtr> single_matching_filter( | 279 std::vector<blink::mojom::WebBluetoothScanFilterPtr> single_matching_filter( |
| 280 1); | 280 1); |
| 281 | 281 |
| 282 single_matching_filter[0] = blink::mojom::WebBluetoothScanFilter::New(); | 282 single_matching_filter[0] = blink::mojom::WebBluetoothScanFilter::New(); |
| 283 single_matching_filter[0]->services.emplace(); | 283 single_matching_filter[0]->services.emplace(); |
| 284 single_matching_filter[0]->services->push_back(BluetoothUUID("eeee")); | 284 single_matching_filter[0]->services->push_back(BluetoothUUID("eeee")); |
| 285 | 285 |
| 286 EXPECT_TRUE(list_.IsExcluded(single_matching_filter)); | 286 EXPECT_TRUE(list_.IsExcluded(single_matching_filter)); |
| 287 } | 287 } |
| 288 { | 288 { |
| 289 mojo::Array<blink::mojom::WebBluetoothScanFilterPtr> first_matching_filter( | 289 std::vector<blink::mojom::WebBluetoothScanFilterPtr> first_matching_filter( |
| 290 2); | 290 2); |
| 291 | 291 |
| 292 first_matching_filter[0] = blink::mojom::WebBluetoothScanFilter::New(); | 292 first_matching_filter[0] = blink::mojom::WebBluetoothScanFilter::New(); |
| 293 first_matching_filter[0]->services.emplace(); | 293 first_matching_filter[0]->services.emplace(); |
| 294 first_matching_filter[0]->services->push_back(BluetoothUUID("eeee")); | 294 first_matching_filter[0]->services->push_back(BluetoothUUID("eeee")); |
| 295 first_matching_filter[0]->services->push_back(BluetoothUUID("0001")); | 295 first_matching_filter[0]->services->push_back(BluetoothUUID("0001")); |
| 296 | 296 |
| 297 first_matching_filter[1] = blink::mojom::WebBluetoothScanFilter::New(); | 297 first_matching_filter[1] = blink::mojom::WebBluetoothScanFilter::New(); |
| 298 first_matching_filter[1]->services.emplace(); | 298 first_matching_filter[1]->services.emplace(); |
| 299 first_matching_filter[1]->services->push_back(BluetoothUUID("0002")); | 299 first_matching_filter[1]->services->push_back(BluetoothUUID("0002")); |
| 300 first_matching_filter[1]->services->push_back(BluetoothUUID("0003")); | 300 first_matching_filter[1]->services->push_back(BluetoothUUID("0003")); |
| 301 | 301 |
| 302 EXPECT_TRUE(list_.IsExcluded(first_matching_filter)); | 302 EXPECT_TRUE(list_.IsExcluded(first_matching_filter)); |
| 303 } | 303 } |
| 304 { | 304 { |
| 305 mojo::Array<blink::mojom::WebBluetoothScanFilterPtr> last_matching_filter( | 305 std::vector<blink::mojom::WebBluetoothScanFilterPtr> last_matching_filter( |
| 306 2); | 306 2); |
| 307 | 307 |
| 308 last_matching_filter[0] = blink::mojom::WebBluetoothScanFilter::New(); | 308 last_matching_filter[0] = blink::mojom::WebBluetoothScanFilter::New(); |
| 309 last_matching_filter[0]->services.emplace(); | 309 last_matching_filter[0]->services.emplace(); |
| 310 last_matching_filter[0]->services->push_back(BluetoothUUID("0001")); | 310 last_matching_filter[0]->services->push_back(BluetoothUUID("0001")); |
| 311 last_matching_filter[0]->services->push_back(BluetoothUUID("0001")); | 311 last_matching_filter[0]->services->push_back(BluetoothUUID("0001")); |
| 312 | 312 |
| 313 last_matching_filter[1] = blink::mojom::WebBluetoothScanFilter::New(); | 313 last_matching_filter[1] = blink::mojom::WebBluetoothScanFilter::New(); |
| 314 last_matching_filter[1]->services.emplace(); | 314 last_matching_filter[1]->services.emplace(); |
| 315 last_matching_filter[1]->services->push_back(BluetoothUUID("0002")); | 315 last_matching_filter[1]->services->push_back(BluetoothUUID("0002")); |
| 316 last_matching_filter[1]->services->push_back(BluetoothUUID("eeee")); | 316 last_matching_filter[1]->services->push_back(BluetoothUUID("eeee")); |
| 317 | 317 |
| 318 EXPECT_TRUE(list_.IsExcluded(last_matching_filter)); | 318 EXPECT_TRUE(list_.IsExcluded(last_matching_filter)); |
| 319 } | 319 } |
| 320 { | 320 { |
| 321 mojo::Array<blink::mojom::WebBluetoothScanFilterPtr> | 321 std::vector<blink::mojom::WebBluetoothScanFilterPtr> |
| 322 multiple_matching_filters(2); | 322 multiple_matching_filters(2); |
| 323 | 323 |
| 324 multiple_matching_filters[0] = blink::mojom::WebBluetoothScanFilter::New(); | 324 multiple_matching_filters[0] = blink::mojom::WebBluetoothScanFilter::New(); |
| 325 multiple_matching_filters[0]->services.emplace(); | 325 multiple_matching_filters[0]->services.emplace(); |
| 326 multiple_matching_filters[0]->services->push_back(BluetoothUUID("eeee")); | 326 multiple_matching_filters[0]->services->push_back(BluetoothUUID("eeee")); |
| 327 multiple_matching_filters[0]->services->push_back(BluetoothUUID("eeee")); | 327 multiple_matching_filters[0]->services->push_back(BluetoothUUID("eeee")); |
| 328 | 328 |
| 329 multiple_matching_filters[1] = blink::mojom::WebBluetoothScanFilter::New(); | 329 multiple_matching_filters[1] = blink::mojom::WebBluetoothScanFilter::New(); |
| 330 multiple_matching_filters[1]->services.emplace(); | 330 multiple_matching_filters[1]->services.emplace(); |
| 331 multiple_matching_filters[1]->services->push_back(BluetoothUUID("eeee")); | 331 multiple_matching_filters[1]->services->push_back(BluetoothUUID("eeee")); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 BluetoothUUID("bad1c9a2-9a5b-4015-8b60-1579bbbf2135"))); | 489 BluetoothUUID("bad1c9a2-9a5b-4015-8b60-1579bbbf2135"))); |
| 490 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2902"))); | 490 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2902"))); |
| 491 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2903"))); | 491 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2903"))); |
| 492 EXPECT_TRUE(list_.IsExcludedFromWrites( | 492 EXPECT_TRUE(list_.IsExcludedFromWrites( |
| 493 BluetoothUUID("bad2ddcf-60db-45cd-bef9-fd72b153cf7c"))); | 493 BluetoothUUID("bad2ddcf-60db-45cd-bef9-fd72b153cf7c"))); |
| 494 EXPECT_FALSE(list_.IsExcludedFromWrites( | 494 EXPECT_FALSE(list_.IsExcludedFromWrites( |
| 495 BluetoothUUID("bad3ec61-3cc3-4954-9702-7977df514114"))); | 495 BluetoothUUID("bad3ec61-3cc3-4954-9702-7977df514114"))); |
| 496 } | 496 } |
| 497 | 497 |
| 498 } // namespace content | 498 } // namespace content |
| OLD | NEW |