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

Side by Side Diff: device/bluetooth/bluetooth_local_gatt_characteristic_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_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 CompleteGattSetup();
25 }
26
27 protected:
28 base::WeakPtr<BluetoothLocalGattCharacteristic> characteristic_;
29 };
30
31 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
32 TEST_F(BluetoothLocalGattCharacteristicTest, ReadLocalCharacteristicValue) {
33 TestLocalGattServiceDelegate::value_to_write_ = 0x1337;
34 SimulateLocalGattCharacteristicValueReadRequest(
35 service_.get(), characteristic_.get(),
36 GetReadValueCallback(Call::EXPECTED), GetCallback(Call::NOT_EXPECTED));
37
38 EXPECT_EQ(TestLocalGattServiceDelegate::value_to_write_,
39 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, TestLocalGattServiceDelegate::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 TestLocalGattServiceDelegate::value_to_write_ = 0x1337;
57 TestLocalGattServiceDelegate::should_fail_ = true;
58 SimulateLocalGattCharacteristicValueReadRequest(
59 service_.get(), characteristic_.get(),
60 GetReadValueCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
61
62 EXPECT_NE(TestLocalGattServiceDelegate::value_to_write_,
63 GetInteger(last_read_value_));
64 }
65 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
66
67 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
68 TEST_F(BluetoothLocalGattCharacteristicTest,
69 WriteLocalCharacteristicValueFail) {
70 const uint64_t kValueToWrite = 0x7331ul;
71 TestLocalGattServiceDelegate::should_fail_ = true;
72 SimulateLocalGattCharacteristicValueWriteRequest(
73 service_.get(), characteristic_.get(), GetValue(kValueToWrite),
74 GetCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
75
76 EXPECT_NE(kValueToWrite, TestLocalGattServiceDelegate::last_written_value_);
77 }
78 #endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
79
80 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_local_gatt_characteristic.cc ('k') | device/bluetooth/bluetooth_local_gatt_descriptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698