forked from sanyaade-mobiledev/chromium.src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bluetooth] Standardize Bluetooth device address format to XX:XX:XX:X…
…X:XX:XX. BUG=371014 TEST=device_unittests R=keybuk@chromium.org Review URL: https://codereview.chromium.org/288903003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271179 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
isherman@chromium.org
committed
May 17, 2014
1 parent
1cbaeba
commit db00ff8
Showing
15 changed files
with
117 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "device/bluetooth/bluetooth_device.h" | ||
|
||
#include "base/macros.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace device { | ||
|
||
TEST(BluetoothDeviceTest, CanonicalizeAddressFormat_AcceptsAllValidFormats) { | ||
// There are three valid separators (':', '-', and none). | ||
// Case shouldn't matter. | ||
const char* const kValidFormats[] = { | ||
"1A:2B:3C:4D:5E:6F", | ||
"1a:2B:3c:4D:5e:6F", | ||
"1a:2b:3c:4d:5e:6f", | ||
"1A-2B-3C-4D-5E-6F", | ||
"1a-2B-3c-4D-5e-6F", | ||
"1a-2b-3c-4d-5e-6f", | ||
"1A2B3C4D5E6F", | ||
"1a2B3c4D5e6F", | ||
"1a2b3c4d5e6f", | ||
}; | ||
|
||
for (size_t i = 0; i < arraysize(kValidFormats); ++i) { | ||
SCOPED_TRACE(std::string("Input format: '") + kValidFormats[i] + "'"); | ||
EXPECT_EQ("1A:2B:3C:4D:5E:6F", | ||
BluetoothDevice::CanonicalizeAddress(kValidFormats[i])); | ||
} | ||
} | ||
|
||
TEST(BluetoothDeviceTest, CanonicalizeAddressFormat_RejectsInvalidFormats) { | ||
const char* const kValidFormats[] = { | ||
// Empty string. | ||
"", | ||
// Too short. | ||
"1A:2B:3C:4D:5E", | ||
// Too long. | ||
"1A:2B:3C:4D:5E:6F:70", | ||
// Missing a separator. | ||
"1A:2B:3C:4D:5E6F", | ||
// Mixed separators. | ||
"1A:2B-3C:4D-5E:6F", | ||
// Invalid characters. | ||
"1A:2B-3C:4D-5E:6X", | ||
// Separators in the wrong place. | ||
"1:A2:B3:C4:D5:E6F", | ||
}; | ||
|
||
for (size_t i = 0; i < arraysize(kValidFormats); ++i) { | ||
SCOPED_TRACE(std::string("Input format: '") + kValidFormats[i] + "'"); | ||
EXPECT_EQ(std::string(), | ||
BluetoothDevice::CanonicalizeAddress(kValidFormats[i])); | ||
} | ||
} | ||
|
||
} // namespace device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters