OLD | NEW |
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 "content/shell/browser/layout_test/layout_test_bluetooth_adapter_provid
er.h" | 5 #include "content/shell/browser/layout_test/layout_test_bluetooth_adapter_provid
er.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 GetBaseGATTCharacteristic( | 897 GetBaseGATTCharacteristic( |
898 "Heart Rate Measurement", heart_rate.get(), kHeartRateMeasurementUUID, | 898 "Heart Rate Measurement", heart_rate.get(), kHeartRateMeasurementUUID, |
899 BluetoothRemoteGattCharacteristic::PROPERTY_NOTIFY)); | 899 BluetoothRemoteGattCharacteristic::PROPERTY_NOTIFY)); |
900 NiceMockBluetoothGattCharacteristic* measurement_ptr = | 900 NiceMockBluetoothGattCharacteristic* measurement_ptr = |
901 heart_rate_measurement.get(); | 901 heart_rate_measurement.get(); |
902 | 902 |
903 ON_CALL(*heart_rate_measurement, StartNotifySession(_, _)) | 903 ON_CALL(*heart_rate_measurement, StartNotifySession(_, _)) |
904 .WillByDefault(RunCallbackWithResult<0 /* success_callback */>( | 904 .WillByDefault(RunCallbackWithResult<0 /* success_callback */>( |
905 [adapter, measurement_ptr]() { | 905 [adapter, measurement_ptr]() { |
906 std::unique_ptr<NiceMockBluetoothGattNotifySession> notify_session( | 906 std::unique_ptr<NiceMockBluetoothGattNotifySession> notify_session( |
907 GetBaseGATTNotifySession(measurement_ptr->GetIdentifier())); | 907 GetBaseGATTNotifySession(measurement_ptr->GetWeakPtr())); |
908 | 908 |
909 std::vector<uint8_t> rate(1 /* size */); | 909 std::vector<uint8_t> rate(1 /* size */); |
910 rate[0] = 60; | 910 rate[0] = 60; |
911 | 911 |
912 notify_session->StartTestNotifications(adapter, measurement_ptr, | 912 notify_session->StartTestNotifications(adapter, measurement_ptr, |
913 rate); | 913 rate); |
914 | 914 |
915 return notify_session; | 915 return notify_session; |
916 })); | 916 })); |
917 | 917 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 .WillByDefault(RunCallback<1 /* error_callback */>(error_code)); | 1008 .WillByDefault(RunCallback<1 /* error_callback */>(error_code)); |
1009 | 1009 |
1010 return characteristic; | 1010 return characteristic; |
1011 } | 1011 } |
1012 | 1012 |
1013 // Notify sessions | 1013 // Notify sessions |
1014 | 1014 |
1015 // static | 1015 // static |
1016 std::unique_ptr<NiceMockBluetoothGattNotifySession> | 1016 std::unique_ptr<NiceMockBluetoothGattNotifySession> |
1017 LayoutTestBluetoothAdapterProvider::GetBaseGATTNotifySession( | 1017 LayoutTestBluetoothAdapterProvider::GetBaseGATTNotifySession( |
1018 const std::string& characteristic_identifier) { | 1018 base::WeakPtr<device::BluetoothRemoteGattCharacteristic> characteristic) { |
1019 std::unique_ptr<NiceMockBluetoothGattNotifySession> session( | 1019 std::unique_ptr<NiceMockBluetoothGattNotifySession> session( |
1020 new NiceMockBluetoothGattNotifySession(characteristic_identifier)); | 1020 new NiceMockBluetoothGattNotifySession(characteristic)); |
1021 | 1021 |
1022 ON_CALL(*session, Stop(_)) | 1022 ON_CALL(*session, Stop(_)) |
1023 .WillByDefault(testing::DoAll( | 1023 .WillByDefault(testing::DoAll( |
1024 InvokeWithoutArgs( | 1024 InvokeWithoutArgs( |
1025 session.get(), | 1025 session.get(), |
1026 &MockBluetoothGattNotifySession::StopTestNotifications), | 1026 &MockBluetoothGattNotifySession::StopTestNotifications), |
1027 RunCallback<0>())); | 1027 RunCallback<0>())); |
1028 | 1028 |
1029 return session; | 1029 return session; |
1030 } | 1030 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 return BluetoothUUID(); | 1081 return BluetoothUUID(); |
1082 } | 1082 } |
1083 | 1083 |
1084 // static | 1084 // static |
1085 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) { | 1085 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) { |
1086 return BluetoothDevice::CanonicalizeAddress( | 1086 return BluetoothDevice::CanonicalizeAddress( |
1087 base::StringPrintf("%012" PRIx64, addr)); | 1087 base::StringPrintf("%012" PRIx64, addr)); |
1088 } | 1088 } |
1089 | 1089 |
1090 } // namespace content | 1090 } // namespace content |
OLD | NEW |