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 "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 "jni/Fakes_jni.h" | 10 #include "jni/Fakes_jni.h" |
11 | 11 |
12 using base::android::AttachCurrentThread; | 12 using base::android::AttachCurrentThread; |
13 using base::android::ScopedJavaLocalRef; | 13 using base::android::ScopedJavaLocalRef; |
14 | 14 |
15 namespace device { | 15 namespace device { |
16 | 16 |
17 BluetoothTestAndroid::BluetoothTestAndroid() { | 17 BluetoothTestAndroid::BluetoothTestAndroid() { |
18 } | 18 } |
19 | 19 |
20 BluetoothTestAndroid::~BluetoothTestAndroid() { | 20 BluetoothTestAndroid::~BluetoothTestAndroid() { |
21 } | 21 } |
22 | 22 |
23 void BluetoothTestAndroid::SetUp() { | 23 void BluetoothTestAndroid::SetUp() { |
24 // Register in SetUp so that ASSERT can be used. | 24 // Register in SetUp so that ASSERT can be used. |
25 ASSERT_TRUE(RegisterNativesImpl(AttachCurrentThread())); | 25 ASSERT_TRUE(RegisterNativesImpl(AttachCurrentThread())); |
26 } | 26 } |
27 | 27 |
| 28 bool BluetoothTestAndroid::PlatformSupportsLowEnergy() { |
| 29 return true; |
| 30 } |
| 31 |
28 void BluetoothTestAndroid::InitWithDefaultAdapter() { | 32 void BluetoothTestAndroid::InitWithDefaultAdapter() { |
29 adapter_ = | 33 adapter_ = |
30 BluetoothAdapterAndroid::Create( | 34 BluetoothAdapterAndroid::Create( |
31 BluetoothAdapterWrapper_CreateWithDefaultAdapter().obj()).get(); | 35 BluetoothAdapterWrapper_CreateWithDefaultAdapter().obj()).get(); |
32 } | 36 } |
33 | 37 |
34 void BluetoothTestAndroid::InitWithoutDefaultAdapter() { | 38 void BluetoothTestAndroid::InitWithoutDefaultAdapter() { |
35 adapter_ = BluetoothAdapterAndroid::Create(NULL).get(); | 39 adapter_ = BluetoothAdapterAndroid::Create(NULL).get(); |
36 } | 40 } |
37 | 41 |
38 void BluetoothTestAndroid::InitWithFakeAdapter() { | 42 void BluetoothTestAndroid::InitWithFakeAdapter() { |
39 j_fake_bluetooth_adapter_.Reset( | 43 j_fake_bluetooth_adapter_.Reset( |
40 Java_FakeBluetoothAdapter_create(AttachCurrentThread())); | 44 Java_FakeBluetoothAdapter_create(AttachCurrentThread())); |
41 | 45 |
42 adapter_ = | 46 adapter_ = |
43 BluetoothAdapterAndroid::Create(j_fake_bluetooth_adapter_.obj()).get(); | 47 BluetoothAdapterAndroid::Create(j_fake_bluetooth_adapter_.obj()).get(); |
44 } | 48 } |
45 | 49 |
46 void BluetoothTestAndroid::DiscoverLowEnergyDevice(int device_ordinal) { | 50 void BluetoothTestAndroid::DiscoverLowEnergyDevice(int device_ordinal) { |
47 Java_FakeBluetoothAdapter_discoverLowEnergyDevice( | 51 Java_FakeBluetoothAdapter_discoverLowEnergyDevice( |
48 AttachCurrentThread(), j_fake_bluetooth_adapter_.obj(), device_ordinal); | 52 AttachCurrentThread(), j_fake_bluetooth_adapter_.obj(), device_ordinal); |
49 } | 53 } |
50 | 54 |
51 } // namespace device | 55 } // namespace device |
OLD | NEW |