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

Side by Side Diff: device/bluetooth/dbus/fake_bluetooth_device_client.cc

Issue 1884033002: Implement BluetoothTestBlueZ and enable some LE tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 "device/bluetooth/dbus/fake_bluetooth_device_client.h" 5 #include "device/bluetooth/dbus/fake_bluetooth_device_client.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 if (status == BluetoothProfileServiceProvider::Delegate::SUCCESS) { 1665 if (status == BluetoothProfileServiceProvider::Delegate::SUCCESS) {
1666 // TODO(keybuk): tear down this side of the connection 1666 // TODO(keybuk): tear down this side of the connection
1667 callback.Run(); 1667 callback.Run();
1668 } else if (status == BluetoothProfileServiceProvider::Delegate::CANCELLED) { 1668 } else if (status == BluetoothProfileServiceProvider::Delegate::CANCELLED) {
1669 error_callback.Run(bluetooth_device::kErrorFailed, "Canceled"); 1669 error_callback.Run(bluetooth_device::kErrorFailed, "Canceled");
1670 } else if (status == BluetoothProfileServiceProvider::Delegate::REJECTED) { 1670 } else if (status == BluetoothProfileServiceProvider::Delegate::REJECTED) {
1671 error_callback.Run(bluetooth_device::kErrorFailed, "Rejected"); 1671 error_callback.Run(bluetooth_device::kErrorFailed, "Rejected");
1672 } 1672 }
1673 } 1673 }
1674 1674
1675 void FakeBluetoothDeviceClient::RemoveAllDevices() {
1676 device_list_.clear();
1677 }
1678
1679 void FakeBluetoothDeviceClient::CreateTestDevice(
1680 const dbus::ObjectPath& adapter_path,
1681 const std::string name,
1682 const std::string alias,
1683 const std::string device_address,
1684 const std::vector<std::string>& service_uuids) {
1685 // Create a random device path.
1686 dbus::ObjectPath device_path;
1687 do {
1688 device_path = dbus::ObjectPath(adapter_path.value() + "/dev" +
1689 base::RandBytesAsString(10));
1690 } while (std::find(device_list_.begin(), device_list_.end(), device_path) !=
1691 device_list_.end());
1692
1693 std::unique_ptr<Properties> properties(
1694 new Properties(base::Bind(&FakeBluetoothDeviceClient::OnPropertyChanged,
1695 base::Unretained(this), device_path)));
1696 properties->adapter.ReplaceValue(adapter_path);
1697
1698 properties->address.ReplaceValue(device_address);
1699 properties->name.ReplaceValue(name);
1700 properties->alias.ReplaceValue(alias);
1701
1702 properties->uuids.ReplaceValue(service_uuids);
1703
1704 properties_map_.insert(std::make_pair(device_path, std::move(properties)));
1705 device_list_.push_back(device_path);
1706 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_,
1707 DeviceAdded(device_path));
1708 }
1709
1675 } // namespace bluez 1710 } // namespace bluez
OLDNEW
« no previous file with comments | « device/bluetooth/dbus/fake_bluetooth_device_client.h ('k') | device/bluetooth/test/bluetooth_test_bluez.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698