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

Side by Side 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: 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_local_gatt_characteristic.h"
7 #include "device/bluetooth/test/bluetooth_gatt_server_test.h"
8 #include "device/bluetooth/test/bluetooth_test.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace device {
12
13 class BluetoothLocalGattCharacteristicTest : public BluetoothGattServerTest {
14 public:
15 void SetUp() override {
16 BluetoothGattServerTest::SetUp();
17
18 StartGattSetup();
19 characteristic_ = BluetoothLocalGattCharacteristic::Create(
20 BluetoothUUID(kTestUUIDGenericAttribute),
21 device::BluetoothLocalGattCharacteristic::Properties(),
22 device::BluetoothLocalGattCharacteristic::Permissions(),
23 service_.get());
24 EXPECT_LT(0u, characteristic_->GetIdentifier().size());
25 CompleteGattSetup();
26 }
27
28 protected:
29 base::WeakPtr<BluetoothLocalGattCharacteristic> characteristic_;
30 };
31
32 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
33 TEST_F(BluetoothLocalGattCharacteristicTest, ReadLocalCharacteristicValue) {
34 delegate_->value_to_write_ = 0x1337;
35 SimulateLocalGattCharacteristicValueReadRequest(
36 service_.get(), characteristic_.get(),
37 GetReadValueCallback(Call::EXPECTED), GetCallback(Call::NOT_EXPECTED));
38
39 EXPECT_EQ(delegate_->value_to_write_, GetInteger(last_read_value_));
40 }
41 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
42
43 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
44 TEST_F(BluetoothLocalGattCharacteristicTest, WriteLocalCharacteristicValue) {
45 const uint64_t kValueToWrite = 0x7331ul;
46 SimulateLocalGattCharacteristicValueWriteRequest(
47 service_.get(), characteristic_.get(), GetValue(kValueToWrite),
48 GetCallback(Call::EXPECTED), GetCallback(Call::NOT_EXPECTED));
49
50 EXPECT_EQ(kValueToWrite, delegate_->last_written_value_);
51 }
52 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
53
54 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
55 TEST_F(BluetoothLocalGattCharacteristicTest, ReadLocalCharacteristicValueFail) {
56 delegate_->value_to_write_ = 0x1337;
57 delegate_->should_fail_ = true;
58 SimulateLocalGattCharacteristicValueReadRequest(
59 service_.get(), characteristic_.get(),
60 GetReadValueCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
61
62 EXPECT_NE(delegate_->value_to_write_, GetInteger(last_read_value_));
63 }
64 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
65
66 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
67 TEST_F(BluetoothLocalGattCharacteristicTest,
68 WriteLocalCharacteristicValueFail) {
69 const uint64_t kValueToWrite = 0x7331ul;
70 delegate_->should_fail_ = true;
71 SimulateLocalGattCharacteristicValueWriteRequest(
72 service_.get(), characteristic_.get(), GetValue(kValueToWrite),
73 GetCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
74
75 EXPECT_NE(kValueToWrite, delegate_->last_written_value_);
76 }
77 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
78
79 } // namespace device
OLDNEW
« 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