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

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

Issue 2357993002: Don't send a value changed notification when a characteristic is written (Closed)
Patch Set: Adding unittest Created 4 years, 2 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
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) 552 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
553 // Tests WriteRemoteCharacteristic with non-empty value buffer. 553 // Tests WriteRemoteCharacteristic with non-empty value buffer.
554 TEST_F(BluetoothRemoteGattCharacteristicTest, WriteRemoteCharacteristic) { 554 TEST_F(BluetoothRemoteGattCharacteristicTest, WriteRemoteCharacteristic) {
555 if (!PlatformSupportsLowEnergy()) { 555 if (!PlatformSupportsLowEnergy()) {
556 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 556 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
557 return; 557 return;
558 } 558 }
559 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate( 559 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
560 BluetoothRemoteGattCharacteristic::PROPERTY_WRITE)); 560 BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
561 561
562 TestBluetoothAdapterObserver observer(adapter_);
563
562 uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff}; 564 uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
563 std::vector<uint8_t> test_vector(values, values + arraysize(values)); 565 std::vector<uint8_t> test_vector(values, values + arraysize(values));
566 characteristic1_->ReadRemoteCharacteristic(
ortuno 2016/10/05 21:42:23 I'm not sure why you are adding this?
jlebel 2016/10/05 22:07:38 Done.
567 GetReadValueCallback(Call::NOT_EXPECTED),
568 GetGattErrorCallback(Call::NOT_EXPECTED));
564 characteristic1_->WriteRemoteCharacteristic( 569 characteristic1_->WriteRemoteCharacteristic(
565 test_vector, GetCallback(Call::EXPECTED), 570 test_vector, GetCallback(Call::EXPECTED),
566 GetGattErrorCallback(Call::NOT_EXPECTED)); 571 GetGattErrorCallback(Call::NOT_EXPECTED));
567 572
568 SimulateGattCharacteristicWrite(characteristic1_); 573 SimulateGattCharacteristicWrite(characteristic1_);
569 574
570 EXPECT_EQ(1, gatt_write_characteristic_attempts_); 575 EXPECT_EQ(1, gatt_write_characteristic_attempts_);
576 EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count());
571 EXPECT_EQ(test_vector, last_write_value_); 577 EXPECT_EQ(test_vector, last_write_value_);
572 } 578 }
573 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) 579 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
574 580
575 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) 581 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
576 // Tests ReadRemoteCharacteristic and GetValue multiple times. 582 // Tests ReadRemoteCharacteristic and GetValue multiple times.
577 TEST_F(BluetoothRemoteGattCharacteristicTest, ReadRemoteCharacteristic_Twice) { 583 TEST_F(BluetoothRemoteGattCharacteristicTest, ReadRemoteCharacteristic_Twice) {
578 if (!PlatformSupportsLowEnergy()) { 584 if (!PlatformSupportsLowEnergy()) {
579 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 585 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
580 return; 586 return;
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size()); 2137 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size());
2132 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size()); 2138 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size());
2133 2139
2134 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size()); 2140 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size());
2135 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size()); 2141 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size());
2136 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size()); 2142 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size());
2137 } 2143 }
2138 #endif // defined(OS_ANDROID) || defined(OS_WIN) 2144 #endif // defined(OS_ANDROID) || defined(OS_WIN)
2139 2145
2140 } // namespace device 2146 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698