| 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 "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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 options.optional_services.push_back(Canonicalize("eeee")); | 404 options.optional_services.push_back(Canonicalize("eeee")); |
| 405 | 405 |
| 406 mojo::Array<base::Optional<BluetoothUUID>> expected; | 406 mojo::Array<base::Optional<BluetoothUUID>> expected; |
| 407 | 407 |
| 408 list_.RemoveExcludedUUIDs(&options); | 408 list_.RemoveExcludedUUIDs(&options); |
| 409 EXPECT_TRUE(options.optional_services.Equals(expected)); | 409 EXPECT_TRUE(options.optional_services.Equals(expected)); |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 | 412 |
| 413 TEST_F(BluetoothBlacklistTest, VerifyDefaultBlacklistSize) { | 413 TEST_F(BluetoothBlacklistTest, VerifyDefaultBlacklistSize) { |
| 414 // When adding items to the blacklist the new values should be added in the | 414 // REMINDER: ADD new blacklist items to tests below for each exclusion type. |
| 415 // tests below for each exclusion type. | 415 EXPECT_EQ(13u, list_.size()); |
| 416 EXPECT_EQ(11u, list_.size()); | |
| 417 } | 416 } |
| 418 | 417 |
| 419 TEST_F(BluetoothBlacklistTest, VerifyDefaultExcludeList) { | 418 TEST_F(BluetoothBlacklistTest, VerifyDefaultExcludeList) { |
| 420 EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("1800"))); | 419 EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("1800"))); |
| 421 EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("1801"))); | 420 EXPECT_FALSE(list_.IsExcluded(BluetoothUUID("1801"))); |
| 422 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("1812"))); | 421 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("1812"))); |
| 423 EXPECT_TRUE( | 422 EXPECT_TRUE( |
| 424 list_.IsExcluded(BluetoothUUID("00001530-1212-efde-1523-785feabcd123"))); | 423 list_.IsExcluded(BluetoothUUID("00001530-1212-efde-1523-785feabcd123"))); |
| 425 EXPECT_TRUE( | 424 EXPECT_TRUE( |
| 426 list_.IsExcluded(BluetoothUUID("f000ffc0-0451-4000-b000-000000000000"))); | 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"))); |
| 427 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("2a03"))); | 429 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("2a03"))); |
| 428 EXPECT_TRUE(list_.IsExcluded(BluetoothUUID("2a25"))); | 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"))); |
| 429 EXPECT_TRUE( | 435 EXPECT_TRUE( |
| 430 list_.IsExcluded(BluetoothUUID("bad2ddcf-60db-45cd-bef9-fd72b153cf7c"))); | 436 list_.IsExcluded(BluetoothUUID("bad2ddcf-60db-45cd-bef9-fd72b153cf7c"))); |
| 437 EXPECT_FALSE( |
| 438 list_.IsExcluded(BluetoothUUID("bad3ec61-3cc3-4954-9702-7977df514114"))); |
| 431 } | 439 } |
| 432 | 440 |
| 433 TEST_F(BluetoothBlacklistTest, VerifyDefaultExcludeReadList) { | 441 TEST_F(BluetoothBlacklistTest, VerifyDefaultExcludeReadList) { |
| 434 EXPECT_FALSE(list_.IsExcludedFromReads(BluetoothUUID("1800"))); | 442 EXPECT_FALSE(list_.IsExcludedFromReads(BluetoothUUID("1800"))); |
| 435 EXPECT_FALSE(list_.IsExcludedFromReads(BluetoothUUID("1801"))); | 443 EXPECT_FALSE(list_.IsExcludedFromReads(BluetoothUUID("1801"))); |
| 436 EXPECT_TRUE(list_.IsExcludedFromReads(BluetoothUUID("1812"))); | 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"))); |
| 437 EXPECT_TRUE(list_.IsExcludedFromReads(BluetoothUUID("2a03"))); | 452 EXPECT_TRUE(list_.IsExcludedFromReads(BluetoothUUID("2a03"))); |
| 438 EXPECT_TRUE(list_.IsExcludedFromReads(BluetoothUUID("2a25"))); | 453 EXPECT_TRUE(list_.IsExcludedFromReads(BluetoothUUID("2a25"))); |
| 439 EXPECT_TRUE(list_.IsExcludedFromReads( | 454 EXPECT_TRUE(list_.IsExcludedFromReads( |
| 440 BluetoothUUID("bad1c9a2-9a5b-4015-8b60-1579bbbf2135"))); | 455 BluetoothUUID("bad1c9a2-9a5b-4015-8b60-1579bbbf2135"))); |
| 456 EXPECT_FALSE(list_.IsExcludedFromReads(BluetoothUUID("2902"))); |
| 457 EXPECT_FALSE(list_.IsExcludedFromReads(BluetoothUUID("2903"))); |
| 441 EXPECT_TRUE(list_.IsExcludedFromReads( | 458 EXPECT_TRUE(list_.IsExcludedFromReads( |
| 442 BluetoothUUID("bad2ddcf-60db-45cd-bef9-fd72b153cf7c"))); | 459 BluetoothUUID("bad2ddcf-60db-45cd-bef9-fd72b153cf7c"))); |
| 443 EXPECT_TRUE(list_.IsExcludedFromReads( | 460 EXPECT_TRUE(list_.IsExcludedFromReads( |
| 444 BluetoothUUID("bad3ec61-3cc3-4954-9702-7977df514114"))); | 461 BluetoothUUID("bad3ec61-3cc3-4954-9702-7977df514114"))); |
| 445 } | 462 } |
| 446 | 463 |
| 447 TEST_F(BluetoothBlacklistTest, VerifyDefaultExcludeWriteList) { | 464 TEST_F(BluetoothBlacklistTest, VerifyDefaultExcludeWriteList) { |
| 448 EXPECT_FALSE(list_.IsExcludedFromWrites(BluetoothUUID("1800"))); | 465 EXPECT_FALSE(list_.IsExcludedFromWrites(BluetoothUUID("1800"))); |
| 449 EXPECT_FALSE(list_.IsExcludedFromWrites(BluetoothUUID("1801"))); | 466 EXPECT_FALSE(list_.IsExcludedFromWrites(BluetoothUUID("1801"))); |
| 450 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("1812"))); | 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"))); |
| 451 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2a02"))); | 474 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2a02"))); |
| 452 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2a03"))); | 475 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2a03"))); |
| 453 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2a25"))); | 476 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2a25"))); |
| 477 EXPECT_FALSE(list_.IsExcludedFromWrites( |
| 478 BluetoothUUID("bad1c9a2-9a5b-4015-8b60-1579bbbf2135"))); |
| 454 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2902"))); | 479 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2902"))); |
| 455 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2903"))); | 480 EXPECT_TRUE(list_.IsExcludedFromWrites(BluetoothUUID("2903"))); |
| 456 EXPECT_TRUE(list_.IsExcludedFromWrites( | 481 EXPECT_TRUE(list_.IsExcludedFromWrites( |
| 457 BluetoothUUID("bad2ddcf-60db-45cd-bef9-fd72b153cf7c"))); | 482 BluetoothUUID("bad2ddcf-60db-45cd-bef9-fd72b153cf7c"))); |
| 483 EXPECT_FALSE(list_.IsExcludedFromWrites( |
| 484 BluetoothUUID("bad3ec61-3cc3-4954-9702-7977df514114"))); |
| 458 } | 485 } |
| 459 | 486 |
| 460 } // namespace content | 487 } // namespace content |
| OLD | NEW |