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

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

Issue 180163009: chrome.bluetooth API improvements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ChromeOS Full build. 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
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/sequenced_task_runner.h"
9 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/test/test_simple_task_runner.h"
10 #include "device/bluetooth/bluetooth_device_win.h" 12 #include "device/bluetooth/bluetooth_device_win.h"
11 #include "device/bluetooth/bluetooth_service_record.h" 13 #include "device/bluetooth/bluetooth_service_record.h"
14 #include "device/bluetooth/bluetooth_socket_thread_win.h"
12 #include "device/bluetooth/bluetooth_task_manager_win.h" 15 #include "device/bluetooth/bluetooth_task_manager_win.h"
13 #include "device/bluetooth/bluetooth_uuid.h" 16 #include "device/bluetooth/bluetooth_uuid.h"
14 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
15 18
16 namespace { 19 namespace {
17 20
18 const char kDeviceName[] = "Device"; 21 const char kDeviceName[] = "Device";
19 const char kDeviceAddress[] = "device address"; 22 const char kDeviceAddress[] = "device address";
20 23
21 const char kTestAudioSdpName[] = "Audio"; 24 const char kTestAudioSdpName[] = "Audio";
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 base::HexStringToBytes(kTestAudioSdpBytes, &audio_state->sdp_bytes); 56 base::HexStringToBytes(kTestAudioSdpBytes, &audio_state->sdp_bytes);
54 device_state.service_record_states.push_back(audio_state); 57 device_state.service_record_states.push_back(audio_state);
55 58
56 BluetoothTaskManagerWin::ServiceRecordState* video_state = 59 BluetoothTaskManagerWin::ServiceRecordState* video_state =
57 new BluetoothTaskManagerWin::ServiceRecordState(); 60 new BluetoothTaskManagerWin::ServiceRecordState();
58 video_state->name = kTestVideoSdpName; 61 video_state->name = kTestVideoSdpName;
59 video_state->address = kTestVideoSdpAddress; 62 video_state->address = kTestVideoSdpAddress;
60 base::HexStringToBytes(kTestVideoSdpBytes, &video_state->sdp_bytes); 63 base::HexStringToBytes(kTestVideoSdpBytes, &video_state->sdp_bytes);
61 device_state.service_record_states.push_back(video_state); 64 device_state.service_record_states.push_back(video_state);
62 65
63 device_.reset(new BluetoothDeviceWin(device_state)); 66 scoped_refptr<base::SequencedTaskRunner> ui_task_runner(
67 new base::TestSimpleTaskRunner());
68 scoped_refptr<BluetoothSocketThreadWin> socket_thread(
69 BluetoothSocketThreadWin::Get());
70 device_.reset(new BluetoothDeviceWin(device_state,
71 ui_task_runner,
72 socket_thread,
73 NULL,
74 net::NetLog::Source()));
64 75
65 // Add empty device. 76 // Add empty device.
66 device_state.service_record_states.clear(); 77 device_state.service_record_states.clear();
67 empty_device_.reset(new BluetoothDeviceWin(device_state)); 78 empty_device_.reset(new BluetoothDeviceWin(device_state,
79 ui_task_runner,
80 socket_thread,
81 NULL,
82 net::NetLog::Source()));
68 } 83 }
69 84
70 protected: 85 protected:
71 scoped_ptr<BluetoothDevice> device_; 86 scoped_ptr<BluetoothDevice> device_;
72 scoped_ptr<BluetoothDevice> empty_device_; 87 scoped_ptr<BluetoothDevice> empty_device_;
73 }; 88 };
74 89
75 TEST_F(BluetoothDeviceWinTest, GetUUIDs) { 90 TEST_F(BluetoothDeviceWinTest, GetUUIDs) {
76 BluetoothDevice::UUIDList uuids = device_->GetUUIDs(); 91 BluetoothDevice::UUIDList uuids = device_->GetUUIDs();
77 92
78 EXPECT_EQ(2, uuids.size()); 93 EXPECT_EQ(2, uuids.size());
79 EXPECT_EQ(kTestAudioSdpUuid, uuids[0]); 94 EXPECT_EQ(kTestAudioSdpUuid, uuids[0]);
80 EXPECT_EQ(kTestVideoSdpUuid, uuids[1]); 95 EXPECT_EQ(kTestVideoSdpUuid, uuids[1]);
81 96
82 uuids = empty_device_->GetUUIDs(); 97 uuids = empty_device_->GetUUIDs();
83 EXPECT_EQ(0, uuids.size()); 98 EXPECT_EQ(0, uuids.size());
84 } 99 }
85 100
86 } // namespace device 101 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_win.cc ('k') | device/bluetooth/bluetooth_profile_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698