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

Side by Side Diff: device/bluetooth/bluetooth_service_record_chromeos_unittest.cc

Issue 11884027: Separated BluetoothServiceRecord interface from BluetoothServiceRecordChromeOs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed to BluetoothServiceRecordChromeOS Created 7 years, 11 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 <string> 5 #include <string>
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "device/bluetooth/bluetooth_service_record.h" 12 #include "device/bluetooth/bluetooth_service_record_chromeos.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace { 15 namespace {
16 16
17 static const char* kAddress = "01:02:03:04:05:06"; 17 static const char* kAddress = "01:02:03:04:05:06";
18 static const char* kCustomUuid = "01234567-89ab-cdef-0123-456789abcdef"; 18 static const char* kCustomUuid = "01234567-89ab-cdef-0123-456789abcdef";
19 static const char* kSerialUuid = "00001101-0000-1000-8000-00805f9b34fb"; 19 static const char* kSerialUuid = "00001101-0000-1000-8000-00805f9b34fb";
20 20
21 } // namespace 21 } // namespace
22 22
23 namespace device { 23 namespace chromeos {
24 24
25 class BluetoothServiceRecordTest : public testing::Test { 25 class BluetoothServiceRecordChromeOSTest : public testing::Test {
26 public: 26 public:
27 FilePath GetTestDataFilePath(const char* file) { 27 FilePath GetTestDataFilePath(const char* file) {
28 FilePath path; 28 FilePath path;
29 PathService::Get(base::DIR_SOURCE_ROOT, &path); 29 PathService::Get(base::DIR_SOURCE_ROOT, &path);
30 path = path.AppendASCII("device"); 30 path = path.AppendASCII("device");
31 path = path.AppendASCII("test"); 31 path = path.AppendASCII("test");
32 path = path.AppendASCII("data"); 32 path = path.AppendASCII("data");
33 path = path.AppendASCII("bluetooth"); 33 path = path.AppendASCII("bluetooth");
34 path = path.AppendASCII(file); 34 path = path.AppendASCII(file);
35 return path; 35 return path;
36 } 36 }
37 }; 37 };
38 38
39 TEST_F(BluetoothServiceRecordTest, RfcommService) { 39 TEST_F(BluetoothServiceRecordChromeOSTest, RfcommService) {
40 std::string xml_data; 40 std::string xml_data;
41 file_util::ReadFileToString(GetTestDataFilePath("rfcomm.xml"), &xml_data); 41 file_util::ReadFileToString(GetTestDataFilePath("rfcomm.xml"), &xml_data);
42 42
43 BluetoothServiceRecord service_record(kAddress, xml_data); 43 BluetoothServiceRecordChromeOS service_record(kAddress, xml_data);
44 EXPECT_EQ(kAddress, service_record.address()); 44 EXPECT_EQ(kAddress, service_record.address());
45 EXPECT_EQ("Headset Audio Gateway", service_record.name()); 45 EXPECT_EQ("Headset Audio Gateway", service_record.name());
46 EXPECT_TRUE(service_record.SupportsRfcomm()); 46 EXPECT_TRUE(service_record.SupportsRfcomm());
47 EXPECT_EQ((uint8)12, service_record.rfcomm_channel()); 47 EXPECT_EQ((uint8)12, service_record.rfcomm_channel());
48 EXPECT_EQ(kCustomUuid, service_record.uuid()); 48 EXPECT_EQ(kCustomUuid, service_record.uuid());
49 } 49 }
50 50
51 TEST_F(BluetoothServiceRecordTest, ShortUuid) { 51 TEST_F(BluetoothServiceRecordChromeOSTest, ShortUuid) {
52 std::string xml_data; 52 std::string xml_data;
53 file_util::ReadFileToString(GetTestDataFilePath("short_uuid.xml"), &xml_data); 53 file_util::ReadFileToString(GetTestDataFilePath("short_uuid.xml"), &xml_data);
54 BluetoothServiceRecord short_uuid_service_record(kAddress, xml_data); 54 BluetoothServiceRecordChromeOS short_uuid_service_record(kAddress, xml_data);
55 EXPECT_EQ(kSerialUuid, short_uuid_service_record.uuid()); 55 EXPECT_EQ(kSerialUuid, short_uuid_service_record.uuid());
56 56
57 xml_data.clear(); 57 xml_data.clear();
58 file_util::ReadFileToString( 58 file_util::ReadFileToString(
59 GetTestDataFilePath("medium_uuid.xml"), &xml_data); 59 GetTestDataFilePath("medium_uuid.xml"), &xml_data);
60 BluetoothServiceRecord medium_uuid_service_record(kAddress, xml_data); 60 BluetoothServiceRecordChromeOS medium_uuid_service_record(kAddress, xml_data);
61 EXPECT_EQ(kSerialUuid, medium_uuid_service_record.uuid()); 61 EXPECT_EQ(kSerialUuid, medium_uuid_service_record.uuid());
62 } 62 }
63 63
64 TEST_F(BluetoothServiceRecordTest, CleanUuid) { 64 TEST_F(BluetoothServiceRecordChromeOSTest, CleanUuid) {
65 std::string xml_data; 65 std::string xml_data;
66 file_util::ReadFileToString(GetTestDataFilePath("uppercase_uuid.xml"), 66 file_util::ReadFileToString(GetTestDataFilePath("uppercase_uuid.xml"),
67 &xml_data); 67 &xml_data);
68 BluetoothServiceRecord service_record(kAddress, xml_data); 68 BluetoothServiceRecordChromeOS service_record(kAddress, xml_data);
69 EXPECT_EQ(kCustomUuid, service_record.uuid()); 69 EXPECT_EQ(kCustomUuid, service_record.uuid());
70 70
71 xml_data.clear(); 71 xml_data.clear();
72 file_util::ReadFileToString(GetTestDataFilePath("invalid_uuid.xml"), 72 file_util::ReadFileToString(GetTestDataFilePath("invalid_uuid.xml"),
73 &xml_data); 73 &xml_data);
74 BluetoothServiceRecord invalid_service_record(kAddress, xml_data); 74 BluetoothServiceRecordChromeOS invalid_service_record(kAddress, xml_data);
75 EXPECT_EQ("", invalid_service_record.uuid()); 75 EXPECT_EQ("", invalid_service_record.uuid());
76 } 76 }
77 77
78 } // namespace device 78 } // namespace chromeos
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_service_record_chromeos.cc ('k') | device/bluetooth/bluetooth_service_record_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698