public abstract class SweetUnitTest<A extends android.app.Activity>
extends AbstractTestClass
Activity
class you are testing against. You will then have to implement createActivity()
and pass in the newly created Activity
instance.Modifier and Type | Field and Description |
---|---|
A |
m_activity |
BleManagerConfig |
m_config |
BleManager |
m_manager |
IBluetoothManager |
mBluetoothManager |
IBluetoothServer |
mBluetoothServer |
Constructor and Description |
---|
SweetUnitTest() |
Modifier and Type | Method and Description |
---|---|
protected abstract A |
createActivity()
Subclasses must implement this method, and a valid, non-null Activity instance is expected.
|
BleManagerConfig |
getConfig()
Returns an instance of
BleManagerConfig . |
IBluetoothDevice |
getDeviceLayer(IBleDevice device)
Returns the current instance of
IBluetoothDevice . |
IBluetoothGatt |
getGattLayer(IBleDevice device)
Returns the current instance of
IBluetoothGatt . |
IBluetoothManager |
getManagerLayer()
Returns the current instance of
IBluetoothManager . |
IBluetoothServer |
getServerLayer(IBleManager mgr,
P_ServerHolder serverHolder)
Returns the current instance of
IBluetoothServer . |
protected int |
getTraceIndex()
Should return the index of the current stack trace that contains the test method.
|
protected BleManager |
initManager(BleManagerConfig config)
Initializes the
BleManager instance with the given BleManagerConfig instance. |
void |
setup()
This method is called before every test.
|
void |
tearDown()
This gets called after every test has run.
|
public IBluetoothManager mBluetoothManager
public IBluetoothServer mBluetoothServer
public BleManager m_manager
public BleManagerConfig m_config
public A extends android.app.Activity m_activity
protected abstract A createActivity()
public IBluetoothManager getManagerLayer()
IBluetoothManager
. If the instance is null
, then
a new instance of UnitTestBluetoothManager
will be created and used.public IBluetoothDevice getDeviceLayer(IBleDevice device)
IBluetoothDevice
. If the instance is null
, then
a new instance of UnitTestBluetoothDevice
will be created and used.public IBluetoothGatt getGattLayer(IBleDevice device)
IBluetoothGatt
. If the instance is null
, then
a new instance of UnitTestBluetoothGatt
will be created and used.public IBluetoothServer getServerLayer(IBleManager mgr, P_ServerHolder serverHolder)
IBluetoothServer
. If the instance is null
, then
a new instance of UnitTestBluetoothServer
will be created and used.public void setup() throws java.lang.Exception
Activity
instance is created,
from calling createActivity()
. The BleManager
instance is also initialized here
using initManager(BleManagerConfig)
, getConfig()
.java.lang.Exception
protected BleManager initManager(BleManagerConfig config)
BleManager
instance with the given BleManagerConfig
instance. This also
calls Util_Native.forceOn(BleManager)
, and onResume() on the Activity
instance.BleManager
instancepublic void tearDown() throws java.lang.Exception
BleManager.shutdown()
, and finish() on the
Activity
instance, as well as null-ing out all instance fields.java.lang.Exception
public BleManagerConfig getConfig()
BleManagerConfig
. Override this method to give a different instance
during test bring-up. This is called by setup()
, and the result is passed into initManager(BleManagerConfig)
.protected int getTraceIndex()