Roll src/third_party/WebKit 787a07c:716df21 (svn 201034:201036)
[chromium-blink-merge.git] / device / bluetooth / test / bluetooth_test_android.cc
blob1be588d51643d5559b18d5462e5313ab4ad5ba27
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
3 // found in the LICENSE file.
5 #include "device/bluetooth/test/bluetooth_test_android.h"
7 #include "base/logging.h"
8 #include "device/bluetooth/android/wrappers.h"
9 #include "device/bluetooth/bluetooth_adapter_android.h"
10 #include "jni/Fakes_jni.h"
12 using base::android::AttachCurrentThread;
13 using base::android::ScopedJavaLocalRef;
15 namespace device {
17 BluetoothTestAndroid::BluetoothTestAndroid() {
20 BluetoothTestAndroid::~BluetoothTestAndroid() {
23 void BluetoothTestAndroid::SetUp() {
24 // Register in SetUp so that ASSERT can be used.
25 ASSERT_TRUE(RegisterNativesImpl(AttachCurrentThread()));
28 bool BluetoothTestAndroid::PlatformSupportsLowEnergy() {
29 return true;
32 void BluetoothTestAndroid::InitWithDefaultAdapter() {
33 adapter_ =
34 BluetoothAdapterAndroid::Create(
35 BluetoothAdapterWrapper_CreateWithDefaultAdapter().obj()).get();
38 void BluetoothTestAndroid::InitWithoutDefaultAdapter() {
39 adapter_ = BluetoothAdapterAndroid::Create(NULL).get();
42 void BluetoothTestAndroid::InitWithFakeAdapter() {
43 j_fake_bluetooth_adapter_.Reset(
44 Java_FakeBluetoothAdapter_create(AttachCurrentThread()));
46 adapter_ =
47 BluetoothAdapterAndroid::Create(j_fake_bluetooth_adapter_.obj()).get();
50 void BluetoothTestAndroid::DiscoverLowEnergyDevice(int device_ordinal) {
51 Java_FakeBluetoothAdapter_discoverLowEnergyDevice(
52 AttachCurrentThread(), j_fake_bluetooth_adapter_.obj(), device_ordinal);
55 } // namespace device