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

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 TestLocalGattServiceDelegate::value_to_write_ = 0x1337;
scheib 2016/05/03 05:55:57 Instead of statics for ::value_to_write etc, why n
rkc 2016/05/03 18:22:15 Done.
35 SimulateLocalGattCharacteristicValueReadRequest(
36 service_.get(), characteristic_.get(),
37 GetReadValueCallback(Call::EXPECTED), GetCallback(Call::NOT_EXPECTED));
38
39 EXPECT_EQ(TestLocalGattServiceDelegate::value_to_write_,
40 GetInteger(last_read_value_));
41 }
42 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
43
44 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
45 TEST_F(BluetoothLocalGattCharacteristicTest, WriteLocalCharacteristicValue) {
46 const uint64_t kValueToWrite = 0x7331ul;
47 SimulateLocalGattCharacteristicValueWriteRequest(
48 service_.get(), characteristic_.get(), GetValue(kValueToWrite),
49 GetCallback(Call::EXPECTED), GetCallback(Call::NOT_EXPECTED));
50
51 EXPECT_EQ(kValueToWrite, TestLocalGattServiceDelegate::last_written_value_);
52 }
53 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
54
55 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
56 TEST_F(BluetoothLocalGattCharacteristicTest, ReadLocalCharacteristicValueFail) {
57 TestLocalGattServiceDelegate::value_to_write_ = 0x1337;
58 TestLocalGattServiceDelegate::should_fail_ = true;
59 SimulateLocalGattCharacteristicValueReadRequest(
60 service_.get(), characteristic_.get(),
61 GetReadValueCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
62
63 EXPECT_NE(TestLocalGattServiceDelegate::value_to_write_,
64 GetInteger(last_read_value_));
65 }
66 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
67
68 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
69 TEST_F(BluetoothLocalGattCharacteristicTest,
70 WriteLocalCharacteristicValueFail) {
71 const uint64_t kValueToWrite = 0x7331ul;
72 TestLocalGattServiceDelegate::should_fail_ = true;
73 SimulateLocalGattCharacteristicValueWriteRequest(
74 service_.get(), characteristic_.get(), GetValue(kValueToWrite),
75 GetCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
76
77 EXPECT_NE(kValueToWrite, TestLocalGattServiceDelegate::last_written_value_);
78 }
79 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
80
81 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698