Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 09e3fd6c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "HidDeviceTest: Start the service with an intent"

parents f0beb508 3dab0e0f
Loading
Loading
Loading
Loading
+10 −6
Original line number Original line Diff line number Diff line
@@ -28,7 +28,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter;
import android.os.IBinder;
import android.os.Looper;
import android.os.Looper;
import android.support.test.InstrumentationRegistry;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest;
import android.support.test.filters.MediumTest;
@@ -124,10 +123,15 @@ public class HidDeviceTest {
        // Get a device for testing
        // Get a device for testing
        mTestDevice = mAdapter.getRemoteDevice("10:11:12:13:14:15");
        mTestDevice = mAdapter.getRemoteDevice("10:11:12:13:14:15");


        IBinder binder = mServiceRule.bindService(
        Intent startIntent =
                new Intent(mTargetContext, HidDeviceService.class));
                new Intent(InstrumentationRegistry.getTargetContext(), HidDeviceService.class);
        mHidDeviceService = ((HidDeviceService.BluetoothHidDeviceBinder) binder)
        startIntent.putExtra(AdapterService.EXTRA_ACTION,
                .getServiceForTesting();
                AdapterService.ACTION_SERVICE_STATE_CHANGED);
        startIntent.putExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.STATE_ON);
        mServiceRule.startService(startIntent);
        verify(sAdapterService, timeout(TIMEOUT_MS)).onProfileServiceStateChanged(
                eq(HidDeviceService.class.getName()), eq(BluetoothAdapter.STATE_ON));
        mHidDeviceService = HidDeviceService.getHidDeviceService();
        Assert.assertNotNull(mHidDeviceService);
        Assert.assertNotNull(mHidDeviceService);


        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@@ -156,7 +160,7 @@ public class HidDeviceTest {
        filter.addAction(BluetoothHidDevice.ACTION_CONNECTION_STATE_CHANGED);
        filter.addAction(BluetoothHidDevice.ACTION_CONNECTION_STATE_CHANGED);
        mConnectionStateChangedReceiver = new ConnectionStateChangedReceiver();
        mConnectionStateChangedReceiver = new ConnectionStateChangedReceiver();
        mTargetContext.registerReceiver(mConnectionStateChangedReceiver, filter);
        mTargetContext.registerReceiver(mConnectionStateChangedReceiver, filter);
        reset(sHidDeviceNativeInterface);
        reset(sHidDeviceNativeInterface, sAdapterService);
    }
    }


    @After
    @After