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

Side by Side Diff: chrome/browser/chromeos/bluetooth/bluetooth_utils_unittest.cc

Issue 11075006: Moved bluetooth adapter files to device/bluetooth/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: renamed 'bluetooth' target to 'device_bluetooth'. Created 8 years, 2 months 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 <bluetooth/bluetooth.h>
6
7 #include "chrome/browser/chromeos/bluetooth/bluetooth_utils.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace chromeos {
11
12 TEST(BluetoothUtilsTest, str2ba) {
13 bdaddr_t bluetooth_address;
14
15 EXPECT_TRUE(bluetooth_utils::str2ba("01:02:03:0A:10:A0", &bluetooth_address));
16 EXPECT_EQ(1, bluetooth_address.b[5]);
17 EXPECT_EQ(2, bluetooth_address.b[4]);
18 EXPECT_EQ(3, bluetooth_address.b[3]);
19 EXPECT_EQ(10, bluetooth_address.b[2]);
20 EXPECT_EQ(16, bluetooth_address.b[1]);
21 EXPECT_EQ(160, bluetooth_address.b[0]);
22
23 EXPECT_FALSE(bluetooth_utils::str2ba("obviously wrong", &bluetooth_address));
24 EXPECT_FALSE(bluetooth_utils::str2ba("00:00", &bluetooth_address));
25 EXPECT_FALSE(bluetooth_utils::str2ba("00:00:00:00:00:00:00",
26 &bluetooth_address));
27 EXPECT_FALSE(bluetooth_utils::str2ba("01:02:03:0A:10:A0", NULL));
28 }
29
30 TEST(BluetoothUtilsTest, CanonicalUuid) {
31 // Does nothing for an already canonical UUID
32 EXPECT_EQ("00001101-0000-1000-8000-00805f9b34fb",
33 bluetooth_utils::CanonicalUuid("00001101-0000-1000-8000-00805f9b34fb"));
34
35 // Rejects misformatted
36 EXPECT_EQ("", bluetooth_utils::CanonicalUuid("1101a"));
37 EXPECT_EQ("", bluetooth_utils::CanonicalUuid("Z101"));
38 EXPECT_EQ("", bluetooth_utils::CanonicalUuid("0000-1101"));
39 EXPECT_EQ("", bluetooth_utils::CanonicalUuid("0000Z101"));
40 EXPECT_EQ("",
41 bluetooth_utils::CanonicalUuid("0001101-0000-1000-8000-00805f9b34fb"));
42 EXPECT_EQ("",
43 bluetooth_utils::CanonicalUuid("Z0001101-0000-1000-8000-00805f9b34fb"));
44 EXPECT_EQ("",
45 bluetooth_utils::CanonicalUuid("00001101 0000-1000-8000-00805f9b34fb"));
46 EXPECT_EQ("",
47 bluetooth_utils::CanonicalUuid("00001101-0000:1000-8000-00805f9b34fb"));
48 EXPECT_EQ("",
49 bluetooth_utils::CanonicalUuid("00001101-0000-1000;8000-00805f9b34fb"));
50 EXPECT_EQ("",
51 bluetooth_utils::CanonicalUuid("00001101-0000-1000-8000000805f9b34fb"));
52
53 // Lower case
54 EXPECT_EQ("00001101-0000-1000-8000-00805f9b34fb",
55 bluetooth_utils::CanonicalUuid("00001101-0000-1000-8000-00805F9B34FB"));
56
57 // Short to full
58 EXPECT_EQ("00001101-0000-1000-8000-00805f9b34fb",
59 bluetooth_utils::CanonicalUuid("1101"));
60 EXPECT_EQ("00001101-0000-1000-8000-00805f9b34fb",
61 bluetooth_utils::CanonicalUuid("0x1101"));
62 EXPECT_EQ("00001101-0000-1000-8000-00805f9b34fb",
63 bluetooth_utils::CanonicalUuid("00001101"));
64 EXPECT_EQ("00001101-0000-1000-8000-00805f9b34fb",
65 bluetooth_utils::CanonicalUuid("0x00001101"));
66
67 // No 0x prefix on 36 character
68 EXPECT_EQ("",
69 bluetooth_utils::CanonicalUuid("0x00001101-0000-1000-8000-00805f9b34fb"));
70 }
71
72 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698