| 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 "device/bluetooth/test/bluetooth_test_android.h" | 5 #include "device/bluetooth/test/bluetooth_test_android.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 | 75 |
| 76 BluetoothDevice* BluetoothTestAndroid::DiscoverLowEnergyDevice( | 76 BluetoothDevice* BluetoothTestAndroid::DiscoverLowEnergyDevice( |
| 77 int device_ordinal) { | 77 int device_ordinal) { |
| 78 TestBluetoothAdapterObserver observer(adapter_); | 78 TestBluetoothAdapterObserver observer(adapter_); |
| 79 Java_FakeBluetoothAdapter_discoverLowEnergyDevice( | 79 Java_FakeBluetoothAdapter_discoverLowEnergyDevice( |
| 80 AttachCurrentThread(), j_fake_bluetooth_adapter_.obj(), device_ordinal); | 80 AttachCurrentThread(), j_fake_bluetooth_adapter_.obj(), device_ordinal); |
| 81 return observer.last_device(); | 81 return observer.last_device(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void BluetoothTestAndroid::ForceIllegalStateException() { |
| 85 Java_FakeBluetoothAdapter_forceIllegalStateException( |
| 86 AttachCurrentThread(), j_fake_bluetooth_adapter_.obj()); |
| 87 } |
| 88 |
| 84 void BluetoothTestAndroid::SimulateGattConnection(BluetoothDevice* device) { | 89 void BluetoothTestAndroid::SimulateGattConnection(BluetoothDevice* device) { |
| 85 BluetoothDeviceAndroid* device_android = | 90 BluetoothDeviceAndroid* device_android = |
| 86 static_cast<BluetoothDeviceAndroid*>(device); | 91 static_cast<BluetoothDeviceAndroid*>(device); |
| 87 | 92 |
| 88 Java_FakeBluetoothDevice_connectionStateChange( | 93 Java_FakeBluetoothDevice_connectionStateChange( |
| 89 AttachCurrentThread(), device_android->GetJavaObject().obj(), | 94 AttachCurrentThread(), device_android->GetJavaObject().obj(), |
| 90 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS | 95 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS |
| 91 true); // connected | 96 true); // connected |
| 92 } | 97 } |
| 93 | 98 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 350 |
| 346 void BluetoothTestAndroid::OnFakeBluetoothGattWriteDescriptor( | 351 void BluetoothTestAndroid::OnFakeBluetoothGattWriteDescriptor( |
| 347 JNIEnv* env, | 352 JNIEnv* env, |
| 348 const JavaParamRef<jobject>& caller, | 353 const JavaParamRef<jobject>& caller, |
| 349 const JavaParamRef<jbyteArray>& value) { | 354 const JavaParamRef<jbyteArray>& value) { |
| 350 gatt_write_descriptor_attempts_++; | 355 gatt_write_descriptor_attempts_++; |
| 351 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_); | 356 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_); |
| 352 } | 357 } |
| 353 | 358 |
| 354 } // namespace device | 359 } // namespace device |
| OLD | NEW |