blob: a68b580364d364311569119cf2648c4bd6d30066 [file] [log] [blame]
package com.android.clockwork.bluetooth;
import android.bluetooth.BluetoothAdapter;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.shadow.api.Shadow;
/**
* Shadow class for {@link BluetoothAdapter}.
*
* Extended to allow for testing null adapters
*/
@Implements(BluetoothAdapter.class)
public class ShadowBluetoothAdapter extends org.robolectric.shadows.ShadowBluetoothAdapter {
private static BluetoothAdapter instanceForTest;
static boolean forceNull;
public static void setAdapter(BluetoothAdapter adapter) {
instanceForTest = adapter;
}
@Implementation
public static BluetoothAdapter getDefaultAdapter() {
if (instanceForTest == null) {
instanceForTest = Shadow.newInstanceOf(BluetoothAdapter.class);
}
if (forceNull) {
return null;
}
return instanceForTest;
}
}