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

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

Issue 1380883003: bluetooth: Refactor BluetoothTest member names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bt-hold-connections-
Patch Set: Created 5 years, 2 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 "base/logging.h" 7 #include "base/logging.h"
8 #include "device/bluetooth/android/wrappers.h" 8 #include "device/bluetooth/android/wrappers.h"
9 #include "device/bluetooth/bluetooth_adapter_android.h" 9 #include "device/bluetooth/bluetooth_adapter_android.h"
10 #include "device/bluetooth/bluetooth_device_android.h" 10 #include "device/bluetooth/bluetooth_device_android.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 51
52 BluetoothDevice* BluetoothTestAndroid::DiscoverLowEnergyDevice( 52 BluetoothDevice* BluetoothTestAndroid::DiscoverLowEnergyDevice(
53 int device_ordinal) { 53 int device_ordinal) {
54 TestBluetoothAdapterObserver observer(adapter_); 54 TestBluetoothAdapterObserver observer(adapter_);
55 Java_FakeBluetoothAdapter_discoverLowEnergyDevice( 55 Java_FakeBluetoothAdapter_discoverLowEnergyDevice(
56 AttachCurrentThread(), j_fake_bluetooth_adapter_.obj(), device_ordinal); 56 AttachCurrentThread(), j_fake_bluetooth_adapter_.obj(), device_ordinal);
57 return observer.last_device(); 57 return observer.last_device();
58 } 58 }
59 59
60 void BluetoothTestAndroid::CompleteGattConnection(BluetoothDevice* device) { 60 void BluetoothTestAndroid::SimulateGattConnection(BluetoothDevice* device) {
61 BluetoothDeviceAndroid* device_android = 61 BluetoothDeviceAndroid* device_android =
62 static_cast<BluetoothDeviceAndroid*>(device); 62 static_cast<BluetoothDeviceAndroid*>(device);
63 63
64 Java_FakeBluetoothDevice_connectionStateChange( 64 Java_FakeBluetoothDevice_connectionStateChange(
65 AttachCurrentThread(), device_android->GetJavaObject().obj(), 65 AttachCurrentThread(), device_android->GetJavaObject().obj(),
66 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS 66 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS
67 true); // connected 67 true); // connected
68 } 68 }
69 69
70 void BluetoothTestAndroid::FailGattConnection( 70 void BluetoothTestAndroid::SimulateGattConnectionError(
71 BluetoothDevice* device, 71 BluetoothDevice* device,
72 BluetoothDevice::ConnectErrorCode error) { 72 BluetoothDevice::ConnectErrorCode error) {
73 int android_error_value = 0; 73 int android_error_value = 0;
74 switch (error) { // Constants are from android.bluetooth.BluetoothGatt. 74 switch (error) { // Constants are from android.bluetooth.BluetoothGatt.
75 case BluetoothDevice::ERROR_FAILED: 75 case BluetoothDevice::ERROR_FAILED:
76 android_error_value = 0x00000101; // GATT_FAILURE 76 android_error_value = 0x00000101; // GATT_FAILURE
77 break; 77 break;
78 case BluetoothDevice::ERROR_AUTH_FAILED: 78 case BluetoothDevice::ERROR_AUTH_FAILED:
79 android_error_value = 0x00000005; // GATT_INSUFFICIENT_AUTHENTICATION 79 android_error_value = 0x00000005; // GATT_INSUFFICIENT_AUTHENTICATION
80 break; 80 break;
81 case BluetoothDevice::ERROR_UNKNOWN: 81 case BluetoothDevice::ERROR_UNKNOWN:
82 case BluetoothDevice::ERROR_INPROGRESS: 82 case BluetoothDevice::ERROR_INPROGRESS:
83 case BluetoothDevice::ERROR_AUTH_CANCELED: 83 case BluetoothDevice::ERROR_AUTH_CANCELED:
84 case BluetoothDevice::ERROR_AUTH_REJECTED: 84 case BluetoothDevice::ERROR_AUTH_REJECTED:
85 case BluetoothDevice::ERROR_AUTH_TIMEOUT: 85 case BluetoothDevice::ERROR_AUTH_TIMEOUT:
86 case BluetoothDevice::ERROR_UNSUPPORTED_DEVICE: 86 case BluetoothDevice::ERROR_UNSUPPORTED_DEVICE:
87 NOTREACHED() << "No translation for error code: " << error; 87 NOTREACHED() << "No translation for error code: " << error;
88 } 88 }
89 89
90 BluetoothDeviceAndroid* device_android = 90 BluetoothDeviceAndroid* device_android =
91 static_cast<BluetoothDeviceAndroid*>(device); 91 static_cast<BluetoothDeviceAndroid*>(device);
92 92
93 Java_FakeBluetoothDevice_connectionStateChange( 93 Java_FakeBluetoothDevice_connectionStateChange(
94 AttachCurrentThread(), device_android->GetJavaObject().obj(), 94 AttachCurrentThread(), device_android->GetJavaObject().obj(),
95 android_error_value, 95 android_error_value,
96 false); // connected 96 false); // connected
97 } 97 }
98 98
99 void BluetoothTestAndroid::CompleteGattDisconnection(BluetoothDevice* device) { 99 void BluetoothTestAndroid::SimulateGattDisconnection(BluetoothDevice* device) {
100 BluetoothDeviceAndroid* device_android = 100 BluetoothDeviceAndroid* device_android =
101 static_cast<BluetoothDeviceAndroid*>(device); 101 static_cast<BluetoothDeviceAndroid*>(device);
102 102
103 Java_FakeBluetoothDevice_connectionStateChange( 103 Java_FakeBluetoothDevice_connectionStateChange(
104 AttachCurrentThread(), device_android->GetJavaObject().obj(), 104 AttachCurrentThread(), device_android->GetJavaObject().obj(),
105 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS 105 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS
106 false); // disconnected 106 false); // disconnected
107 } 107 }
108 108
109 // Records that Java FakeBluetoothDevice connectGatt was called. 109 void BluetoothTestAndroid::OnFakeBluetoothDeviceConnectGattCalled(
110 void BluetoothTestAndroid::OnBluetoothDeviceConnectGattCalled(JNIEnv* env, 110 JNIEnv* env,
111 jobject caller) { 111 jobject caller) {
112 gatt_connection_attempt_count_++; 112 gatt_connection_attempts_++;
113 } 113 }
114 114
115 // Records that Java FakeBluetoothGatt disconnect was called.
116 void BluetoothTestAndroid::OnFakeBluetoothGattDisconnect(JNIEnv* env, 115 void BluetoothTestAndroid::OnFakeBluetoothGattDisconnect(JNIEnv* env,
117 jobject caller) { 116 jobject caller) {
118 gatt_disconnection_attempt_count_++; 117 gatt_disconnection_attempts_++;
119 } 118 }
120 119
121 } // namespace device 120 } // 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