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

Unified Diff: device/bluetooth/bluetooth_local_gatt_characteristic_unittest.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: merge 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
Index: device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc
diff --git a/device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc b/device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dc70e73da90138fb868399321cd22df498e0d762
--- /dev/null
+++ b/device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc
@@ -0,0 +1,80 @@
+// 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 "base/memory/weak_ptr.h"
+#include "device/bluetooth/bluetooth_local_gatt_characteristic.h"
+#include "device/bluetooth/test/bluetooth_gatt_server_test.h"
+#include "device/bluetooth/test/bluetooth_test.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace device {
+
+class BluetoothLocalGattCharacteristicTest : public BluetoothGattServerTest {
+ public:
+ void SetUp() override {
+ BluetoothGattServerTest::SetUp();
+
+ StartGattSetup();
+ characteristic_ = BluetoothLocalGattCharacteristic::Create(
+ BluetoothUUID(kTestUUIDGenericAttribute),
+ device::BluetoothLocalGattCharacteristic::Properties(),
+ device::BluetoothLocalGattCharacteristic::Permissions(),
+ service_.get());
+ CompleteGattSetup();
+ }
+
+ protected:
+ base::WeakPtr<BluetoothLocalGattCharacteristic> characteristic_;
+};
+
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
+TEST_F(BluetoothLocalGattCharacteristicTest, ReadLocalCharacteristicValue) {
+ TestLocalGattServiceDelegate::value_to_write_ = 0x1337;
+ SimulateLocalGattCharacteristicValueReadRequest(
+ service_.get(), characteristic_.get(),
+ GetReadValueCallback(Call::EXPECTED), GetCallback(Call::NOT_EXPECTED));
+
+ EXPECT_EQ(TestLocalGattServiceDelegate::value_to_write_,
+ GetInteger(last_read_value_));
+}
+#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
+
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
+TEST_F(BluetoothLocalGattCharacteristicTest, WriteLocalCharacteristicValue) {
+ const uint64_t kValueToWrite = 0x7331ul;
+ SimulateLocalGattCharacteristicValueWriteRequest(
+ service_.get(), characteristic_.get(), GetValue(kValueToWrite),
+ GetCallback(Call::EXPECTED), GetCallback(Call::NOT_EXPECTED));
+
+ EXPECT_EQ(kValueToWrite, TestLocalGattServiceDelegate::last_written_value_);
+}
+#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
+
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
+TEST_F(BluetoothLocalGattCharacteristicTest, ReadLocalCharacteristicValueFail) {
+ TestLocalGattServiceDelegate::value_to_write_ = 0x1337;
+ TestLocalGattServiceDelegate::should_fail_ = true;
+ SimulateLocalGattCharacteristicValueReadRequest(
+ service_.get(), characteristic_.get(),
+ GetReadValueCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
+
+ EXPECT_NE(TestLocalGattServiceDelegate::value_to_write_,
+ GetInteger(last_read_value_));
+}
+#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
+
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
+TEST_F(BluetoothLocalGattCharacteristicTest,
+ WriteLocalCharacteristicValueFail) {
+ const uint64_t kValueToWrite = 0x7331ul;
+ TestLocalGattServiceDelegate::should_fail_ = true;
+ SimulateLocalGattCharacteristicValueWriteRequest(
+ service_.get(), characteristic_.get(), GetValue(kValueToWrite),
+ GetCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
+
+ EXPECT_NE(kValueToWrite, TestLocalGattServiceDelegate::last_written_value_);
+}
+#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
+
+} // namespace device
« no previous file with comments | « device/bluetooth/bluetooth_adapter_unittest.cc ('k') | device/bluetooth/bluetooth_local_gatt_descriptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698