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

Side by Side Diff: device/bluetooth/bluetooth_local_gatt_descriptor_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: Created 4 years, 7 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
(Empty)
1 // Copyright 2016 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.
4
5 #include "base/memory/weak_ptr.h"
6 #include "device/bluetooth/bluetooth_gatt_characteristic.h"
7 #include "device/bluetooth/bluetooth_local_gatt_descriptor.h"
8 #include "device/bluetooth/test/bluetooth_gatt_server_test.h"
9 #include "device/bluetooth/test/bluetooth_test.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace device {
13
14 class BluetoothLocalGattDescriptorTest : public BluetoothGattServerTest {
15 public:
16 void SetUp() override {
17 BluetoothGattServerTest::SetUp();
18
19 StartGattSetup();
20 characteristic_ = BluetoothLocalGattCharacteristic::Create(
21 BluetoothUUID(kTestUUIDGenericAttribute),
22 device::BluetoothLocalGattCharacteristic::Properties(),
23 device::BluetoothLocalGattCharacteristic::Permissions(),
24 service_.get());
25 descriptor_ = BluetoothLocalGattDescriptor::Create(
26 BluetoothUUID(kTestUUIDGenericAttribute),
27 device::BluetoothLocalGattCharacteristic::Permissions(),
28 characteristic_.get());
29 EXPECT_LT(0u, descriptor_->GetIdentifier().size());
30 CompleteGattSetup();
31 }
32
33 protected:
34 base::WeakPtr<BluetoothLocalGattCharacteristic> characteristic_;
35 base::WeakPtr<BluetoothLocalGattDescriptor> descriptor_;
36 };
37
38 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
39 TEST_F(BluetoothLocalGattDescriptorTest, ReadLocalDescriptorValue) {
40 delegate_->value_to_write_ = 0x1337;
41 SimulateLocalGattDescriptorValueReadRequest(
42 service_.get(), descriptor_.get(), GetReadValueCallback(Call::EXPECTED),
43 GetCallback(Call::NOT_EXPECTED));
44
45 EXPECT_EQ(delegate_->value_to_write_, GetInteger(last_read_value_));
46 }
47 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
48
49 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
50 TEST_F(BluetoothLocalGattDescriptorTest, WriteLocalDescriptorValue) {
51 const uint64_t kValueToWrite = 0x7331ul;
52 SimulateLocalGattDescriptorValueWriteRequest(
53 service_.get(), descriptor_.get(), GetValue(kValueToWrite),
54 GetCallback(Call::EXPECTED), GetCallback(Call::NOT_EXPECTED));
55
56 EXPECT_EQ(kValueToWrite, delegate_->last_written_value_);
57 }
58 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
59
60 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
61 TEST_F(BluetoothLocalGattDescriptorTest, ReadLocalDescriptorValueFail) {
62 delegate_->value_to_write_ = 0x1337;
63 delegate_->should_fail_ = true;
64 SimulateLocalGattDescriptorValueReadRequest(
65 service_.get(), descriptor_.get(),
66 GetReadValueCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
67
68 EXPECT_NE(delegate_->value_to_write_, GetInteger(last_read_value_));
69 }
70 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
71
72 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
73 TEST_F(BluetoothLocalGattDescriptorTest, WriteLocalDescriptorValueFail) {
74 const uint64_t kValueToWrite = 0x7331ul;
75 delegate_->should_fail_ = true;
76 SimulateLocalGattDescriptorValueWriteRequest(
77 service_.get(), descriptor_.get(), GetValue(kValueToWrite),
78 GetCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
79
80 EXPECT_NE(kValueToWrite, delegate_->last_written_value_);
81 }
82 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
83
84 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc ('k') | device/bluetooth/bluez/bluetooth_adapter_bluez.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698