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

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

Issue 1920693002: Complete //device/bt implementation for hosting local GATT attributes. (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
(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 CompleteGattSetup();
30 }
31
32 protected:
33 base::WeakPtr<BluetoothLocalGattCharacteristic> characteristic_;
34 base::WeakPtr<BluetoothLocalGattDescriptor> descriptor_;
35 };
36
37 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
38 TEST_F(BluetoothLocalGattDescriptorTest, ReadLocalDescriptorValue) {
39 TestLocalGattServiceDelegate::value_to_write_ = 0x1337;
40 SimulateLocalGattDescriptorValueReadRequest(
41 service_.get(), descriptor_.get(), GetReadValueCallback(Call::EXPECTED),
42 GetCallback(Call::NOT_EXPECTED));
43
44 EXPECT_EQ(TestLocalGattServiceDelegate::value_to_write_,
45 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, TestLocalGattServiceDelegate::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 TestLocalGattServiceDelegate::value_to_write_ = 0x1337;
63 TestLocalGattServiceDelegate::should_fail_ = true;
64 SimulateLocalGattDescriptorValueReadRequest(
65 service_.get(), descriptor_.get(),
66 GetReadValueCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
67
68 EXPECT_NE(TestLocalGattServiceDelegate::value_to_write_,
69 GetInteger(last_read_value_));
70 }
71 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
72
73 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
74 TEST_F(BluetoothLocalGattDescriptorTest, WriteLocalDescriptorValueFail) {
75 const uint64_t kValueToWrite = 0x7331ul;
76 TestLocalGattServiceDelegate::should_fail_ = true;
77 SimulateLocalGattDescriptorValueWriteRequest(
78 service_.get(), descriptor_.get(), GetValue(kValueToWrite),
79 GetCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
80
81 EXPECT_NE(kValueToWrite, TestLocalGattServiceDelegate::last_written_value_);
82 }
83 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
84
85 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_local_gatt_descriptor.cc ('k') | device/bluetooth/bluetooth_local_gatt_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698