Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 29 } | 29 } |
| 30 | 30 |
| 31 BluetoothTestAndroid::~BluetoothTestAndroid() { | 31 BluetoothTestAndroid::~BluetoothTestAndroid() { |
| 32 } | 32 } |
| 33 | 33 |
| 34 void BluetoothTestAndroid::SetUp() { | 34 void BluetoothTestAndroid::SetUp() { |
| 35 // Register in SetUp so that ASSERT can be used. | 35 // Register in SetUp so that ASSERT can be used. |
| 36 ASSERT_TRUE(RegisterNativesImpl(AttachCurrentThread())); | 36 ASSERT_TRUE(RegisterNativesImpl(AttachCurrentThread())); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void BluetoothTestAndroid::TearDown() { | |
| 40 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); | |
| 41 for (auto& device : devices) { | |
| 42 DeleteDevice(device); | |
| 43 } | |
| 44 EXPECT_EQ(0, gatt_open_connections_); | |
| 45 } | |
|
scheib
2016/02/01 18:18:48
Also call BluetoothTest::TearDown()
tommyt
2016/02/02 09:48:30
I even read the comment in bluetooth_test.h that s
| |
| 46 | |
| 39 bool BluetoothTestAndroid::PlatformSupportsLowEnergy() { | 47 bool BluetoothTestAndroid::PlatformSupportsLowEnergy() { |
| 40 return true; | 48 return true; |
| 41 } | 49 } |
| 42 | 50 |
| 43 void BluetoothTestAndroid::InitWithDefaultAdapter() { | 51 void BluetoothTestAndroid::InitWithDefaultAdapter() { |
| 44 adapter_ = | 52 adapter_ = |
| 45 BluetoothAdapterAndroid::Create( | 53 BluetoothAdapterAndroid::Create( |
| 46 BluetoothAdapterWrapper_CreateWithDefaultAdapter().obj()).get(); | 54 BluetoothAdapterWrapper_CreateWithDefaultAdapter().obj()).get(); |
| 47 } | 55 } |
| 48 | 56 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 BluetoothRemoteGattDescriptorAndroid* descriptor_android = | 290 BluetoothRemoteGattDescriptorAndroid* descriptor_android = |
| 283 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); | 291 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); |
| 284 Java_FakeBluetoothGattDescriptor_setWriteDescriptorWillFailSynchronouslyOnce( | 292 Java_FakeBluetoothGattDescriptor_setWriteDescriptorWillFailSynchronouslyOnce( |
| 285 base::android::AttachCurrentThread(), | 293 base::android::AttachCurrentThread(), |
| 286 descriptor_android->GetJavaObject().obj()); | 294 descriptor_android->GetJavaObject().obj()); |
| 287 } | 295 } |
| 288 | 296 |
| 289 void BluetoothTestAndroid::OnFakeBluetoothDeviceConnectGattCalled( | 297 void BluetoothTestAndroid::OnFakeBluetoothDeviceConnectGattCalled( |
| 290 JNIEnv* env, | 298 JNIEnv* env, |
| 291 const JavaParamRef<jobject>& caller) { | 299 const JavaParamRef<jobject>& caller) { |
| 300 gatt_open_connections_++; | |
| 292 gatt_connection_attempts_++; | 301 gatt_connection_attempts_++; |
| 293 } | 302 } |
| 294 | 303 |
| 295 void BluetoothTestAndroid::OnFakeBluetoothGattDisconnect( | 304 void BluetoothTestAndroid::OnFakeBluetoothGattDisconnect( |
| 296 JNIEnv* env, | 305 JNIEnv* env, |
| 297 const JavaParamRef<jobject>& caller) { | 306 const JavaParamRef<jobject>& caller) { |
| 298 gatt_disconnection_attempts_++; | 307 gatt_disconnection_attempts_++; |
| 299 } | 308 } |
| 300 | 309 |
| 310 void BluetoothTestAndroid::OnFakeBluetoothGattClose( | |
| 311 JNIEnv* env, | |
| 312 const JavaParamRef<jobject>& caller) { | |
| 313 gatt_open_connections_--; | |
| 314 | |
| 315 // close implies disconnect | |
| 316 gatt_disconnection_attempts_++; | |
| 317 } | |
| 318 | |
| 301 void BluetoothTestAndroid::OnFakeBluetoothGattDiscoverServices( | 319 void BluetoothTestAndroid::OnFakeBluetoothGattDiscoverServices( |
| 302 JNIEnv* env, | 320 JNIEnv* env, |
| 303 const JavaParamRef<jobject>& caller) { | 321 const JavaParamRef<jobject>& caller) { |
| 304 gatt_discovery_attempts_++; | 322 gatt_discovery_attempts_++; |
| 305 } | 323 } |
| 306 | 324 |
| 307 void BluetoothTestAndroid::OnFakeBluetoothGattSetCharacteristicNotification( | 325 void BluetoothTestAndroid::OnFakeBluetoothGattSetCharacteristicNotification( |
| 308 JNIEnv* env, | 326 JNIEnv* env, |
| 309 const JavaParamRef<jobject>& caller) { | 327 const JavaParamRef<jobject>& caller) { |
| 310 gatt_notify_characteristic_attempts_++; | 328 gatt_notify_characteristic_attempts_++; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 326 | 344 |
| 327 void BluetoothTestAndroid::OnFakeBluetoothGattWriteDescriptor( | 345 void BluetoothTestAndroid::OnFakeBluetoothGattWriteDescriptor( |
| 328 JNIEnv* env, | 346 JNIEnv* env, |
| 329 const JavaParamRef<jobject>& caller, | 347 const JavaParamRef<jobject>& caller, |
| 330 const JavaParamRef<jbyteArray>& value) { | 348 const JavaParamRef<jbyteArray>& value) { |
| 331 gatt_write_descriptor_attempts_++; | 349 gatt_write_descriptor_attempts_++; |
| 332 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_); | 350 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_); |
| 333 } | 351 } |
| 334 | 352 |
| 335 } // namespace device | 353 } // namespace device |
| OLD | NEW |