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

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

Issue 224893002: device/bluetooth: Rename device::bluetooth_utils::UUID to device::BluetoothUUID (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "device/bluetooth/bluetooth_device_win.h" 10 #include "device/bluetooth/bluetooth_device_win.h"
11 #include "device/bluetooth/bluetooth_service_record.h" 11 #include "device/bluetooth/bluetooth_service_record.h"
12 #include "device/bluetooth/bluetooth_task_manager_win.h" 12 #include "device/bluetooth/bluetooth_task_manager_win.h"
13 #include "device/bluetooth/bluetooth_uuid.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace { 16 namespace {
16 17
17 const char kDeviceName[] = "Device"; 18 const char kDeviceName[] = "Device";
18 const char kDeviceAddress[] = "device address"; 19 const char kDeviceAddress[] = "device address";
19 20
20 const char kTestAudioSdpName[] = "Audio"; 21 const char kTestAudioSdpName[] = "Audio";
21 const char kTestAudioSdpAddress[] = "01:02:03:0A:10:A0"; 22 const char kTestAudioSdpAddress[] = "01:02:03:0A:10:A0";
22 const char kTestAudioSdpBytes[] = 23 const char kTestAudioSdpBytes[] =
23 "35510900000a00010001090001350319110a09000435103506190100090019350619001909" 24 "35510900000a00010001090001350319110a09000435103506190100090019350619001909"
24 "010209000535031910020900093508350619110d090102090100250c417564696f20536f75" 25 "010209000535031910020900093508350619110d090102090100250c417564696f20536f75"
25 "726365090311090001"; 26 "726365090311090001";
26 const char kTestAudioSdpUuid[] = "0000110a-0000-1000-8000-00805f9b34fb"; 27 const device::BluetoothUUID kTestAudioSdpUuid("110a");
27 28
28 const char kTestVideoSdpName[] = "Video"; 29 const char kTestVideoSdpName[] = "Video";
29 const char kTestVideoSdpAddress[] = "A0:10:0A:03:02:01"; 30 const char kTestVideoSdpAddress[] = "A0:10:0A:03:02:01";
30 const char kTestVideoSdpBytes[] = 31 const char kTestVideoSdpBytes[] =
31 "354b0900000a000100030900013506191112191203090004350c3503190100350519000308" 32 "354b0900000a000100030900013506191112191203090004350c3503190100350519000308"
32 "0b090005350319100209000935083506191108090100090100250d566f6963652047617465" 33 "0b090005350319100209000935083506191108090100090100250d566f6963652047617465"
33 "776179"; 34 "776179";
34 const char kTestVideoSdpUuid[] = "00001112-0000-1000-8000-00805f9b34fb"; 35 const device::BluetoothUUID kTestVideoSdpUuid("1112");
35 36
36 } // namespace 37 } // namespace
37 38
38 namespace device { 39 namespace device {
39 40
40 class BluetoothDeviceWinTest : public testing::Test { 41 class BluetoothDeviceWinTest : public testing::Test {
41 public: 42 public:
42 BluetoothDeviceWinTest() { 43 BluetoothDeviceWinTest() {
43 BluetoothTaskManagerWin::DeviceState device_state; 44 BluetoothTaskManagerWin::DeviceState device_state;
44 device_state.name = kDeviceName; 45 device_state.name = kDeviceName;
45 device_state.address = kDeviceAddress; 46 device_state.address = kDeviceAddress;
46 47
48 // Add device with audio/video services.
47 BluetoothTaskManagerWin::ServiceRecordState* audio_state = 49 BluetoothTaskManagerWin::ServiceRecordState* audio_state =
48 new BluetoothTaskManagerWin::ServiceRecordState(); 50 new BluetoothTaskManagerWin::ServiceRecordState();
49 audio_state->name = kTestAudioSdpName; 51 audio_state->name = kTestAudioSdpName;
50 audio_state->address = kTestAudioSdpAddress; 52 audio_state->address = kTestAudioSdpAddress;
51 base::HexStringToBytes(kTestAudioSdpBytes, &audio_state->sdp_bytes); 53 base::HexStringToBytes(kTestAudioSdpBytes, &audio_state->sdp_bytes);
52 device_state.service_record_states.push_back(audio_state); 54 device_state.service_record_states.push_back(audio_state);
53 55
54 BluetoothTaskManagerWin::ServiceRecordState* video_state = 56 BluetoothTaskManagerWin::ServiceRecordState* video_state =
55 new BluetoothTaskManagerWin::ServiceRecordState(); 57 new BluetoothTaskManagerWin::ServiceRecordState();
56 video_state->name = kTestVideoSdpName; 58 video_state->name = kTestVideoSdpName;
57 video_state->address = kTestVideoSdpAddress; 59 video_state->address = kTestVideoSdpAddress;
58 base::HexStringToBytes(kTestVideoSdpBytes, &video_state->sdp_bytes); 60 base::HexStringToBytes(kTestVideoSdpBytes, &video_state->sdp_bytes);
59 device_state.service_record_states.push_back(video_state); 61 device_state.service_record_states.push_back(video_state);
60 62
61 device_.reset(new BluetoothDeviceWin(device_state)); 63 device_.reset(new BluetoothDeviceWin(device_state));
64
65 // Add empty device.
66 device_state.service_record_states.clear();
67 empty_device_.reset(new BluetoothDeviceWin(device_state));
62 } 68 }
63 69
64 protected: 70 protected:
65 scoped_ptr<BluetoothDevice> device_; 71 scoped_ptr<BluetoothDevice> device_;
66 scoped_ptr<BluetoothDevice> empty_device_; 72 scoped_ptr<BluetoothDevice> empty_device_;
67 }; 73 };
68 74
69 TEST_F(BluetoothDeviceWinTest, GetUUIDs) { 75 TEST_F(BluetoothDeviceWinTest, GetUUIDs) {
70 BluetoothDevice::UUIDList uuids = device_->GetUUIDs(); 76 BluetoothDevice::UUIDList uuids = device_->GetUUIDs();
71 77
72 EXPECT_EQ(2, uuids.size()); 78 EXPECT_EQ(2, uuids.size());
73 EXPECT_STREQ(kTestAudioSdpUuid, uuids[0].c_str()); 79 EXPECT_EQ(kTestAudioSdpUuid, uuids[0]);
74 EXPECT_STREQ(kTestVideoSdpUuid, uuids[1].c_str()); 80 EXPECT_EQ(kTestVideoSdpUuid, uuids[1]);
75 81
76 uuids = empty_device_->GetUUIDs(); 82 uuids = empty_device_->GetUUIDs();
77 EXPECT_EQ(0, uuids.size()); 83 EXPECT_EQ(0, uuids.size());
78 } 84 }
79 85
80 } // namespace device 86 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_win.cc ('k') | device/bluetooth/bluetooth_gatt_characteristic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698