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

Side by Side Diff: device/bluetooth/test/bluetooth_test_android.cc

Issue 1618273002: Call BluetoothGatt#close() after disconnecting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Call parent class' TearDown Created 4 years, 10 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/test/bluetooth_test_android.h ('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 "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
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 BluetoothTestBase::TearDown();
46 }
47
39 bool BluetoothTestAndroid::PlatformSupportsLowEnergy() { 48 bool BluetoothTestAndroid::PlatformSupportsLowEnergy() {
40 return true; 49 return true;
41 } 50 }
42 51
43 void BluetoothTestAndroid::InitWithDefaultAdapter() { 52 void BluetoothTestAndroid::InitWithDefaultAdapter() {
44 adapter_ = 53 adapter_ =
45 BluetoothAdapterAndroid::Create( 54 BluetoothAdapterAndroid::Create(
46 BluetoothAdapterWrapper_CreateWithDefaultAdapter().obj()).get(); 55 BluetoothAdapterWrapper_CreateWithDefaultAdapter().obj()).get();
47 } 56 }
48 57
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 BluetoothRemoteGattDescriptorAndroid* descriptor_android = 291 BluetoothRemoteGattDescriptorAndroid* descriptor_android =
283 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); 292 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor);
284 Java_FakeBluetoothGattDescriptor_setWriteDescriptorWillFailSynchronouslyOnce( 293 Java_FakeBluetoothGattDescriptor_setWriteDescriptorWillFailSynchronouslyOnce(
285 base::android::AttachCurrentThread(), 294 base::android::AttachCurrentThread(),
286 descriptor_android->GetJavaObject().obj()); 295 descriptor_android->GetJavaObject().obj());
287 } 296 }
288 297
289 void BluetoothTestAndroid::OnFakeBluetoothDeviceConnectGattCalled( 298 void BluetoothTestAndroid::OnFakeBluetoothDeviceConnectGattCalled(
290 JNIEnv* env, 299 JNIEnv* env,
291 const JavaParamRef<jobject>& caller) { 300 const JavaParamRef<jobject>& caller) {
301 gatt_open_connections_++;
292 gatt_connection_attempts_++; 302 gatt_connection_attempts_++;
293 } 303 }
294 304
295 void BluetoothTestAndroid::OnFakeBluetoothGattDisconnect( 305 void BluetoothTestAndroid::OnFakeBluetoothGattDisconnect(
296 JNIEnv* env, 306 JNIEnv* env,
297 const JavaParamRef<jobject>& caller) { 307 const JavaParamRef<jobject>& caller) {
298 gatt_disconnection_attempts_++; 308 gatt_disconnection_attempts_++;
299 } 309 }
300 310
311 void BluetoothTestAndroid::OnFakeBluetoothGattClose(
312 JNIEnv* env,
313 const JavaParamRef<jobject>& caller) {
314 gatt_open_connections_--;
315
316 // close implies disconnect
317 gatt_disconnection_attempts_++;
318 }
319
301 void BluetoothTestAndroid::OnFakeBluetoothGattDiscoverServices( 320 void BluetoothTestAndroid::OnFakeBluetoothGattDiscoverServices(
302 JNIEnv* env, 321 JNIEnv* env,
303 const JavaParamRef<jobject>& caller) { 322 const JavaParamRef<jobject>& caller) {
304 gatt_discovery_attempts_++; 323 gatt_discovery_attempts_++;
305 } 324 }
306 325
307 void BluetoothTestAndroid::OnFakeBluetoothGattSetCharacteristicNotification( 326 void BluetoothTestAndroid::OnFakeBluetoothGattSetCharacteristicNotification(
308 JNIEnv* env, 327 JNIEnv* env,
309 const JavaParamRef<jobject>& caller) { 328 const JavaParamRef<jobject>& caller) {
310 gatt_notify_characteristic_attempts_++; 329 gatt_notify_characteristic_attempts_++;
(...skipping 15 matching lines...) Expand all
326 345
327 void BluetoothTestAndroid::OnFakeBluetoothGattWriteDescriptor( 346 void BluetoothTestAndroid::OnFakeBluetoothGattWriteDescriptor(
328 JNIEnv* env, 347 JNIEnv* env,
329 const JavaParamRef<jobject>& caller, 348 const JavaParamRef<jobject>& caller,
330 const JavaParamRef<jbyteArray>& value) { 349 const JavaParamRef<jbyteArray>& value) {
331 gatt_write_descriptor_attempts_++; 350 gatt_write_descriptor_attempts_++;
332 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_); 351 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_);
333 } 352 }
334 353
335 } // namespace device 354 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/test/bluetooth_test_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698