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

Unified Diff: device/bluetooth/test/test_bluetooth_local_gatt_service_delegate.cc

Issue 1919683002: Adapter changes for implementing local GATT attributes and tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dbus_classes
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/test/test_bluetooth_local_gatt_service_delegate.h ('k') | device/device_tests.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/test/test_bluetooth_local_gatt_service_delegate.cc
diff --git a/device/bluetooth/test/test_bluetooth_local_gatt_service_delegate.cc b/device/bluetooth/test/test_bluetooth_local_gatt_service_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c96c1a419250a740869f2323fdb12b5f5321e711
--- /dev/null
+++ b/device/bluetooth/test/test_bluetooth_local_gatt_service_delegate.cc
@@ -0,0 +1,83 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <device/bluetooth/test/test_bluetooth_local_gatt_service_delegate.h>
+#include "base/callback.h"
+#include "device/bluetooth/test/bluetooth_gatt_server_test.h"
+
+namespace device {
+
+TestBluetoothLocalGattServiceDelegate::TestBluetoothLocalGattServiceDelegate()
+ : should_fail_(false),
+ last_written_value_(0),
+ value_to_write_(0),
+ expected_service_(nullptr),
+ expected_characteristic_(nullptr),
+ expected_descriptor_(nullptr) {}
+
+void TestBluetoothLocalGattServiceDelegate::OnCharacteristicReadRequest(
+ const BluetoothLocalGattService* service,
+ const BluetoothLocalGattCharacteristic* characteristic,
+ int offset,
+ const ValueCallback& callback,
+ const ErrorCallback& error_callback) {
+ EXPECT_EQ(expected_service_, service);
+ EXPECT_EQ(expected_characteristic_, characteristic);
+ if (should_fail_) {
+ error_callback.Run();
+ return;
+ }
+ callback.Run(BluetoothGattServerTest::GetValue(value_to_write_));
+}
+
+void TestBluetoothLocalGattServiceDelegate::OnCharacteristicWriteRequest(
+ const BluetoothLocalGattService* service,
+ const BluetoothLocalGattCharacteristic* characteristic,
+ const std::vector<uint8_t>& value,
+ int offset,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
+ EXPECT_EQ(expected_service_, service);
+ EXPECT_EQ(expected_characteristic_, characteristic);
+ if (should_fail_) {
+ error_callback.Run();
+ return;
+ }
+ last_written_value_ = BluetoothGattServerTest::GetInteger(value);
+ callback.Run();
+}
+
+void TestBluetoothLocalGattServiceDelegate::OnDescriptorReadRequest(
+ const BluetoothLocalGattService* service,
+ const BluetoothLocalGattDescriptor* descriptor,
+ int offset,
+ const ValueCallback& callback,
+ const ErrorCallback& error_callback) {
+ EXPECT_EQ(expected_service_, service);
+ EXPECT_EQ(expected_descriptor_, descriptor);
+ if (should_fail_) {
+ error_callback.Run();
+ return;
+ }
+ callback.Run(BluetoothGattServerTest::GetValue(value_to_write_));
+}
+
+void TestBluetoothLocalGattServiceDelegate::OnDescriptorWriteRequest(
+ const BluetoothLocalGattService* service,
+ const BluetoothLocalGattDescriptor* descriptor,
+ const std::vector<uint8_t>& value,
+ int offset,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
+ EXPECT_EQ(expected_service_, service);
+ EXPECT_EQ(expected_descriptor_, descriptor);
+ if (should_fail_) {
+ error_callback.Run();
+ return;
+ }
+ last_written_value_ = BluetoothGattServerTest::GetInteger(value);
+ callback.Run();
+}
+
+} // namespace device
« no previous file with comments | « device/bluetooth/test/test_bluetooth_local_gatt_service_delegate.h ('k') | device/device_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698