Enable multiline RTL alignment in RTHB on mac
[chromium-blink-merge.git] / device / bluetooth / bluetooth_device_win_unittest.cc
blob7fc8874fc3eab8899f4cdced9f795e2f815e3e3e
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
3 // found in the LICENSE file.
5 #include "base/basictypes.h"
6 #include "base/bind.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/scoped_vector.h"
9 #include "base/sequenced_task_runner.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/test/test_simple_task_runner.h"
12 #include "device/bluetooth/bluetooth_device_win.h"
13 #include "device/bluetooth/bluetooth_service_record_win.h"
14 #include "device/bluetooth/bluetooth_socket_thread.h"
15 #include "device/bluetooth/bluetooth_task_manager_win.h"
16 #include "device/bluetooth/bluetooth_uuid.h"
17 #include "testing/gtest/include/gtest/gtest.h"
19 namespace {
21 const char kDeviceName[] = "Device";
22 const char kDeviceAddress[] = "01:02:03:0A:10:A0";
24 const char kTestAudioSdpName[] = "Audio";
25 const char kTestAudioSdpBytes[] =
26 "35510900000a00010001090001350319110a09000435103506190100090019350619001909"
27 "010209000535031910020900093508350619110d090102090100250c417564696f20536f75"
28 "726365090311090001";
29 const device::BluetoothUUID kTestAudioSdpUuid("110a");
31 const char kTestVideoSdpName[] = "Video";
32 const char kTestVideoSdpBytes[] =
33 "354b0900000a000100030900013506191112191203090004350c3503190100350519000308"
34 "0b090005350319100209000935083506191108090100090100250d566f6963652047617465"
35 "776179";
36 const device::BluetoothUUID kTestVideoSdpUuid("1112");
38 } // namespace
40 namespace device {
42 class BluetoothDeviceWinTest : public testing::Test {
43 public:
44 BluetoothDeviceWinTest() {
45 scoped_refptr<base::SequencedTaskRunner> ui_task_runner(
46 new base::TestSimpleTaskRunner());
47 scoped_refptr<BluetoothSocketThread> socket_thread(
48 BluetoothSocketThread::Get());
50 // Add device with audio/video services.
51 device_state_.reset(new BluetoothTaskManagerWin::DeviceState());
52 device_state_->name = kDeviceName;
53 device_state_->address = kDeviceAddress;
55 BluetoothTaskManagerWin::ServiceRecordState* audio_state =
56 new BluetoothTaskManagerWin::ServiceRecordState();
57 audio_state->name = kTestAudioSdpName;
58 base::HexStringToBytes(kTestAudioSdpBytes, &audio_state->sdp_bytes);
59 device_state_->service_record_states.push_back(audio_state);
61 BluetoothTaskManagerWin::ServiceRecordState* video_state =
62 new BluetoothTaskManagerWin::ServiceRecordState();
63 video_state->name = kTestVideoSdpName;
64 base::HexStringToBytes(kTestVideoSdpBytes, &video_state->sdp_bytes);
65 device_state_->service_record_states.push_back(video_state);
67 device_.reset(new BluetoothDeviceWin(*device_state_,
68 ui_task_runner,
69 socket_thread,
70 NULL,
71 net::NetLog::Source()));
73 // Add empty device.
74 empty_device_state_.reset(new BluetoothTaskManagerWin::DeviceState());
75 empty_device_state_->name = kDeviceName;
76 empty_device_state_->address = kDeviceAddress;
77 empty_device_.reset(new BluetoothDeviceWin(*empty_device_state_,
78 ui_task_runner,
79 socket_thread,
80 NULL,
81 net::NetLog::Source()));
84 protected:
85 scoped_ptr<BluetoothDeviceWin> device_;
86 scoped_ptr<BluetoothTaskManagerWin::DeviceState> device_state_;
87 scoped_ptr<BluetoothDeviceWin> empty_device_;
88 scoped_ptr<BluetoothTaskManagerWin::DeviceState> empty_device_state_;
91 TEST_F(BluetoothDeviceWinTest, GetUUIDs) {
92 BluetoothDevice::UUIDList uuids = device_->GetUUIDs();
94 EXPECT_EQ(2, uuids.size());
95 EXPECT_EQ(kTestAudioSdpUuid, uuids[0]);
96 EXPECT_EQ(kTestVideoSdpUuid, uuids[1]);
98 uuids = empty_device_->GetUUIDs();
99 EXPECT_EQ(0, uuids.size());
102 TEST_F(BluetoothDeviceWinTest, IsEqual) {
103 EXPECT_TRUE(device_->IsEqual(*device_state_));
104 EXPECT_FALSE(device_->IsEqual(*empty_device_state_));
105 EXPECT_FALSE(empty_device_->IsEqual(*device_state_));
106 EXPECT_TRUE(empty_device_->IsEqual(*empty_device_state_));
109 } // namespace device