From a4a50d0341c3fb40eb75b1aa9f56e7eda9f9a86e Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sun, 9 Oct 2016 14:05:36 +0900 Subject: [PATCH] Fixed Android tests to work on emulator --- .../ensichat/bluetooth/BluetoothInterfaceTest.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/android/src/androidTest/scala/com/nutomic/ensichat/bluetooth/BluetoothInterfaceTest.scala b/android/src/androidTest/scala/com/nutomic/ensichat/bluetooth/BluetoothInterfaceTest.scala index a505e8c..4f0abf4 100644 --- a/android/src/androidTest/scala/com/nutomic/ensichat/bluetooth/BluetoothInterfaceTest.scala +++ b/android/src/androidTest/scala/com/nutomic/ensichat/bluetooth/BluetoothInterfaceTest.scala @@ -6,14 +6,18 @@ import android.test.AndroidTestCase class BluetoothInterfaceTest extends AndroidTestCase { - private lazy val adapter = new BluetoothInterface(getContext, new Handler(), null) + private lazy val btInterface = new BluetoothInterface(getContext, new Handler(), null) /** * Test for issue [[https://github.com/Nutomic/ensichat/issues/3 #3]]. */ def testStartBluetoothOff(): Unit = { - BluetoothAdapter.getDefaultAdapter.disable() - adapter.create() + val btAdapter = BluetoothAdapter.getDefaultAdapter + if (btAdapter == null) + return + + btAdapter.disable() + btInterface.create() } }