Commit 7d335716 authored by ortuno's avatar ortuno Committed by Commit bot

bluetooth: Fix constants' names in BluetoothAllowedDevicesMap tests

BUG=493459

Review URL: https://codereview.chromium.org/1641783002

Cr-Commit-Position: refs/heads/master@{#371864}
parent 47a6da61
...@@ -12,15 +12,15 @@ ...@@ -12,15 +12,15 @@
namespace content { namespace content {
namespace { namespace {
const url::Origin test_origin1(GURL("https://www.example1.com")); const url::Origin kTestOrigin1(GURL("https://www.example1.com"));
const url::Origin test_origin2(GURL("https://www.example2.com")); const url::Origin kTestOrigin2(GURL("https://www.example2.com"));
const std::string device_address1 = "00:00:00"; const std::string kDeviceAddress1 = "00:00:00";
const std::string device_address2 = "11:11:11"; const std::string kDeviceAddress2 = "11:11:11";
const std::vector<content::BluetoothScanFilter> filters = const std::vector<content::BluetoothScanFilter> kEmptyFilters =
std::vector<BluetoothScanFilter>(); std::vector<BluetoothScanFilter>();
const std::vector<device::BluetoothUUID> optional_services = const std::vector<device::BluetoothUUID> kEmptyOptionalServices =
std::vector<device::BluetoothUUID>(); std::vector<device::BluetoothUUID>();
} // namespace } // namespace
...@@ -30,110 +30,110 @@ TEST_F(BluetoothAllowedDevicesMapTest, AddDeviceToMap) { ...@@ -30,110 +30,110 @@ TEST_F(BluetoothAllowedDevicesMapTest, AddDeviceToMap) {
BluetoothAllowedDevicesMap allowed_devices_map; BluetoothAllowedDevicesMap allowed_devices_map;
const std::string& device_id = allowed_devices_map.AddDevice( const std::string& device_id = allowed_devices_map.AddDevice(
test_origin1, device_address1, filters, optional_services); kTestOrigin1, kDeviceAddress1, kEmptyFilters, kEmptyOptionalServices);
// Test that we can retrieve the device address/id. // Test that we can retrieve the device address/id.
EXPECT_EQ(device_id, EXPECT_EQ(device_id,
allowed_devices_map.GetDeviceId(test_origin1, device_address1)); allowed_devices_map.GetDeviceId(kTestOrigin1, kDeviceAddress1));
EXPECT_EQ(device_address1, EXPECT_EQ(kDeviceAddress1,
allowed_devices_map.GetDeviceAddress(test_origin1, device_id)); allowed_devices_map.GetDeviceAddress(kTestOrigin1, device_id));
} }
TEST_F(BluetoothAllowedDevicesMapTest, AddDeviceToMapTwice) { TEST_F(BluetoothAllowedDevicesMapTest, AddDeviceToMapTwice) {
BluetoothAllowedDevicesMap allowed_devices_map; BluetoothAllowedDevicesMap allowed_devices_map;
const std::string& device_id1 = allowed_devices_map.AddDevice( const std::string& device_id1 = allowed_devices_map.AddDevice(
test_origin1, device_address1, filters, optional_services); kTestOrigin1, kDeviceAddress1, kEmptyFilters, kEmptyOptionalServices);
const std::string& device_id2 = allowed_devices_map.AddDevice( const std::string& device_id2 = allowed_devices_map.AddDevice(
test_origin1, device_address1, filters, optional_services); kTestOrigin1, kDeviceAddress1, kEmptyFilters, kEmptyOptionalServices);
EXPECT_EQ(device_id1, device_id2); EXPECT_EQ(device_id1, device_id2);
// Test that we can retrieve the device address/id. // Test that we can retrieve the device address/id.
EXPECT_EQ(device_id1, EXPECT_EQ(device_id1,
allowed_devices_map.GetDeviceId(test_origin1, device_address1)); allowed_devices_map.GetDeviceId(kTestOrigin1, kDeviceAddress1));
EXPECT_EQ(device_address1, EXPECT_EQ(kDeviceAddress1,
allowed_devices_map.GetDeviceAddress(test_origin1, device_id1)); allowed_devices_map.GetDeviceAddress(kTestOrigin1, device_id1));
} }
TEST_F(BluetoothAllowedDevicesMapTest, AddTwoDevicesFromSameOriginToMap) { TEST_F(BluetoothAllowedDevicesMapTest, AddTwoDevicesFromSameOriginToMap) {
BluetoothAllowedDevicesMap allowed_devices_map; BluetoothAllowedDevicesMap allowed_devices_map;
const std::string& device_id1 = allowed_devices_map.AddDevice( const std::string& device_id1 = allowed_devices_map.AddDevice(
test_origin1, device_address1, filters, optional_services); kTestOrigin1, kDeviceAddress1, kEmptyFilters, kEmptyOptionalServices);
const std::string& device_id2 = allowed_devices_map.AddDevice( const std::string& device_id2 = allowed_devices_map.AddDevice(
test_origin1, device_address2, filters, optional_services); kTestOrigin1, kDeviceAddress2, kEmptyFilters, kEmptyOptionalServices);
EXPECT_NE(device_id1, device_id2); EXPECT_NE(device_id1, device_id2);
// Test that we can retrieve the device address/id. // Test that we can retrieve the device address/id.
EXPECT_EQ(device_id1, EXPECT_EQ(device_id1,
allowed_devices_map.GetDeviceId(test_origin1, device_address1)); allowed_devices_map.GetDeviceId(kTestOrigin1, kDeviceAddress1));
EXPECT_EQ(device_id2, EXPECT_EQ(device_id2,
allowed_devices_map.GetDeviceId(test_origin1, device_address2)); allowed_devices_map.GetDeviceId(kTestOrigin1, kDeviceAddress2));
EXPECT_EQ(device_address1, EXPECT_EQ(kDeviceAddress1,
allowed_devices_map.GetDeviceAddress(test_origin1, device_id1)); allowed_devices_map.GetDeviceAddress(kTestOrigin1, device_id1));
EXPECT_EQ(device_address2, EXPECT_EQ(kDeviceAddress2,
allowed_devices_map.GetDeviceAddress(test_origin1, device_id2)); allowed_devices_map.GetDeviceAddress(kTestOrigin1, device_id2));
} }
TEST_F(BluetoothAllowedDevicesMapTest, AddTwoDevicesFromTwoOriginsToMap) { TEST_F(BluetoothAllowedDevicesMapTest, AddTwoDevicesFromTwoOriginsToMap) {
BluetoothAllowedDevicesMap allowed_devices_map; BluetoothAllowedDevicesMap allowed_devices_map;
const std::string& device_id1 = allowed_devices_map.AddDevice( const std::string& device_id1 = allowed_devices_map.AddDevice(
test_origin1, device_address1, filters, optional_services); kTestOrigin1, kDeviceAddress1, kEmptyFilters, kEmptyOptionalServices);
const std::string& device_id2 = allowed_devices_map.AddDevice( const std::string& device_id2 = allowed_devices_map.AddDevice(
test_origin2, device_address2, filters, optional_services); kTestOrigin2, kDeviceAddress2, kEmptyFilters, kEmptyOptionalServices);
EXPECT_NE(device_id1, device_id2); EXPECT_NE(device_id1, device_id2);
// Test that the wrong origin doesn't have access to the device. // Test that the wrong origin doesn't have access to the device.
EXPECT_EQ(base::EmptyString(), EXPECT_EQ(base::EmptyString(),
allowed_devices_map.GetDeviceId(test_origin1, device_address2)); allowed_devices_map.GetDeviceId(kTestOrigin1, kDeviceAddress2));
EXPECT_EQ(base::EmptyString(), EXPECT_EQ(base::EmptyString(),
allowed_devices_map.GetDeviceId(test_origin2, device_address1)); allowed_devices_map.GetDeviceId(kTestOrigin2, kDeviceAddress1));
EXPECT_EQ(base::EmptyString(), EXPECT_EQ(base::EmptyString(),
allowed_devices_map.GetDeviceAddress(test_origin1, device_id2)); allowed_devices_map.GetDeviceAddress(kTestOrigin1, device_id2));
EXPECT_EQ(base::EmptyString(), EXPECT_EQ(base::EmptyString(),
allowed_devices_map.GetDeviceAddress(test_origin2, device_id1)); allowed_devices_map.GetDeviceAddress(kTestOrigin2, device_id1));
// Test that we can retrieve the device address/id. // Test that we can retrieve the device address/id.
EXPECT_EQ(device_id1, EXPECT_EQ(device_id1,
allowed_devices_map.GetDeviceId(test_origin1, device_address1)); allowed_devices_map.GetDeviceId(kTestOrigin1, kDeviceAddress1));
EXPECT_EQ(device_id2, EXPECT_EQ(device_id2,
allowed_devices_map.GetDeviceId(test_origin2, device_address2)); allowed_devices_map.GetDeviceId(kTestOrigin2, kDeviceAddress2));
EXPECT_EQ(device_address1, EXPECT_EQ(kDeviceAddress1,
allowed_devices_map.GetDeviceAddress(test_origin1, device_id1)); allowed_devices_map.GetDeviceAddress(kTestOrigin1, device_id1));
EXPECT_EQ(device_address2, EXPECT_EQ(kDeviceAddress2,
allowed_devices_map.GetDeviceAddress(test_origin2, device_id2)); allowed_devices_map.GetDeviceAddress(kTestOrigin2, device_id2));
} }
TEST_F(BluetoothAllowedDevicesMapTest, AddDeviceFromTwoOriginsToMap) { TEST_F(BluetoothAllowedDevicesMapTest, AddDeviceFromTwoOriginsToMap) {
BluetoothAllowedDevicesMap allowed_devices_map; BluetoothAllowedDevicesMap allowed_devices_map;
const std::string& device_id1 = allowed_devices_map.AddDevice( const std::string& device_id1 = allowed_devices_map.AddDevice(
test_origin1, device_address1, filters, optional_services); kTestOrigin1, kDeviceAddress1, kEmptyFilters, kEmptyOptionalServices);
const std::string& device_id2 = allowed_devices_map.AddDevice( const std::string& device_id2 = allowed_devices_map.AddDevice(
test_origin2, device_address1, filters, optional_services); kTestOrigin2, kDeviceAddress1, kEmptyFilters, kEmptyOptionalServices);
EXPECT_NE(device_id1, device_id2); EXPECT_NE(device_id1, device_id2);
// Test that the wrong origin doesn't have access to the device. // Test that the wrong origin doesn't have access to the device.
EXPECT_EQ(base::EmptyString(), EXPECT_EQ(base::EmptyString(),
allowed_devices_map.GetDeviceAddress(test_origin1, device_id2)); allowed_devices_map.GetDeviceAddress(kTestOrigin1, device_id2));
EXPECT_EQ(base::EmptyString(), EXPECT_EQ(base::EmptyString(),
allowed_devices_map.GetDeviceAddress(test_origin2, device_id1)); allowed_devices_map.GetDeviceAddress(kTestOrigin2, device_id1));
} }
TEST_F(BluetoothAllowedDevicesMapTest, AddRemoveAddDeviceToMap) { TEST_F(BluetoothAllowedDevicesMapTest, AddRemoveAddDeviceToMap) {
BluetoothAllowedDevicesMap allowed_devices_map; BluetoothAllowedDevicesMap allowed_devices_map;
const std::string device_id_first_time = allowed_devices_map.AddDevice( const std::string device_id_first_time = allowed_devices_map.AddDevice(
test_origin1, device_address1, filters, optional_services); kTestOrigin1, kDeviceAddress1, kEmptyFilters, kEmptyOptionalServices);
allowed_devices_map.RemoveDevice(test_origin1, device_address1); allowed_devices_map.RemoveDevice(kTestOrigin1, kDeviceAddress1);
const std::string device_id_second_time = allowed_devices_map.AddDevice( const std::string device_id_second_time = allowed_devices_map.AddDevice(
test_origin1, device_address1, filters, optional_services); kTestOrigin1, kDeviceAddress1, kEmptyFilters, kEmptyOptionalServices);
EXPECT_NE(device_id_first_time, device_id_second_time); EXPECT_NE(device_id_first_time, device_id_second_time);
} }
...@@ -142,21 +142,21 @@ TEST_F(BluetoothAllowedDevicesMapTest, RemoveDeviceFromMap) { ...@@ -142,21 +142,21 @@ TEST_F(BluetoothAllowedDevicesMapTest, RemoveDeviceFromMap) {
BluetoothAllowedDevicesMap allowed_devices_map; BluetoothAllowedDevicesMap allowed_devices_map;
const std::string& device_id = allowed_devices_map.AddDevice( const std::string& device_id = allowed_devices_map.AddDevice(
test_origin1, device_address1, filters, optional_services); kTestOrigin1, kDeviceAddress1, kEmptyFilters, kEmptyOptionalServices);
allowed_devices_map.RemoveDevice(test_origin1, device_address1); allowed_devices_map.RemoveDevice(kTestOrigin1, kDeviceAddress1);
EXPECT_EQ(base::EmptyString(), EXPECT_EQ(base::EmptyString(),
allowed_devices_map.GetDeviceId(test_origin1, device_id)); allowed_devices_map.GetDeviceId(kTestOrigin1, device_id));
EXPECT_EQ(base::EmptyString(), allowed_devices_map.GetDeviceAddress( EXPECT_EQ(base::EmptyString(), allowed_devices_map.GetDeviceAddress(
test_origin1, device_address1)); kTestOrigin1, kDeviceAddress1));
} }
TEST_F(BluetoothAllowedDevicesMapTest, CorrectIdFormat) { TEST_F(BluetoothAllowedDevicesMapTest, CorrectIdFormat) {
BluetoothAllowedDevicesMap allowed_devices_map; BluetoothAllowedDevicesMap allowed_devices_map;
const std::string& device_id = allowed_devices_map.AddDevice( const std::string& device_id = allowed_devices_map.AddDevice(
test_origin1, device_address1, filters, optional_services); kTestOrigin1, kDeviceAddress1, kEmptyFilters, kEmptyOptionalServices);
EXPECT_TRUE(device_id.size() == 24) EXPECT_TRUE(device_id.size() == 24)
<< "Expected Lenghth of a 128bit string encoded to Base64."; << "Expected Lenghth of a 128bit string encoded to Base64.";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment