Methods Summary |
---|
private static void | assertByteArrayEquals(byte[] b1, byte[] b2)
assertEquals(b1.length, b2.length);
for (int i = 0; i < b1.length; i++) {
assertEquals(b1[i], b2[i]);
}
|
protected void | setUp()
super.setUp();
mContext = getInstrumentation().getTargetContext();
mAdapterExtras = NfcAdapterExtras.get(NfcAdapter.getDefaultAdapter(mContext));
mEe = mAdapterExtras.getEmbeddedExecutionEnvironment();
|
public void | testDisableEe()
mAdapterExtras.setCardEmulationRoute(
new CardEmulationRoute(CardEmulationRoute.ROUTE_OFF, null));
CardEmulationRoute newRoute = mAdapterExtras.getCardEmulationRoute();
assertEquals(CardEmulationRoute.ROUTE_OFF, newRoute.route);
assertNull(newRoute.nfcEe);
|
public void | testEnableEe()
mAdapterExtras.setCardEmulationRoute(
new CardEmulationRoute(CardEmulationRoute.ROUTE_ON_WHEN_SCREEN_ON, mEe));
CardEmulationRoute newRoute = mAdapterExtras.getCardEmulationRoute();
assertEquals(CardEmulationRoute.ROUTE_ON_WHEN_SCREEN_ON, newRoute.route);
assertEquals(mEe, newRoute.nfcEe);
|
public void | testSendCardManagerApdu()
mEe.open();
try {
byte[] out = mEe.transceive(SELECT_CARD_MANAGER_COMMAND);
assertTrue(out.length >= SELECT_CARD_MANAGER_RESPONSE.length);
byte[] trailing = Arrays.copyOfRange(out,
out.length - SELECT_CARD_MANAGER_RESPONSE.length,
out.length);
assertByteArrayEquals(SELECT_CARD_MANAGER_RESPONSE, trailing);
} finally {
mEe.close();
}
|
public void | testSendCardManagerApduMultiple()
for (int i=0; i<10; i++) {
try {
mEe.open();
try {
byte[] out = mEe.transceive(SELECT_CARD_MANAGER_COMMAND);
byte[] trailing = Arrays.copyOfRange(out,
out.length - SELECT_CARD_MANAGER_RESPONSE.length,
out.length);
} finally {
try {Thread.sleep(1000);} catch (InterruptedException e) {}
mEe.close();
}
} catch (IOException e) {}
}
testSendCardManagerApdu();
|