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

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

Issue 2089313006: bluetooth: Avoid use of lambda to work around clang bug. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 std::vector<uint8_t> empty_vector; 391 std::vector<uint8_t> empty_vector;
392 SimulateGattCharacteristicRead(characteristic1_, empty_vector); 392 SimulateGattCharacteristicRead(characteristic1_, empty_vector);
393 393
394 EXPECT_EQ(1, gatt_read_characteristic_attempts_); 394 EXPECT_EQ(1, gatt_read_characteristic_attempts_);
395 EXPECT_EQ(test_vector, last_read_value_); 395 EXPECT_EQ(test_vector, last_read_value_);
396 EXPECT_EQ(test_vector, characteristic1_->GetValue()); 396 EXPECT_EQ(test_vector, characteristic1_->GetValue());
397 } 397 }
398 #endif // defined(OS_ANDROID) || defined(OS_WIN) 398 #endif // defined(OS_ANDROID) || defined(OS_WIN)
399 399
400 #if defined(OS_ANDROID) || defined(OS_WIN) 400 #if defined(OS_ANDROID) || defined(OS_WIN)
401 // Callback that make sure GattCharacteristicValueChanged has been called
402 // before the callback runs.
403 static void test_callback(
ortuno 2016/06/25 00:19:36 Since this is no longer a lambda you can remove th
pcc1 2016/06/25 00:26:39 Done.
404 BluetoothRemoteGattCharacteristic::ValueCallback callback,
405 const TestBluetoothAdapterObserver& callback_observer,
406 const std::vector<uint8_t>& value) {
407 EXPECT_EQ(1, callback_observer.gatt_characteristic_value_changed_count());
408 callback.Run(value);
409 }
410
401 // Tests that ReadRemoteCharacteristic results in a 411 // Tests that ReadRemoteCharacteristic results in a
402 // GattCharacteristicValueChanged call. 412 // GattCharacteristicValueChanged call.
403 TEST_F(BluetoothRemoteGattCharacteristicTest, 413 TEST_F(BluetoothRemoteGattCharacteristicTest,
404 ReadRemoteCharacteristic_GattCharacteristicValueChanged) { 414 ReadRemoteCharacteristic_GattCharacteristicValueChanged) {
405 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate( 415 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
406 BluetoothRemoteGattCharacteristic::PROPERTY_READ)); 416 BluetoothRemoteGattCharacteristic::PROPERTY_READ));
407 417
408 TestBluetoothAdapterObserver observer(adapter_); 418 TestBluetoothAdapterObserver observer(adapter_);
409 419
410 // Callback that make sure GattCharacteristicValueChanged has been called
411 // before the callback runs.
412 auto test_callback = [](
413 BluetoothRemoteGattCharacteristic::ValueCallback callback,
414 const TestBluetoothAdapterObserver& callback_observer,
415 const std::vector<uint8_t>& value) {
416 EXPECT_EQ(1, callback_observer.gatt_characteristic_value_changed_count());
417 callback.Run(value);
418 };
419
420 characteristic1_->ReadRemoteCharacteristic( 420 characteristic1_->ReadRemoteCharacteristic(
421 base::Bind((void (*)(BluetoothRemoteGattCharacteristic::ValueCallback, 421 base::Bind((void (*)(BluetoothRemoteGattCharacteristic::ValueCallback,
422 const TestBluetoothAdapterObserver&, 422 const TestBluetoothAdapterObserver&,
423 const std::vector<uint8_t>&))test_callback, 423 const std::vector<uint8_t>&))test_callback,
424 GetReadValueCallback(Call::EXPECTED), 424 GetReadValueCallback(Call::EXPECTED),
425 base::ConstRef(observer)), 425 base::ConstRef(observer)),
426 GetGattErrorCallback(Call::NOT_EXPECTED)); 426 GetGattErrorCallback(Call::NOT_EXPECTED));
427 427
428 std::vector<uint8_t> test_vector = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff}; 428 std::vector<uint8_t> test_vector = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
429 SimulateGattCharacteristicRead(characteristic1_, test_vector); 429 SimulateGattCharacteristicRead(characteristic1_, test_vector);
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size()); 1280 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size());
1281 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size()); 1281 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size());
1282 1282
1283 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size()); 1283 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size());
1284 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size()); 1284 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size());
1285 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size()); 1285 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size());
1286 } 1286 }
1287 #endif // defined(OS_ANDROID) || defined(OS_WIN) 1287 #endif // defined(OS_ANDROID) || defined(OS_WIN)
1288 1288
1289 } // namespace device 1289 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698