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

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

Issue 2100313003: bluetooth: Remove Context from Wrappers and use LocationUtils directly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-location-utils
Patch Set: remove new line Created 4 years, 5 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
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 16 matching lines...) Expand all
27 27
28 BluetoothTestAndroid::BluetoothTestAndroid() { 28 BluetoothTestAndroid::BluetoothTestAndroid() {
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
38 // Set the permission to true so that we can use the API.
39 Java_Fakes_setLocationServicesState(
40 AttachCurrentThread(), true /* hasPermission */, true /* isEnabled */);
37 } 41 }
38 42
39 void BluetoothTestAndroid::TearDown() { 43 void BluetoothTestAndroid::TearDown() {
40 BluetoothAdapter::DeviceList devices = adapter_->GetDevices(); 44 BluetoothAdapter::DeviceList devices = adapter_->GetDevices();
41 for (auto& device : devices) { 45 for (auto& device : devices) {
42 DeleteDevice(device); 46 DeleteDevice(device);
43 } 47 }
44 EXPECT_EQ(0, gatt_open_connections_); 48 EXPECT_EQ(0, gatt_open_connections_);
45 BluetoothTestBase::TearDown(); 49 BluetoothTestBase::TearDown();
46 } 50 }
(...skipping 14 matching lines...) Expand all
61 65
62 void BluetoothTestAndroid::InitWithFakeAdapter() { 66 void BluetoothTestAndroid::InitWithFakeAdapter() {
63 j_fake_bluetooth_adapter_.Reset(Java_FakeBluetoothAdapter_create( 67 j_fake_bluetooth_adapter_.Reset(Java_FakeBluetoothAdapter_create(
64 AttachCurrentThread(), reinterpret_cast<intptr_t>(this))); 68 AttachCurrentThread(), reinterpret_cast<intptr_t>(this)));
65 69
66 adapter_ = 70 adapter_ =
67 BluetoothAdapterAndroid::Create(j_fake_bluetooth_adapter_.obj()).get(); 71 BluetoothAdapterAndroid::Create(j_fake_bluetooth_adapter_.obj()).get();
68 } 72 }
69 73
70 bool BluetoothTestAndroid::DenyPermission() { 74 bool BluetoothTestAndroid::DenyPermission() {
71 Java_FakeBluetoothAdapter_denyPermission(AttachCurrentThread(), 75 Java_Fakes_setLocationServicesState(
72 j_fake_bluetooth_adapter_.obj()); 76 AttachCurrentThread(), false /* hasPermission */, true /* isEnabled */);
73 return true; 77 return true;
74 } 78 }
75 79
76 BluetoothDevice* BluetoothTestAndroid::SimulateLowEnergyDevice( 80 BluetoothDevice* BluetoothTestAndroid::SimulateLowEnergyDevice(
77 int device_ordinal) { 81 int device_ordinal) {
78 TestBluetoothAdapterObserver observer(adapter_); 82 TestBluetoothAdapterObserver observer(adapter_);
79 Java_FakeBluetoothAdapter_simulateLowEnergyDevice( 83 Java_FakeBluetoothAdapter_simulateLowEnergyDevice(
80 AttachCurrentThread(), j_fake_bluetooth_adapter_.obj(), device_ordinal); 84 AttachCurrentThread(), j_fake_bluetooth_adapter_.obj(), device_ordinal);
81 return observer.last_device(); 85 return observer.last_device();
82 } 86 }
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 472 }
469 473
470 void BluetoothTestAndroid::OnFakeAdapterStateChanged( 474 void BluetoothTestAndroid::OnFakeAdapterStateChanged(
471 JNIEnv* env, 475 JNIEnv* env,
472 const JavaParamRef<jobject>& caller, 476 const JavaParamRef<jobject>& caller,
473 const bool powered) { 477 const bool powered) {
474 adapter_->NotifyAdapterPoweredChanged(powered); 478 adapter_->NotifyAdapterPoweredChanged(powered);
475 } 479 }
476 480
477 } // namespace device 481 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698