Java Examples for android.test.suitebuilder.annotation.MediumTest
The following java examples will help you to understand the usage of android.test.suitebuilder.annotation.MediumTest. These source code samples are taken from different open source projects.
Example 1
Project: droolsjbpm-integration-master File: DroolsActivityActivityTest.java View source code |
/**
* This test demonstrates ways to exercise the Activity's life cycle.
*/
@MediumTest
public void testLifeCycleCreate() throws InterruptedException {
Activity activity = startActivity(mStartIntent, null, null);
// At this point, onCreate() has been called
getInstrumentation().callActivityOnStart(activity);
getInstrumentation().callActivityOnResume(activity);
assertNotNull("kiecontainer", ((DroolsActivity) activity).mContainer);
assertNotNull("kiebase", ((DroolsActivity) activity).mKieBase);
assertNotNull("kiesession", ((DroolsActivity) activity).kSession);
Button fireRulesButton = (Button) activity.findViewById(R.id.fireRules);
assertNotNull("fireRulesButton", fireRulesButton);
TextView log = (TextView) activity.findViewById(R.id.log);
fireRulesButton.performClick();
Thread.sleep(2000);
assertFalse(log.getText().toString().isEmpty());
getInstrumentation().callActivityOnPause(activity);
getInstrumentation().callActivityOnStop(activity);
}
Example 2
Project: SOCIETIES-Platform-master File: TestTrustClientHelper.java View source code |
@MediumTest
public void testServiceConfiguration() throws Exception {
this.testCompleted = false;
final CountDownLatch latch = new CountDownLatch(1);
final TrustClientHelper helper = new TrustClientHelper(super.getContext());
helper.setUpService(new IMethodCallback() {
/*
* @see org.societies.android.api.comms.IMethodCallback#returnException(java.lang.String)
*/
@Override
public void returnException(String exception) {
fail("setUpService returned exception: " + exception);
}
/*
* @see org.societies.android.api.comms.IMethodCallback#returnAction(java.lang.String)
*/
@Override
public void returnAction(String result) {
fail("setUpService returned action: " + result);
}
/*
* @see org.societies.android.api.comms.IMethodCallback#returnAction(boolean)
*/
@Override
public void returnAction(boolean resultFlag) {
assertTrue(resultFlag);
helper.tearDownService(new IMethodCallback() {
/*
* @see org.societies.android.api.comms.IMethodCallback#returnException(java.lang.String)
*/
@Override
public void returnException(String exception) {
fail("tearDownService returned exception: " + exception);
}
/*
* @see org.societies.android.api.comms.IMethodCallback#returnAction(java.lang.String)
*/
@Override
public void returnAction(String result) {
fail("tearDownService returned action: " + result);
}
/*
* @see org.societies.android.api.comms.IMethodCallback#returnAction(boolean)
*/
@Override
public void returnAction(boolean resultFlag) {
assertTrue(resultFlag);
TestTrustClientHelper.this.testCompleted = true;
latch.countDown();
}
});
}
});
latch.await(LATCH_TIME_OUT, TimeUnit.MILLISECONDS);
assertTrue(this.testCompleted);
}
Example 3
Project: WS171-frameworks-base-master File: StrictMathTest.java View source code |
/**
* @tests java.lang.StrictMath#random()
*/
@MediumTest
public void testRandom() {
// There isn't a place for these tests so just stick them here
assertEquals("Wrong value E", 4613303445314885481L, Double.doubleToLongBits(StrictMath.E));
assertEquals("Wrong value PI", 4614256656552045848L, Double.doubleToLongBits(StrictMath.PI));
for (int i = 500; i >= 0; i--) {
double d = StrictMath.random();
assertTrue("Generated number is out of range: " + d, d >= 0.0 && d < 1.0);
}
}
Example 4
Project: android-15-master File: StateMachineTest.java View source code |
@MediumTest
public void testStateMachine1() throws Exception {
StateMachine1 sm1 = new StateMachine1("sm1");
sm1.start();
if (sm1.isDbg())
Log.d(TAG, "testStateMachine1 E");
synchronized (sm1) {
// Send two messages
sm1.sendMessage(TEST_CMD_1);
sm1.sendMessage(TEST_CMD_2);
try {
// wait for the messages to be handled
sm1.wait();
} catch (InterruptedException e) {
Log.e(TAG, "testStateMachine1: exception while waiting " + e.getMessage());
}
}
assertEquals(2, sm1.mEnterCount);
assertEquals(2, sm1.mExitCount);
assertTrue(sm1.getProcessedMessagesSize() == 2);
ProcessedMessageInfo pmi;
pmi = sm1.getProcessedMessageInfo(0);
assertEquals(TEST_CMD_1, pmi.getWhat());
assertEquals(sm1.mS1, pmi.getState());
assertEquals(sm1.mS1, pmi.getOriginalState());
pmi = sm1.getProcessedMessageInfo(1);
assertEquals(TEST_CMD_2, pmi.getWhat());
assertEquals(sm1.mS1, pmi.getState());
assertEquals(sm1.mS1, pmi.getOriginalState());
assertEquals(2, sm1.mEnterCount);
assertEquals(2, sm1.mExitCount);
if (sm1.isDbg())
Log.d(TAG, "testStateMachine1 X");
}
Example 5
Project: android-sdk-sources-for-api-level-23-master File: StateMachineTest.java View source code |
@MediumTest
public void testStateMachine1() throws Exception {
StateMachine1 sm1 = new StateMachine1("sm1");
sm1.start();
if (sm1.isDbg())
tlog("testStateMachine1 E");
synchronized (sm1) {
// Send two messages
sm1.sendMessage(TEST_CMD_1);
sm1.sendMessage(TEST_CMD_2);
try {
// wait for the messages to be handled
sm1.wait();
} catch (InterruptedException e) {
tloge("testStateMachine1: exception while waiting " + e.getMessage());
}
}
assertEquals(2, sm1.mEnterCount);
assertEquals(2, sm1.mExitCount);
assertEquals(2, sm1.getLogRecSize());
LogRec lr;
lr = sm1.getLogRec(0);
assertEquals(TEST_CMD_1, lr.getWhat());
assertEquals(sm1.mS1, lr.getState());
assertEquals(sm1.mS1, lr.getOriginalState());
lr = sm1.getLogRec(1);
assertEquals(TEST_CMD_2, lr.getWhat());
assertEquals(sm1.mS1, lr.getState());
assertEquals(sm1.mS1, lr.getOriginalState());
assertEquals(2, sm1.mEnterCount);
assertEquals(2, sm1.mExitCount);
if (sm1.isDbg())
tlog("testStateMachine1 X");
}
Example 6
Project: android_frameworks_base-master File: StateMachineTest.java View source code |
@MediumTest
public void testStateMachine1() throws Exception {
StateMachine1 sm1 = new StateMachine1("sm1");
sm1.start();
if (sm1.isDbg())
tlog("testStateMachine1 E");
synchronized (sm1) {
// Send two messages
sm1.sendMessage(TEST_CMD_1);
sm1.sendMessage(TEST_CMD_2);
try {
// wait for the messages to be handled
sm1.wait();
} catch (InterruptedException e) {
tloge("testStateMachine1: exception while waiting " + e.getMessage());
}
}
assertEquals(2, sm1.mEnterCount);
assertEquals(2, sm1.mExitCount);
assertEquals(2, sm1.getLogRecSize());
LogRec lr;
lr = sm1.getLogRec(0);
assertEquals(TEST_CMD_1, lr.getWhat());
assertEquals(sm1.mS1, lr.getState());
assertEquals(sm1.mS1, lr.getOriginalState());
lr = sm1.getLogRec(1);
assertEquals(TEST_CMD_2, lr.getWhat());
assertEquals(sm1.mS1, lr.getState());
assertEquals(sm1.mS1, lr.getOriginalState());
assertEquals(2, sm1.mEnterCount);
assertEquals(2, sm1.mExitCount);
if (sm1.isDbg())
tlog("testStateMachine1 X");
}
Example 7
Project: android_frameworks_base_telephony-master File: SMSDispatcherTest.java View source code |
@MediumTest
public void testCMT1() throws Exception {
SmsMessage sms;
SmsHeader header;
String[] lines = new String[2];
lines[0] = "+CMT: ,158";
lines[1] = "07914140279510F6440A8111110301003BF56080426101748A8C0B05040B" + "8423F000035502010106276170706C69636174696F6E2F766E642E776170" + "2E6D6D732D6D65737361676500AF848D0185B4848C8298524F347839776F" + "7547514D4141424C3641414141536741415A4B554141414141008D908918" + "802B31363530323438363137392F545950453D504C4D4E008A808E028000" + "88058103093A8083687474703A2F2F36";
sms = SmsMessage.newFromCMT(lines);
header = sms.getUserDataHeader();
assertNotNull(header);
assertNotNull(sms.getUserData());
assertNotNull(header.concatRef);
assertEquals(header.concatRef.refNumber, 85);
assertEquals(header.concatRef.msgCount, 2);
assertEquals(header.concatRef.seqNumber, 1);
assertEquals(header.concatRef.isEightBits, true);
assertNotNull(header.portAddrs);
assertEquals(header.portAddrs.destPort, 2948);
assertEquals(header.portAddrs.origPort, 9200);
assertEquals(header.portAddrs.areEightBits, false);
}
Example 8
Project: astrid-master File: SessionTests.java View source code |
@SmallTest
@MediumTest
@LargeTest
public void testActiveSessionChangeRegistration() {
final WaitForBroadcastReceiver receiver0 = new WaitForBroadcastReceiver();
final WaitForBroadcastReceiver receiver1 = new WaitForBroadcastReceiver();
final WaitForBroadcastReceiver receiver2 = new WaitForBroadcastReceiver();
final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getActivity());
try {
// Register these on the blocker thread so they will send
// notifications there as well. The notifications need to be on a
// different thread than the progress.
Runnable initialize0 = new Runnable() {
@Override
public void run() {
broadcastManager.registerReceiver(receiver0, getActiveSessionAllFilter());
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_SET));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_CLOSED));
broadcastManager.registerReceiver(receiver2, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver2, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_CLOSED));
}
};
runOnBlockerThread(initialize0, true);
// Verify all actions show up where they are expected
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1);
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
receiver0.waitForExpectedCalls();
// Remove receiver1 and verify actions continue to show up where
// expected
broadcastManager.unregisterReceiver(receiver1);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver2);
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
receiver0.waitForExpectedCalls();
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
receiver0.waitForExpectedCalls();
// Remove receiver0 and register receiver1 multiple times for one
// action
broadcastManager.unregisterReceiver(receiver0);
Runnable initialize1 = new Runnable() {
@Override
public void run() {
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
}
};
runOnBlockerThread(initialize1, true);
receiver1.incrementExpectCount(3);
receiver2.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
receiver1.waitForExpectedCalls();
receiver2.waitForExpectedCalls();
receiver2.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
receiver2.waitForExpectedCalls();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
closeBlockerAndAssertSuccess();
} finally {
broadcastManager.unregisterReceiver(receiver0);
broadcastManager.unregisterReceiver(receiver1);
broadcastManager.unregisterReceiver(receiver2);
Session.setActiveSession(null);
}
}
Example 9
Project: cmf-master File: ExecCommandTest.java View source code |
/**
* Method that performs a test over known executable program.
*
* @throws Exception If test failed
*/
@MediumTest
public void testExecWithPartialResult() throws Exception {
try {
// Create the test program
WriteExecutable writeCmd = CommandHelper.write(getContext(), EXEC_CMD, null, getConsole());
OutputStream os = writeCmd.createOutputStream();
os.write(EXEC_PROGRAM.getBytes());
writeCmd.end();
// Enable execute permission
CommandHelper.changePermissions(getContext(), EXEC_CMD, Permissions.fromOctalString(EXEC_CMD_PERMISSIONS), getConsole());
// Execute the test program
this.mNewPartialData = false;
CommandHelper.exec(getContext(), EXEC_CMD, new AsyncResultListener() {
@Override
public void onAsyncStart() {
/**NON BLOCK**/
}
@Override
public void onAsyncEnd(boolean cancelled) {
synchronized (ExecCommandTest.this.mSync) {
ExecCommandTest.this.mSync.notify();
}
}
@Override
public void onAsyncExitCode(int exitCode) {
}
@Override
public void onException(Exception cause) {
fail(String.valueOf(cause));
}
@Override
public void onPartialResult(Object results) {
ExecCommandTest.this.mNewPartialData = true;
}
}, getConsole());
synchronized (ExecCommandTest.this.mSync) {
ExecCommandTest.this.mSync.wait(15000L);
}
//$NON-NLS-1$
assertTrue("no new partial data", this.mNewPartialData);
} finally {
try {
CommandHelper.deleteFile(getContext(), EXEC_CMD, getConsole());
} catch (Exception e) {
}
}
}
Example 10
Project: CMFileManager-master File: ExecCommandTest.java View source code |
/**
* Method that performs a test over known executable program.
*
* @throws Exception If test failed
*/
@MediumTest
public void testExecWithPartialResult() throws Exception {
try {
// Create the test program
WriteExecutable writeCmd = CommandHelper.write(getContext(), EXEC_CMD, null, getConsole());
OutputStream os = writeCmd.createOutputStream();
os.write(EXEC_PROGRAM.getBytes());
writeCmd.end();
// Enable execute permission
CommandHelper.changePermissions(getContext(), EXEC_CMD, Permissions.fromOctalString(EXEC_CMD_PERMISSIONS), getConsole());
// Execute the test program
this.mNewPartialData = false;
CommandHelper.exec(getContext(), EXEC_CMD, new AsyncResultListener() {
@Override
public void onAsyncStart() {
/**NON BLOCK**/
}
@Override
public void onAsyncEnd(boolean cancelled) {
synchronized (ExecCommandTest.this.mSync) {
ExecCommandTest.this.mSync.notify();
}
}
@Override
public void onAsyncExitCode(int exitCode) {
}
@Override
public void onException(Exception cause) {
fail(String.valueOf(cause));
}
@Override
public void onPartialResult(Object results) {
ExecCommandTest.this.mNewPartialData = true;
}
}, getConsole());
synchronized (ExecCommandTest.this.mSync) {
ExecCommandTest.this.mSync.wait(15000L);
}
//$NON-NLS-1$
assertTrue("no new partial data", this.mNewPartialData);
} finally {
try {
CommandHelper.deleteFile(getContext(), EXEC_CMD, getConsole());
} catch (Exception e) {
}
}
}
Example 11
Project: copyit-app-master File: SessionTests.java View source code |
@SmallTest
@MediumTest
@LargeTest
public void testActiveSessionChangeRegistration() {
final WaitForBroadcastReceiver receiver0 = new WaitForBroadcastReceiver();
final WaitForBroadcastReceiver receiver1 = new WaitForBroadcastReceiver();
final WaitForBroadcastReceiver receiver2 = new WaitForBroadcastReceiver();
final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getActivity());
try {
// Register these on the blocker thread so they will send
// notifications there as well. The notifications need to be on a
// different thread than the progress.
Runnable initialize0 = new Runnable() {
@Override
public void run() {
broadcastManager.registerReceiver(receiver0, getActiveSessionAllFilter());
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_SET));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_CLOSED));
broadcastManager.registerReceiver(receiver2, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver2, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_CLOSED));
}
};
runOnBlockerThread(initialize0, true);
// Verify all actions show up where they are expected
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1);
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
receiver0.waitForExpectedCalls();
// Remove receiver1 and verify actions continue to show up where
// expected
broadcastManager.unregisterReceiver(receiver1);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver2);
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
receiver0.waitForExpectedCalls();
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
receiver0.waitForExpectedCalls();
// Remove receiver0 and register receiver1 multiple times for one
// action
broadcastManager.unregisterReceiver(receiver0);
Runnable initialize1 = new Runnable() {
@Override
public void run() {
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
}
};
runOnBlockerThread(initialize1, true);
receiver1.incrementExpectCount(3);
receiver2.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
receiver1.waitForExpectedCalls();
receiver2.waitForExpectedCalls();
receiver2.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
receiver2.waitForExpectedCalls();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
closeBlockerAndAssertSuccess();
} finally {
broadcastManager.unregisterReceiver(receiver0);
broadcastManager.unregisterReceiver(receiver1);
broadcastManager.unregisterReceiver(receiver2);
Session.setActiveSession(null);
}
}
Example 12
Project: facebook-sdk-sbt-master File: SessionTests.java View source code |
@SmallTest
@MediumTest
@LargeTest
public void testActiveSessionChangeRegistration() {
final WaitForBroadcastReceiver receiver0 = new WaitForBroadcastReceiver();
final WaitForBroadcastReceiver receiver1 = new WaitForBroadcastReceiver();
final WaitForBroadcastReceiver receiver2 = new WaitForBroadcastReceiver();
final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getActivity());
try {
// Register these on the blocker thread so they will send
// notifications there as well. The notifications need to be on a
// different thread than the progress.
Runnable initialize0 = new Runnable() {
@Override
public void run() {
broadcastManager.registerReceiver(receiver0, getActiveSessionAllFilter());
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_SET));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_CLOSED));
broadcastManager.registerReceiver(receiver2, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver2, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_CLOSED));
}
};
runOnBlockerThread(initialize0, true);
// Verify all actions show up where they are expected
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1);
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
receiver0.waitForExpectedCalls();
// Remove receiver1 and verify actions continue to show up where
// expected
broadcastManager.unregisterReceiver(receiver1);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver2);
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
receiver0.waitForExpectedCalls();
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
receiver0.waitForExpectedCalls();
// Remove receiver0 and register receiver1 multiple times for one
// action
broadcastManager.unregisterReceiver(receiver0);
Runnable initialize1 = new Runnable() {
@Override
public void run() {
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
}
};
runOnBlockerThread(initialize1, true);
receiver1.incrementExpectCount(3);
receiver2.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
receiver1.waitForExpectedCalls();
receiver2.waitForExpectedCalls();
receiver2.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
receiver2.waitForExpectedCalls();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
closeBlockerAndAssertSuccess();
} finally {
broadcastManager.unregisterReceiver(receiver0);
broadcastManager.unregisterReceiver(receiver1);
broadcastManager.unregisterReceiver(receiver2);
Session.setActiveSession(null);
}
}
Example 13
Project: FacebookImageShareIntent-master File: SessionTests.java View source code |
@SmallTest
@MediumTest
@LargeTest
public void testActiveSessionChangeRegistration() {
final WaitForBroadcastReceiver receiver0 = new WaitForBroadcastReceiver();
final WaitForBroadcastReceiver receiver1 = new WaitForBroadcastReceiver();
final WaitForBroadcastReceiver receiver2 = new WaitForBroadcastReceiver();
final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getActivity());
try {
// Register these on the blocker thread so they will send
// notifications there as well. The notifications need to be on a
// different thread than the progress.
Runnable initialize0 = new Runnable() {
@Override
public void run() {
broadcastManager.registerReceiver(receiver0, getActiveSessionAllFilter());
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_SET));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_CLOSED));
broadcastManager.registerReceiver(receiver2, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver2, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_CLOSED));
}
};
runOnBlockerThread(initialize0, true);
// Verify all actions show up where they are expected
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1);
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
receiver0.waitForExpectedCalls();
// Remove receiver1 and verify actions continue to show up where
// expected
broadcastManager.unregisterReceiver(receiver1);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver2);
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
receiver0.waitForExpectedCalls();
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
receiver0.waitForExpectedCalls();
// Remove receiver0 and register receiver1 multiple times for one
// action
broadcastManager.unregisterReceiver(receiver0);
Runnable initialize1 = new Runnable() {
@Override
public void run() {
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
}
};
runOnBlockerThread(initialize1, true);
receiver1.incrementExpectCount(3);
receiver2.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
receiver1.waitForExpectedCalls();
receiver2.waitForExpectedCalls();
receiver2.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
receiver2.waitForExpectedCalls();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
closeBlockerAndAssertSuccess();
} finally {
broadcastManager.unregisterReceiver(receiver0);
broadcastManager.unregisterReceiver(receiver1);
broadcastManager.unregisterReceiver(receiver2);
Session.setActiveSession(null);
}
}
Example 14
Project: FacebookLoginInAndroidUsingParse-master File: SessionTests.java View source code |
@SmallTest
@MediumTest
@LargeTest
public void testActiveSessionChangeRegistration() {
final WaitForBroadcastReceiver receiver0 = new WaitForBroadcastReceiver();
final WaitForBroadcastReceiver receiver1 = new WaitForBroadcastReceiver();
final WaitForBroadcastReceiver receiver2 = new WaitForBroadcastReceiver();
final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getActivity());
try {
// Register these on the blocker thread so they will send
// notifications there as well. The notifications need to be on a
// different thread than the progress.
Runnable initialize0 = new Runnable() {
@Override
public void run() {
broadcastManager.registerReceiver(receiver0, getActiveSessionAllFilter());
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_SET));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_CLOSED));
broadcastManager.registerReceiver(receiver2, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver2, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_CLOSED));
}
};
runOnBlockerThread(initialize0, true);
// Verify all actions show up where they are expected
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1);
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
receiver0.waitForExpectedCalls();
// Remove receiver1 and verify actions continue to show up where
// expected
broadcastManager.unregisterReceiver(receiver1);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver2);
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
receiver0.waitForExpectedCalls();
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
receiver0.waitForExpectedCalls();
// Remove receiver0 and register receiver1 multiple times for one
// action
broadcastManager.unregisterReceiver(receiver0);
Runnable initialize1 = new Runnable() {
@Override
public void run() {
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
}
};
runOnBlockerThread(initialize1, true);
receiver1.incrementExpectCount(3);
receiver2.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
receiver1.waitForExpectedCalls();
receiver2.waitForExpectedCalls();
receiver2.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
receiver2.waitForExpectedCalls();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
closeBlockerAndAssertSuccess();
} finally {
broadcastManager.unregisterReceiver(receiver0);
broadcastManager.unregisterReceiver(receiver1);
broadcastManager.unregisterReceiver(receiver2);
Session.setActiveSession(null);
}
}
Example 15
Project: folio100_frameworks_base-master File: PackageManagerTests.java View source code |
/*
* Install a package on internal flash via PackageManager install flag. Replace
* the package via flag to install on sdcard. Make sure the new flag overrides
* the old install location.
*/
@MediumTest
public void testReplaceFlagInternalSdcard() {
int iFlags = 0;
int rFlags = PackageManager.INSTALL_EXTERNAL;
InstallParams ip = sampleInstallFromRawResource(iFlags, false);
GenericReceiver receiver = new ReplaceReceiver(ip.pkg.packageName);
int replaceFlags = rFlags | PackageManager.INSTALL_REPLACE_EXISTING;
try {
assertEquals(invokeInstallPackage(ip.packageURI, replaceFlags, receiver), true);
assertInstall(ip.pkg, rFlags, ip.pkg.installLocation);
} catch (Exception e) {
failStr("Failed with exception : " + e);
} finally {
cleanUpInstall(ip);
}
}
Example 16
Project: frameworks_base_disabled-master File: StateMachineTest.java View source code |
@MediumTest
public void testStateMachine1() throws Exception {
StateMachine1 sm1 = new StateMachine1("sm1");
sm1.start();
if (sm1.isDbg())
Log.d(TAG, "testStateMachine1 E");
synchronized (sm1) {
// Send two messages
sm1.sendMessage(TEST_CMD_1);
sm1.sendMessage(TEST_CMD_2);
try {
// wait for the messages to be handled
sm1.wait();
} catch (InterruptedException e) {
Log.e(TAG, "testStateMachine1: exception while waiting " + e.getMessage());
}
}
assertEquals(2, sm1.mEnterCount);
assertEquals(2, sm1.mExitCount);
assertTrue(sm1.getProcessedMessagesSize() == 2);
ProcessedMessageInfo pmi;
pmi = sm1.getProcessedMessageInfo(0);
assertEquals(TEST_CMD_1, pmi.getWhat());
assertEquals(sm1.mS1, pmi.getState());
assertEquals(sm1.mS1, pmi.getOriginalState());
pmi = sm1.getProcessedMessageInfo(1);
assertEquals(TEST_CMD_2, pmi.getWhat());
assertEquals(sm1.mS1, pmi.getState());
assertEquals(sm1.mS1, pmi.getOriginalState());
assertEquals(2, sm1.mEnterCount);
assertEquals(2, sm1.mExitCount);
if (sm1.isDbg())
Log.d(TAG, "testStateMachine1 X");
}
Example 17
Project: frameworks_opt-master File: ServiceStateTrackerTest.java View source code |
@Test
@MediumTest
public void testSetRadioPowerFromCarrier() {
// Carrier disable radio power
sst.setRadioPowerFromCarrier(false);
waitForMs(100);
assertFalse(mSimulatedCommands.getRadioState().isOn());
assertTrue(sst.getDesiredPowerState());
assertFalse(sst.getPowerStateFromCarrier());
// User toggle radio power will not overrides carrier settings
sst.setRadioPower(true);
waitForMs(100);
assertFalse(mSimulatedCommands.getRadioState().isOn());
assertTrue(sst.getDesiredPowerState());
assertFalse(sst.getPowerStateFromCarrier());
// Carrier re-enable radio power
sst.setRadioPowerFromCarrier(true);
waitForMs(100);
assertTrue(mSimulatedCommands.getRadioState().isOn());
assertTrue(sst.getDesiredPowerState());
assertTrue(sst.getPowerStateFromCarrier());
// User toggle radio power off (airplane mode) and set carrier on
sst.setRadioPower(false);
sst.setRadioPowerFromCarrier(true);
waitForMs(100);
assertFalse(mSimulatedCommands.getRadioState().isOn());
assertFalse(sst.getDesiredPowerState());
assertTrue(sst.getPowerStateFromCarrier());
}
Example 18
Project: j2objc-master File: SpannableTest.java View source code |
@MediumTest
public void testGetSpans() {
Spannable spannable = newSpannableWithText("abcdef");
Object emptySpan = new Object();
spannable.setSpan(emptySpan, 1, 1, 0);
Object unemptySpan = new Object();
spannable.setSpan(unemptySpan, 1, 2, 0);
Object[] spans;
// Empty spans are included when they merely abut the query region
// but other spans are not, unless the query region is empty, in
// in which case any abutting spans are returned.
spans = spannable.getSpans(0, 1, Object.class);
MoreAsserts.assertEquals(new Object[] { emptySpan }, spans);
spans = spannable.getSpans(0, 2, Object.class);
MoreAsserts.assertEquals(new Object[] { emptySpan, unemptySpan }, spans);
spans = spannable.getSpans(1, 2, Object.class);
MoreAsserts.assertEquals(new Object[] { emptySpan, unemptySpan }, spans);
spans = spannable.getSpans(2, 2, Object.class);
MoreAsserts.assertEquals(new Object[] { unemptySpan }, spans);
}
Example 19
Project: Notepad-master File: DBUpgradeTest.java View source code |
@MediumTest
public void testExistingUpgrade() {
// First delete test databases if they exist
context.deleteDatabase(PREFIX + LegacyDBHelper.LEGACY_DATABASE_NAME);
context.deleteDatabase(PREFIX + DatabaseHandler.DATABASE_NAME);
final SQLiteDatabase legacyDB = new LegacyDBHelper(context, PREFIX).getWritableDatabase();
initializeDB(legacyDB);
// Check that things exist
Cursor c = DatabaseHandler.getLegacyLists(legacyDB);
assertEquals("LegacyDB not correct for tests", numOfLegacyLists, c.getCount());
c.close();
c = DatabaseHandler.getLegacyNotes(legacyDB);
assertEquals("LegacyDB not correct for tests", numOfLegacyLists * numOfLegacyNotes, c.getCount());
c.close();
c = DatabaseHandler.getLegacyNotifications(legacyDB);
assertEquals("LegacyDB not correct for tests", numOfLegacyLists * numOfLegacyNotes, c.getCount());
c.close();
// Check that new database correctly converts old
final SQLiteDatabase db = new DatabaseHandler(context, PREFIX).getReadableDatabase();
c = db.query(TaskList.TABLE_NAME, TaskList.Columns.FIELDS, null, null, null, null, null);
assertEquals("Unexpected amount of lists returned", numOfLegacyLists, c.getCount());
// TODO Examine details
c.close();
c = db.query(Task.TABLE_NAME, Task.Columns.FIELDS, null, null, null, null, null);
assertEquals("Incorrect number of notes converted", numOfLegacyLists * numOfLegacyNotes, c.getCount());
// TODO examine details
c.close();
c = db.query(Notification.TABLE_NAME, Notification.Columns.FIELDS, null, null, null, null, null);
assertEquals("Incorrect number of notifications converted", numOfLegacyLists * numOfLegacyNotes, c.getCount());
// TODO examine details
c.close();
db.close();
legacyDB.close();
assertTrue("Could not delete database", context.deleteDatabase(PREFIX + LegacyDBHelper.LEGACY_DATABASE_NAME));
assertTrue("Could not delete database", context.deleteDatabase(PREFIX + DatabaseHandler.DATABASE_NAME));
}
Example 20
Project: Omni-Notes-master File: MainActivityTest.java View source code |
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@MediumTest
public void testRemoveExistentDetailFragment() {
MainActivity mainActivity = getActivity();
assertNotNull(mainActivity);
assertSame(MainActivity.class, mainActivity.getClass());
FragmentManager fm = mainActivity.getSupportFragmentManager();
Fragment f = new TestFragment("tf1");
fm.beginTransaction().add(f, "tf1").commit();
}
Example 21
Project: platform_frameworks_base-master File: StateMachineTest.java View source code |
@MediumTest
public void testStateMachine1() throws Exception {
StateMachine1 sm1 = new StateMachine1("sm1");
sm1.start();
if (sm1.isDbg())
tlog("testStateMachine1 E");
synchronized (sm1) {
// Send two messages
sm1.sendMessage(TEST_CMD_1);
sm1.sendMessage(TEST_CMD_2);
try {
// wait for the messages to be handled
sm1.wait();
} catch (InterruptedException e) {
tloge("testStateMachine1: exception while waiting " + e.getMessage());
}
}
assertEquals(2, sm1.mEnterCount);
assertEquals(2, sm1.mExitCount);
assertEquals(2, sm1.getLogRecSize());
LogRec lr;
lr = sm1.getLogRec(0);
assertEquals(TEST_CMD_1, lr.getWhat());
assertEquals(sm1.mS1, lr.getState());
assertEquals(sm1.mS1, lr.getOriginalState());
lr = sm1.getLogRec(1);
assertEquals(TEST_CMD_2, lr.getWhat());
assertEquals(sm1.mS1, lr.getState());
assertEquals(sm1.mS1, lr.getOriginalState());
assertEquals(2, sm1.mEnterCount);
assertEquals(2, sm1.mExitCount);
if (sm1.isDbg())
tlog("testStateMachine1 X");
}
Example 22
Project: ProguardPack-master File: MyFirstTestActivityTest.java View source code |
@MediumTest
public void testClickMeButton_layout() {
final View decorView = mActivity.getWindow().getDecorView();
ViewAsserts.assertOnScreen(decorView, mBtn);
final ViewGroup.LayoutParams layoutParams = mBtn.getLayoutParams();
assertNotNull(layoutParams);
assertEquals(layoutParams.width, RelativeLayout.LayoutParams.WRAP_CONTENT);
assertEquals(layoutParams.height, WindowManager.LayoutParams.WRAP_CONTENT);
}
Example 23
Project: property-db-master File: StateMachineTest.java View source code |
@MediumTest
public void testStateMachine1() throws Exception {
StateMachine1 sm1 = new StateMachine1("sm1");
sm1.start();
if (sm1.isDbg())
Log.d(TAG, "testStateMachine1 E");
synchronized (sm1) {
// Send two messages
sm1.sendMessage(TEST_CMD_1);
sm1.sendMessage(TEST_CMD_2);
try {
// wait for the messages to be handled
sm1.wait();
} catch (InterruptedException e) {
Log.e(TAG, "testStateMachine1: exception while waiting " + e.getMessage());
}
}
assertEquals(2, sm1.mEnterCount);
assertEquals(2, sm1.mExitCount);
assertEquals(2, sm1.getLogRecSize());
LogRec lr;
lr = sm1.getLogRec(0);
assertEquals(TEST_CMD_1, lr.getWhat());
assertEquals(sm1.mS1, lr.getState());
assertEquals(sm1.mS1, lr.getOriginalState());
lr = sm1.getLogRec(1);
assertEquals(TEST_CMD_2, lr.getWhat());
assertEquals(sm1.mS1, lr.getState());
assertEquals(sm1.mS1, lr.getOriginalState());
assertEquals(2, sm1.mEnterCount);
assertEquals(2, sm1.mExitCount);
if (sm1.isDbg())
Log.d(TAG, "testStateMachine1 X");
}
Example 24
Project: soas-master File: PhotosListActivityEspressoTest.java View source code |
@MediumTest
public void testLoadingPhotos() throws InterruptedException {
VolleyIdlingResource volleyResources;
try {
volleyResources = new VolleyIdlingResource(mActivity, "VolleyCalls");
Espresso.registerIdlingResources(volleyResources);
} catch (SecurityExceptionNoSuchFieldException | e) {
fail(e.getMessage());
}
Espresso.onView(ViewMatchers.withId(android.R.id.list)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
}
Example 25
Project: talkback-master File: CursorControllerAppTest.java View source code |
@MediumTest
public void testGetCursorOrInputCursor() {
setContentView(R.layout.text_activity);
AccessibilityNodeInfoCompat usernameEditText = getNodeForId(R.id.username);
mCursorController.setCursor(usernameEditText);
waitForAccessibilityIdleSync();
// Click to open the keyboard.
mCursorController.clickCurrent();
waitForAccessibilityIdleSync();
// Remove accessibility focus from the text field. Input focus should stay, however.
mCursorController.clearCursor();
waitForAccessibilityIdleSync();
assertEquals(usernameEditText, mCursorController.getCursorOrInputCursor());
}
Example 26
Project: TopRate_Materialised-master File: CardFilmDetailsActivityTest.java View source code |
@MediumTest
public void testTxtTitleMockInitial() {
txtTitle = (TextView) getActivity().findViewById(R.id.txtTitle);
final String expected = getActivity().getResources().getString(R.string.mock_info_title);
final String actual = txtTitle.getText().toString();
assertEquals("mCardFilmDetailsActivity contains wrong text", expected, actual);
}
Example 27
Project: totoro-master File: SessionTests.java View source code |
@SmallTest
@MediumTest
@LargeTest
public void testActiveSessionChangeRegistration() {
final WaitForBroadcastReceiver receiver0 = new WaitForBroadcastReceiver();
final WaitForBroadcastReceiver receiver1 = new WaitForBroadcastReceiver();
final WaitForBroadcastReceiver receiver2 = new WaitForBroadcastReceiver();
final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getActivity());
try {
// Register these on the blocker thread so they will send
// notifications there as well. The notifications need to be on a
// different thread than the progress.
Runnable initialize0 = new Runnable() {
@Override
public void run() {
broadcastManager.registerReceiver(receiver0, getActiveSessionAllFilter());
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_SET));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_CLOSED));
broadcastManager.registerReceiver(receiver2, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver2, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_CLOSED));
}
};
runOnBlockerThread(initialize0, true);
// Verify all actions show up where they are expected
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver1);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver1);
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
receiver0.waitForExpectedCalls();
// Remove receiver1 and verify actions continue to show up where
// expected
broadcastManager.unregisterReceiver(receiver1);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver2);
WaitForBroadcastReceiver.incrementExpectCounts(receiver0, receiver2);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
WaitForBroadcastReceiver.waitForExpectedCalls(receiver0, receiver2);
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
receiver0.waitForExpectedCalls();
receiver0.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
receiver0.waitForExpectedCalls();
// Remove receiver0 and register receiver1 multiple times for one
// action
broadcastManager.unregisterReceiver(receiver0);
Runnable initialize1 = new Runnable() {
@Override
public void run() {
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
broadcastManager.registerReceiver(receiver1, getActiveSessionFilter(Session.ACTION_ACTIVE_SESSION_OPENED));
}
};
runOnBlockerThread(initialize1, true);
receiver1.incrementExpectCount(3);
receiver2.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_OPENED);
receiver1.waitForExpectedCalls();
receiver2.waitForExpectedCalls();
receiver2.incrementExpectCount();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_CLOSED);
receiver2.waitForExpectedCalls();
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_SET);
Session.postActiveSessionAction(Session.ACTION_ACTIVE_SESSION_UNSET);
closeBlockerAndAssertSuccess();
} finally {
broadcastManager.unregisterReceiver(receiver0);
broadcastManager.unregisterReceiver(receiver1);
broadcastManager.unregisterReceiver(receiver2);
Session.setActiveSession(null);
}
}
Example 28
Project: WALA-Mobile-master File: CallGraphServiceTest.java View source code |
@MediumTest
public void testCallGraph() throws RemoteException {
Intent startIntent = makeIntent();
IBinder service = bindService(startIntent);
Parcel callData = Parcel.obtain();
Parcel returnData = Parcel.obtain();
String app = "/data/test/com.ibm.wala.core.testdata_1.0.0a.dex";
callData.writeString(app);
callData.writeString("LdynamicCG/MainClass");
service.transact(CallGraphService.MAIN_CALL_GRAPH, callData, returnData, 0);
returnData.setDataPosition(0);
@SuppressWarnings("unchecked") SlowSparseNumberedGraph<Pair<String, Integer>> CG = (SlowSparseNumberedGraph<Pair<String, Integer>>) returnData.readSerializable();
Log.i("CallGraphServiceTest", CG.toString());
callData.recycle();
returnData.recycle();
assert CG != null;
}
Example 29
Project: cs282-master File: DownloadServiceTest.java View source code |
/**
* Post messages and verify that they meet their appropriate fates.
*/
@TestPreamble(activate = "1.6.3", expire = "unlimited", onSmoke = true, onComponent = {}, onUnit = {})
@MediumTest
public void testRequest() {
logger.info("test postal : start");
try {
this.startUp("dist-policy-single-rule.xml");
} catch (Exception ex) {
Assert.fail("test failed, could not start environment " + ex.getLocalizedMessage());
}
final MockChannel mockChannel = MockChannel.getInstance("mock", this.service);
logger.info("postal : exercise the distributor");
Assert.assertNotNull("mock channel not available", mockChannel);
final MockNetworkStack network = mockChannel.mockNetworkStack;
final ByteBuffer sentBuf = network.getSent();
Assert.assertNotNull("not received into send buffer", sentBuf);
}
Example 30
Project: disconnected-content-explorer-android-master File: ReportTest.java View source code |
@MediumTest
public void testWritesAndReadsToParcel() {
Report r = new Report();
r.setDescription("test parcelling");
r.setEnabled(true);
r.setError("none");
r.setId("1234");
r.setLat(20.0);
r.setLon(100.0);
r.setPath(new File(Environment.getExternalStorageDirectory(), "test/reports/test_report"));
r.setSourceFile(Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "test/report.zip")));
r.setThumbnail("thumbnail");
r.setTitle("Test Report");
Parcel parcel = Parcel.obtain();
r.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
Report fromParcel = Report.CREATOR.createFromParcel(parcel);
assertThat(fromParcel.getDescription(), equalTo(r.getDescription()));
assertThat(fromParcel.getError(), equalTo(r.getError()));
assertThat(fromParcel.getFileExtension(), equalTo(r.getFileExtension()));
assertThat(fromParcel.getSourceFileName(), equalTo(r.getSourceFileName()));
assertThat(fromParcel.getId(), equalTo(r.getId()));
assertThat(fromParcel.getLat(), equalTo(r.getLat()));
assertThat(fromParcel.getLon(), equalTo(r.getLon()));
assertThat(fromParcel.getPath(), equalTo(r.getPath()));
assertThat(fromParcel.getSourceFile(), equalTo(r.getSourceFile()));
assertThat(fromParcel.getThumbnail(), equalTo(r.getThumbnail()));
assertThat(fromParcel.getTitle(), equalTo(r.getTitle()));
}
Example 31
Project: mage-android-master File: LayoutBakerTest.java View source code |
@MediumTest
public void testDynamicLayoutMapping() {
String form = "{\n" + " \"variantField\": null,\n" + " \"fields\": [\n" + " {\n" + " \"id\": 1,\n" + " \"title\": \"Date\",\n" + " \"type\": \"date\",\n" + " \"required\": true,\n" + " \"name\": \"timestamp\",\n" + " \"choices\": []\n" + " },\n" + " {\n" + " \"id\": 2,\n" + " \"title\": \"Location\",\n" + " \"type\": \"geometry\",\n" + " \"required\": true,\n" + " \"name\": \"geometry\",\n" + " \"choices\": []\n" + " },\n" + " {\n" + " \"id\": 3,\n" + " \"title\": \"Type\",\n" + " \"type\": \"dropdown\",\n" + " \"required\": true,\n" + " \"name\": \"type\",\n" + " \"choices\": [\n" + " {\n" + " \"id\": 0,\n" + " \"title\": \"awesome\",\n" + " \"value\": 0\n" + " }\n" + " ]\n" + " }\n" + " ]\n" + " }";
JsonObject dynamicFormJson = new JsonParser().parse(form).getAsJsonObject();
List<View> controls = LayoutBaker.createControlsFromJson(activity, LayoutBaker.ControlGenerationType.VIEW, dynamicFormJson);
Collection<ObservationProperty> properties = new ArrayList<ObservationProperty>();
properties.add(new ObservationProperty("type", "awesome"));
properties.add(new ObservationProperty("timestamp", DateFormatFactory.ISO8601().format(new Date())));
Observation o = new Observation(null, properties, null, null, null);
final Map<String, ObservationProperty> propertiesMapBefore = o.getPropertiesMap();
LinearLayout ll = new LinearLayout(activity);
// add dynamic controls to view
LayoutBaker.populateLayoutWithControls(ll, controls);
// check two way mapping
LayoutBaker.populateLayoutFromMap(ll, LayoutBaker.ControlGenerationType.VIEW, propertiesMapBefore);
final Map<String, ObservationProperty> propertiesMapAfter = LayoutBaker.populateMapFromLayout(ll);
for (String key : propertiesMapBefore.keySet()) {
Serializable before = propertiesMapBefore.get(key).getValue();
Serializable after = propertiesMapAfter.get(key).getValue();
assertEquals(before, after);
}
}
Example 32
Project: spring-android-master File: AbstractHttpRequestFactoryTestCase.java View source code |
@MediumTest
public void testStatus() throws Exception {
URI uri = new URI(baseUrl + "/status/notfound");
ClientHttpRequest request = factory.createRequest(uri, HttpMethod.GET);
assertEquals("Invalid HTTP method", HttpMethod.GET, request.getMethod());
assertEquals("Invalid HTTP URI", uri, request.getURI());
ClientHttpResponse response = request.execute();
try {
assertEquals("Invalid status code", HttpStatus.NOT_FOUND, response.getStatusCode());
} finally {
response.close();
}
}
Example 33
Project: standup-timer-master File: StandupTimerTest.java View source code |
@MediumTest
public void test_onPause_saves_state_if_not_finished() {
a.setRemainingMeetingSeconds(123);
a.setTotalParticipants(456);
a.setCurrentIndividualStatusSeconds(43);
a.setMeetingStartTime(123456789);
a.setIndividualStatusEndTime(666777888);
a.setQuickestStatus(789);
a.setLongestStatus(999);
a.onPause();
a.loadState();
assertEquals(123, a.getRemainingMeetingSeconds());
assertEquals(456, a.getTotalParticipants());
assertEquals(43, a.getCurrentIndividualStatusSeconds());
assertEquals(123456789, a.getMeetingStartTime());
assertEquals(123456789, a.getIndividualStatusStartTime());
assertEquals(666777888, a.getIndividualStatusEndTime());
assertEquals(789, a.getQuickestStatus());
assertEquals(999, a.getLongestStatus());
}
Example 34
Project: 360-Engine-for-Android-master File: FetchNativeContactsTest.java View source code |
@MediumTest
@Suppress
public // Breaks tests
void testRunWithOneNewContact() {
final String fnName = "testRunWithOneNewContact";
Log.i(LOG_TAG, "***** EXECUTING " + fnName + " *****");
mTestStep = 1;
startSubTest(fnName, "Checking people database is empty");
Cursor peopleCursor = mDb.openContactSummaryCursor(null, null);
assertEquals(0, peopleCursor.getCount());
assertTrue(Settings.ENABLE_UPDATE_NATIVE_CONTACTS);
startSubTest(fnName, "Checking native database is empty");
Cursor nativeCursor = mCr.query(People.CONTENT_URI, new String[] { People._ID, People.NAME, People.NOTES }, null, null, null);
assertEquals(0, nativeCursor.getCount());
startSubTest(fnName, "Add one dummy native contact");
ContentValues peopleValues = new ContentValues();
peopleValues.put(Contacts.People.NAME, ADD_CONTACT_TEST_NAME);
peopleValues.put(Contacts.People.NOTES, ADD_CONTACT_TEST_NOTE);
Uri personUri1 = mCr.insert(Contacts.People.CONTENT_URI, peopleValues);
assertTrue("Unable to insert contact into native people table", personUri1 != null);
final long personId = ContentUris.parseId(personUri1);
ContentValues phoneValues = new ContentValues();
phoneValues.put(Contacts.Phones.PERSON_ID, personId);
phoneValues.put(Contacts.Phones.NUMBER, ADD_PHONE_TEST1);
phoneValues.put(Contacts.Phones.TYPE, ADD_PHONE_TYPE_TEST1);
Uri phoneUri1 = mCr.insert(Contacts.Phones.CONTENT_URI, phoneValues);
assertTrue("Unable to insert contact into native phone table 1", phoneUri1 != null);
final long phoneId1 = (int) ContentUris.parseId(phoneUri1);
phoneValues.put(Contacts.Phones.NUMBER, ADD_PHONE_TEST2);
phoneValues.put(Contacts.Phones.TYPE, ADD_PHONE_TYPE_TEST2);
phoneValues.put(Contacts.Phones.ISPRIMARY, 1);
Uri phoneUri2 = mCr.insert(Contacts.Phones.CONTENT_URI, phoneValues);
assertTrue("Unable to insert contact into native phone table 2", phoneUri2 != null);
final long phoneId2 = ContentUris.parseId(phoneUri2);
phoneValues.put(Contacts.Phones.NUMBER, ADD_PHONE_TEST3);
phoneValues.put(Contacts.Phones.TYPE, ADD_PHONE_TYPE_TEST3);
phoneValues.remove(Contacts.Phones.ISPRIMARY);
Uri phoneUri3 = mCr.insert(Contacts.Phones.CONTENT_URI, phoneValues);
assertTrue("Unable to insert contact into native phone table 3", phoneUri3 != null);
final long phoneId3 = ContentUris.parseId(phoneUri3);
ContentValues cmValues = new ContentValues();
cmValues.put(Contacts.ContactMethods.PERSON_ID, personId);
cmValues.put(Contacts.ContactMethods.DATA, ADD_CM_TEST1);
cmValues.put(Contacts.ContactMethods.TYPE, ADD_CM_TYPE_TEST1);
cmValues.put(Contacts.ContactMethods.KIND, ADD_CM_KIND_TEST1);
Uri cmUri1 = mCr.insert(Contacts.ContactMethods.CONTENT_URI, cmValues);
assertTrue("Unable to insert contact into native contact methods table 1", cmUri1 != null);
final long cmId1 = ContentUris.parseId(cmUri1);
cmValues.put(Contacts.ContactMethods.DATA, ADD_CM_TEST2);
cmValues.put(Contacts.ContactMethods.TYPE, ADD_CM_TYPE_TEST2);
cmValues.put(Contacts.ContactMethods.KIND, ADD_CM_KIND_TEST2);
cmValues.put(Contacts.ContactMethods.ISPRIMARY, 1);
Uri cmUri2 = mCr.insert(Contacts.ContactMethods.CONTENT_URI, cmValues);
assertTrue("Unable to insert contact into native contact methods table 2", cmUri2 != null);
final long cmId2 = ContentUris.parseId(cmUri2);
ContentValues orgValues = new ContentValues();
orgValues.put(Contacts.Organizations.PERSON_ID, personId);
orgValues.put(Contacts.Organizations.COMPANY, ADD_ORG_COMPANY_TEST1);
orgValues.put(Contacts.Organizations.TITLE, ADD_ORG_TITLE_TEST1);
orgValues.put(Contacts.Organizations.TYPE, ADD_ORG_TYPE_TEST1);
orgValues.put(Contacts.Organizations.LABEL, ADD_ORG_LABEL_TEST1);
Uri orgUri = mCr.insert(Contacts.Organizations.CONTENT_URI, orgValues);
assertTrue("Unable to insert contact into native organizations table 1", orgUri != null);
final long orgId1 = ContentUris.parseId(orgUri);
startSubTest(fnName, "Running processor");
runProcessor();
startSubTest(fnName, "Checking contact has been synced to people");
peopleCursor.requery();
assertEquals(1, peopleCursor.getCount());
assertTrue(peopleCursor.moveToFirst());
ContactSummary summary = ContactSummaryTable.getQueryData(peopleCursor);
assertTrue(summary != null);
Contact newContact = new Contact();
ServiceStatus status = mDb.fetchContact(summary.localContactID, newContact);
assertEquals(ServiceStatus.SUCCESS, status);
boolean doneName = false;
boolean doneNickname = false;
boolean doneNote = false;
boolean donePhone1 = false;
boolean donePhone2 = false;
boolean donePhone3 = false;
boolean doneCm1 = false;
boolean doneCm2 = false;
boolean doneOrg1 = false;
boolean doneTitle1 = false;
assertTrue(newContact.synctophone);
assertEquals(personId, newContact.nativeContactId.longValue());
assertEquals(personId, summary.nativeContactId.longValue());
for (ContactDetail detail : newContact.details) {
assertEquals(personId, detail.nativeContactId.longValue());
detail.syncNativeContactId = fetchSyncNativeId(detail.localDetailID);
assertEquals("No sync marker, ID = " + detail.nativeDetailId + ", key = " + detail.key, Integer.valueOf(-1), detail.syncNativeContactId);
Integer detailId = detail.nativeDetailId;
assertTrue(detailId != null);
switch(detail.key) {
case VCARD_NAME:
assertEquals(personId, detailId.longValue());
assertEquals(ADD_CONTACT_TEST_NAME, detail.nativeVal1);
VCardHelper.Name name = detail.getName();
assertTrue(name != null);
assertEquals(ADD_CONTACT_TEST_NAME, name.toString());
doneName = true;
break;
case VCARD_NICKNAME:
assertEquals(personId, detailId.longValue());
assertEquals(ADD_CONTACT_TEST_NAME, detail.nativeVal1);
assertEquals(ADD_CONTACT_TEST_NAME, detail.getValue());
doneNickname = true;
break;
case VCARD_NOTE:
assertEquals(personId, detailId.longValue());
assertEquals(ADD_CONTACT_TEST_NOTE, detail.nativeVal1);
assertEquals(ADD_CONTACT_TEST_NOTE, detail.getValue());
doneNote = true;
break;
case VCARD_PHONE:
if (detailId.longValue() == phoneId1) {
donePhone1 = true;
assertEquals(ADD_PHONE_TEST1, detail.nativeVal1);
assertEquals(ADD_PHONE_TEST1, detail.getValue());
assertEquals(ADD_PHONE_PEOPLE_TYPE_TEST1, detail.keyType);
assertEquals(Integer.valueOf(ContactDetail.ORDER_NORMAL), detail.order);
} else if (detailId.longValue() == phoneId2) {
donePhone2 = true;
assertEquals(ADD_PHONE_TEST2, detail.nativeVal1);
assertEquals(ADD_PHONE_TEST2, detail.getValue());
assertEquals(ADD_PHONE_PEOPLE_TYPE_TEST2, detail.keyType);
assertEquals(Integer.valueOf(ContactDetail.ORDER_PREFERRED), detail.order);
} else if (detailId.longValue() == phoneId3) {
donePhone3 = true;
assertEquals(ADD_PHONE_TEST3, detail.nativeVal1);
assertEquals(ADD_PHONE_TEST3, detail.getValue());
assertEquals(ADD_PHONE_PEOPLE_TYPE_TEST3, detail.keyType);
assertEquals(Integer.valueOf(ContactDetail.ORDER_NORMAL), detail.order);
} else {
fail("Unknown phone number in people contact: ID:" + detailId + " does not match " + phoneId1 + "," + phoneId2 + "," + phoneId3);
}
break;
case VCARD_EMAIL:
assertTrue(detailId != null);
if (detailId.longValue() == cmId1) {
doneCm1 = true;
assertEquals(ADD_CM_TEST1, detail.nativeVal1);
assertEquals(String.valueOf(ADD_CM_TYPE_TEST1), detail.nativeVal2);
assertEquals(String.valueOf(ADD_CM_KIND_TEST1), detail.nativeVal3);
assertEquals(ADD_CM_TEST1, detail.getValue());
assertEquals(ADD_CM_PEOPLE_TYPE_TEST1, detail.keyType);
} else {
fail("Unknown email in people contact");
}
break;
case VCARD_ADDRESS:
assertTrue(detailId != null);
if (detailId.longValue() == cmId2) {
doneCm2 = true;
assertEquals(ADD_CM_TEST2, detail.nativeVal1);
assertEquals(String.valueOf(ADD_CM_TYPE_TEST2), detail.nativeVal2);
assertEquals(String.valueOf(ADD_CM_KIND_TEST2), detail.nativeVal3);
VCardHelper.PostalAddress address = detail.getPostalAddress();
assertTrue(address != null);
assertEquals(ADD_CM_TEST2_ADDRESS1, address.addressLine1);
assertEquals(ADD_CM_TEST2_ADDRESS2, address.addressLine2);
assertEquals(ADD_CM_TEST2_ADDRESS_CITY, address.city);
assertEquals(ADD_CM_TEST2_ADDRESS_COUNTY, address.county);
assertEquals(ADD_CM_TEST2_ADDRESS_POSTCODE, address.postCode);
assertEquals(ADD_CM_TEST2_ADDRESS_COUNTRY, address.country);
assertEquals(ADD_CM_PEOPLE_TYPE_TEST2, detail.keyType);
} else {
fail("Unknown address in people contact");
}
break;
case VCARD_ORG:
assertTrue(detailId != null);
if (detailId.longValue() == orgId1) {
doneOrg1 = true;
assertEquals(ADD_ORG_COMPANY_TEST1, detail.nativeVal1);
assertEquals(String.valueOf(ADD_ORG_TYPE_TEST1), detail.nativeVal3);
VCardHelper.Organisation org = detail.getOrg();
assertTrue(org != null);
assertEquals(0, org.unitNames.size());
assertEquals(ADD_ORG_COMPANY_TEST1, org.name);
assertEquals(ADD_ORG_PEOPLE_TYPE_TEST1, detail.keyType);
} else {
fail("Unknown organisation in people contact");
}
break;
case VCARD_TITLE:
assertTrue(detailId != null);
if (detailId.longValue() == orgId1) {
doneTitle1 = true;
assertEquals(ADD_ORG_TITLE_TEST1, detail.nativeVal1);
assertEquals(ADD_ORG_TITLE_TEST1, detail.getValue());
} else {
fail("Unknown title in people contact");
}
break;
default:
fail("Unexpected detail in people contact: " + detail.key);
}
}
assertTrue("Name was missing", doneName);
assertTrue("Nickname was missing", doneNickname);
assertTrue("Note was missing", doneNote);
assertTrue("Phone1 was missing", donePhone1);
assertTrue("Phone2 was missing", donePhone2);
assertTrue("Phone3 was missing", donePhone3);
assertTrue("Email was missing", doneCm1);
assertTrue("Address was missing", doneCm2);
assertTrue("Organisation was missing", doneOrg1);
assertTrue("Title was missing", doneTitle1);
nativeCursor.close();
peopleCursor.close();
Log.i(LOG_TAG, "*************************************************************************");
Log.i(LOG_TAG, fnName + " has completed successfully");
Log.i(LOG_TAG, "*************************************************************************");
Log.i(LOG_TAG, "");
}
Example 35
Project: android-downloadprovider-master File: DownloadProviderPermissionsTest.java View source code |
/**
* Test that an app cannot access the /cache filesystem
* <p>Tests Permission:
* {@link android.Manifest.permission#ACCESS_CACHE_FILESYSTEM}
*/
@MediumTest
public void testAccessCacheFilesystem() throws IOException {
try {
String filePath = "/cache/this-should-not-exist.txt";
FileOutputStream strm = new FileOutputStream(filePath);
strm.write("Oops!".getBytes());
strm.flush();
strm.close();
fail("Was able to create and write to " + filePath);
} catch (SecurityException e) {
} catch (FileNotFoundException e) {
}
}
Example 36
Project: AndroidBillingLibrary-master File: BillingControllerTest.java View source code |
@MediumTest
public void testIsPurchased() throws Exception {
assertFalse(BillingController.isPurchased(getContext(), TransactionTest.TRANSACTION_1.productId));
BillingController.storeTransaction(getContext(), TransactionTest.TRANSACTION_1);
assertTrue(BillingController.isPurchased(getContext(), TransactionTest.TRANSACTION_1.productId));
BillingController.storeTransaction(getContext(), TransactionTest.TRANSACTION_1_REFUNDED);
assertTrue(BillingController.isPurchased(getContext(), TransactionTest.TRANSACTION_1.productId));
}
Example 37
Project: chromium_webview-master File: ClientOnPageFinishedTest.java View source code |
@MediumTest
@Feature({ "AndroidWebView" })
public void testOnPageFinishedPassesCorrectUrl() throws Throwable {
TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper = mWebViewClient.getOnPageFinishedHelper();
String html = "<html><body>Simple page.</body></html>";
int currentCallCount = onPageFinishedHelper.getCallCount();
loadDataAsync(mWebView, html, "text/html", "utf-8");
onPageFinishedHelper.waitForCallback(currentCallCount);
assertEquals("data:text/html," + html, onPageFinishedHelper.getUrl());
}
Example 38
Project: openxc-android-master File: VehicleManagerTest.java View source code |
@MediumTest
public void testCustomSink() throws DataSourceException {
prepareServices();
assertNull(receivedMessageId);
service.addSink(mCustomSink);
source.inject(VehicleSpeed.ID, 42.0);
// TODO this is failing in CI, not sure why, but disabling it for now to
// get things released.
// assertNotNull(receivedMessageId);
// service.removeSink(mCustomSink);
// receivedMessageId = null;
// source.inject(VehicleSpeed.ID, 42.0);
// assertNull(receivedMessageId);
}
Example 39
Project: packages_provider_DownloadProvider-master File: DownloadProviderPermissionsTest.java View source code |
/**
* Test that an app cannot access the /cache filesystem
* <p>Tests Permission:
* {@link com.android.providers.downloads.Manifest.permission#ACCESS_CACHE_FILESYSTEM}
*/
@MediumTest
public void testAccessCacheFilesystem() throws IOException {
try {
String filePath = "/cache/this-should-not-exist.txt";
FileOutputStream strm = new FileOutputStream(filePath);
strm.write("Oops!".getBytes());
strm.flush();
strm.close();
fail("Was able to create and write to " + filePath);
} catch (SecurityException e) {
} catch (FileNotFoundException e) {
}
}
Example 40
Project: platform_packages_providers_downloadprovider-master File: DownloadProviderPermissionsTest.java View source code |
/**
* Test that an app cannot access the /cache filesystem
* <p>Tests Permission:
* {@link android.Manifest.permission#ACCESS_CACHE_FILESYSTEM}
*/
@MediumTest
public void testAccessCacheFilesystem() throws IOException {
try {
String filePath = "/cache/this-should-not-exist.txt";
FileOutputStream strm = new FileOutputStream(filePath);
strm.write("Oops!".getBytes());
strm.flush();
strm.close();
fail("Was able to create and write to " + filePath);
} catch (SecurityException e) {
} catch (FileNotFoundException e) {
}
}
Example 41
Project: SealBrowser-master File: ClientOnPageFinishedTest.java View source code |
@MediumTest
@Feature({ "AndroidWebView" })
public void testOnPageFinishedPassesCorrectUrl() throws Throwable {
TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper = mWebViewClient.getOnPageFinishedHelper();
String html = "<html><body>Simple page.</body></html>";
int currentCallCount = onPageFinishedHelper.getCallCount();
loadDataAsync(mWebView, html, "text/html", "utf-8");
onPageFinishedHelper.waitForCallback(currentCallCount);
assertEquals("data:text/html," + html, onPageFinishedHelper.getUrl());
}
Example 42
Project: VBoxManager-master File: HelpActivityTest.java View source code |
/**
* This test demonstrates ways to exercise the Activity's life cycle.
*/
@MediumTest
public void testLifeCycleCreate() {
HelpActivity activity = startActivity(mStartIntent, null, null);
// At this point, onCreate() has been called
getInstrumentation().callActivityOnStart(activity);
getInstrumentation().callActivityOnResume(activity);
// At this point you could use a Mock Context to confirm that
//your activity has made certain calls to the system & set itself up properly.
getInstrumentation().callActivityOnPause(activity);
// At this point you could confirm that the activity has paused
getInstrumentation().callActivityOnStop(activity);
// At this point, you could confirm that the activity has shut itself down
// or you could use a Mock Context to confirm that your activity has
// released any system resources it should no longer be holding.
}
Example 43
Project: andevcon-2014-jl-master File: ForwardingTest.java View source code |
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
Forwarding activity = startActivity(mStartIntent, null, null);
mButton = (Button) activity.findViewById(R.id.go);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
assertNotNull(getStartedActivityIntent());
assertTrue(isFinishCalled());
}
Example 44
Project: android-apidemos-master File: ForwardingTest.java View source code |
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
Forwarding activity = startActivity(mStartIntent, null, null);
mButton = (Button) activity.findViewById(R.id.go);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
assertNotNull(getStartedActivityIntent());
assertTrue(isFinishCalled());
}
Example 45
Project: android-fourteeners-master File: LocationTest.java View source code |
@MediumTest
public void testNearestFromDenver() throws InterruptedException {
Location denver = new Location(mockProvider);
denver.setLatitude(39.738494);
denver.setLongitude(-104.9878033);
denver.setAltitude((double) 5280);
denver.setAccuracy((float) 1.0);
denver.setBearing((float) 180.0);
denver.setElapsedRealtimeNanos(1);
denver.setTime(System.currentTimeMillis());
addMockProvider();
setMockLocation(denver);
Thread.sleep(1000);
ArrayList<Mountain> nearDenver = mLocation.getNearestMountains(5);
removeMockProvider();
for (Mountain m : nearDenver) {
SRLOG.v(TAG, m.getName());
}
Assert.assertTrue("size not 5", nearDenver.size() == 5);
Assert.assertTrue("nearest not Evans", nearDenver.get(0).getName().equals("Mt. Evans"));
Assert.assertTrue("nearest not Bierstady", nearDenver.get(1).getName().equals("Mt. Bierstadt"));
Assert.assertTrue("nearest not Grays", nearDenver.get(2).getName().equals("Grays Peak"));
Assert.assertTrue("nearest not Torreys", nearDenver.get(3).getName().equals("Torreys Peak"));
Assert.assertTrue("nearest not Longs", nearDenver.get(4).getName().equals("Longs Peak"));
}
Example 46
Project: android-gradle-plugin-master File: MainActivityTest.java View source code |
/**
* The name 'test preconditions' is a convention to signal that if this
* test doesn't pass, the test case was not set up properly and it might
* explain any and all failures in other tests. This is not guaranteed
* to run before other tests, as junit uses reflection to find the tests.
*/
@MediumTest
public void testPreconditions() {
assertNotNull(mAppTextView1);
assertNotNull(mAppTextView2);
assertNotNull(mLib1TextView1);
assertNotNull(mLib1TextView2);
assertNotNull(mLib2TextView1);
assertNotNull(mLib2TextView2);
assertNotNull(mLib2bTextView1);
assertNotNull(mLib2bTextView2);
assertNotNull(mLibappTextView1);
assertNotNull(mLibappTextView2);
}
Example 47
Project: android-maven-plugin-master File: ForwardingTest.java View source code |
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
Forwarding activity = startActivity(mStartIntent, null, null);
mButton = (Button) activity.findViewById(R.id.go);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
assertNotNull(getStartedActivityIntent());
assertTrue(isFinishCalled());
}
Example 48
Project: android-platform-tools-base-master File: MainActivityTest.java View source code |
/**
* The name 'test preconditions' is a convention to signal that if this
* test doesn't pass, the test case was not set up properly and it might
* explain any and all failures in other tests. This is not guaranteed
* to run before other tests, as junit uses reflection to find the tests.
*/
@MediumTest
public void testPreconditions() {
assertNotNull(mAppTextView1);
assertNotNull(mAppTextView2);
assertNotNull(mLib1TextView1);
assertNotNull(mLib1TextView2);
assertNotNull(mLib2TextView1);
assertNotNull(mLib2TextView2);
assertNotNull(mLib2bTextView1);
assertNotNull(mLib2bTextView2);
assertNotNull(mLibappTextView1);
assertNotNull(mLibappTextView2);
}
Example 49
Project: Android-SDK-Samples-master File: ForwardingTest.java View source code |
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
Forwarding activity = startActivity(mStartIntent, null, null);
mButton = (Button) activity.findViewById(R.id.go);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
assertNotNull(getStartedActivityIntent());
assertTrue(isFinishCalled());
}
Example 50
Project: apidemo-master File: ForwardingTest.java View source code |
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
Forwarding activity = startActivity(mStartIntent, null, null);
mButton = (Button) activity.findViewById(R.id.go);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
assertNotNull(getStartedActivityIntent());
assertTrue(isFinishCalled());
}
Example 51
Project: ApiDemos-master File: ForwardingTest.java View source code |
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
Forwarding activity = startActivity(mStartIntent, null, null);
mButton = (Button) activity.findViewById(R.id.go);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
assertNotNull(getStartedActivityIntent());
assertTrue(isFinishCalled());
}
Example 52
Project: ApkLauncher-master File: ForwardingTest.java View source code |
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
Forwarding activity = startActivity(mStartIntent, null, null);
mButton = (Button) activity.findViewById(R.id.go);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
assertNotNull(getStartedActivityIntent());
assertTrue(isFinishCalled());
}
Example 53
Project: ApkLauncher_legacy-master File: ForwardingTest.java View source code |
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
Forwarding activity = startActivity(mStartIntent, null, null);
mButton = (Button) activity.findViewById(R.id.go);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
assertNotNull(getStartedActivityIntent());
assertTrue(isFinishCalled());
}
Example 54
Project: cascade-master File: UIExecutorServiceTest.java View source code |
@MediumTest
public void testInvokeAllCallable() throws Exception {
AtomicInteger ai = new AtomicInteger(0);
ArrayList<Callable<Integer>> callableList = new ArrayList<>();
SettableAltFuture<String> saf = new SettableAltFuture<>(WORKER);
callableList.add(() -> {
ai.set(100);
return 100;
});
callableList.add(() -> {
ai.set(ai.get() + 200);
return 200;
});
callableList.add(() -> {
saf.set("done");
return 1;
});
uiExecutorService.invokeAll(callableList);
awaitDone(saf);
assertTrue(sendCount > 0);
assertEquals(300, ai.get());
}
Example 55
Project: Collageify-master File: ForwardingTest.java View source code |
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
Forwarding activity = startActivity(mStartIntent, null, null);
mButton = (Button) activity.findViewById(R.id.go);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
assertNotNull(getStartedActivityIntent());
assertTrue(isFinishCalled());
}
Example 56
Project: development_apps_spareparts-master File: ForwardingTest.java View source code |
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
Forwarding activity = startActivity(mStartIntent, null, null);
mButton = (Button) activity.findViewById(R.id.go);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
assertNotNull(getStartedActivityIntent());
assertTrue(isFinishCalled());
}
Example 57
Project: ese2013-team7-master File: MensaActivityTest.java View source code |
@MediumTest
public void testMenuActivityStarted() {
// add monitor to check for the second activity
ActivityMonitor monitor = getInstrumentation().addMonitor(MenuActivity.class.getName(), null, false);
TextView listItem = (TextView) activity.findViewById(R.id.mensa_list_row);
// TouchUtils handles the sync with the main thread internally
TouchUtils.clickView(this, listItem);
// wait 2 seconds for the start of the activity
MenuActivity startedActivity = (MenuActivity) monitor.waitForActivityWithTimeout(2000);
assertNotNull(startedActivity);
// search for the textView
TextView textView = (TextView) startedActivity.findViewById(R.id.menu_text);
// check that the TextView is on the screen
ViewAsserts.assertOnScreen(startedActivity.getWindow().getDecorView(), textView);
// press back
this.sendKeys(KeyEvent.KEYCODE_BACK);
}
Example 58
Project: facebook-android-sdk-master File: AsyncRequestTests.java View source code |
@SmallTest
@MediumTest
@LargeTest
public void testExecuteBatchWithZeroRequestsThrows() throws Exception {
try {
TestGraphRequestAsyncTask task = new TestGraphRequestAsyncTask(new GraphRequest[] {});
task.executeOnBlockerThread();
waitAndAssertSuccessOrRethrow(1);
fail("expected IllegalArgumentException");
} catch (IllegalArgumentException exception) {
}
}
Example 59
Project: felix-on-android-master File: ForwardingTest.java View source code |
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
Forwarding activity = startActivity(mStartIntent, null, null);
mButton = (Button) activity.findViewById(R.id.go);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
assertNotNull(getStartedActivityIntent());
assertTrue(isFinishCalled());
}
Example 60
Project: GradleCodeLab-master File: ForwardingTest.java View source code |
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
Forwarding activity = startActivity(mStartIntent, null, null);
mButton = (Button) activity.findViewById(R.id.go);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
assertNotNull(getStartedActivityIntent());
assertTrue(isFinishCalled());
}
Example 61
Project: gradle_examples_0.14.4-master File: MainActivityTest.java View source code |
/**
* The name 'test preconditions' is a convention to signal that if this
* test doesn't pass, the test case was not set up properly and it might
* explain any and all failures in other tests. This is not guaranteed
* to run before other tests, as junit uses reflection to find the tests.
*/
@MediumTest
public void testPreconditions() {
assertNotNull(mAppTextView1);
assertNotNull(mAppTextView2);
assertNotNull(mLib1TextView1);
assertNotNull(mLib1TextView2);
assertNotNull(mLib2TextView1);
assertNotNull(mLib2TextView2);
assertNotNull(mLib2bTextView1);
assertNotNull(mLib2bTextView2);
assertNotNull(mLibappTextView1);
assertNotNull(mLibappTextView2);
}
Example 62
Project: ListviewFilter-master File: MainActivityTest.java View source code |
// list view is in layout or not?
@MediumTest
public void testListViewLayout() {
final View decorView = mActivity.getWindow().getDecorView();
ViewAsserts.assertOnScreen(decorView, mListView);
final ViewGroup.LayoutParams layoutParams = mListView.getLayoutParams();
assertNotNull("mListView layoutParams is null", layoutParams);
assertEquals("mListView has wrong width", layoutParams.width, WindowManager.LayoutParams.MATCH_PARENT);
assertEquals("mListView has wrong height", layoutParams.height, WindowManager.LayoutParams.MATCH_PARENT);
sleep();
assertTrue("mListView is not visible", View.VISIBLE == mListView.getVisibility());
}
Example 63
Project: mobile-spec-master File: ForwardingTest.java View source code |
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
Forwarding activity = startActivity(mStartIntent, null, null);
mButton = (Button) activity.findViewById(R.id.go);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
assertNotNull(getStartedActivityIntent());
assertTrue(isFinishCalled());
}
Example 64
Project: platform_development-master File: ForwardingTest.java View source code |
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
Forwarding activity = startActivity(mStartIntent, null, null);
mButton = (Button) activity.findViewById(R.id.go);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
assertNotNull(getStartedActivityIntent());
assertTrue(isFinishCalled());
}
Example 65
Project: sqlite-android-master File: DatabaseGeneralTest.java View source code |
@MediumTest
public void testCustomFunction() {
mDatabase.addCustomFunction("roundFunction", 1, new SQLiteDatabase.CustomFunction() {
@Override
public String callback(String[] args) {
String input = args[0];
double value = Double.parseDouble(input);
return String.valueOf(Math.round(value));
}
});
Cursor cursor = mDatabase.rawQuery("SELECT roundFunction(3.14)", null);
assertTrue(cursor.moveToFirst());
int result = cursor.getInt(0);
assertSame(3, result);
}
Example 66
Project: subscribe-master File: SubscribeAppTest.java View source code |
/**
* Tests the preconditions of this test fixture.
*/
@MediumTest
public void testPreconditions() {
//Start the activity under test in isolation, without values for savedInstanceState and
//lastNonConfigurationInstance
assertNotNull("mLaunchActivity is null", getActivity());
assertNotNull("EmailEditText is null", email);
assertNotNull("subject is null", subject);
assertNotNull("body is null", body);
assertNotNull("send button is null", btnSend);
}
Example 67
Project: SUJogger-master File: LoggerMapTest.java View source code |
/**
* Usecase A: Start logging
*
* Start the MapView and start / stop the logging
* @throws InterruptedException
*
*/
@MediumTest
public void testStartTracking() throws InterruptedException {
GPSLoggerServiceManager serviceManager = new GPSLoggerServiceManager(this.getInstrumentation().getContext());
serviceManager.startup();
Assert.assertEquals("The service should not be logging", Constants.STOPPED, serviceManager.getLoggingState());
this.sendKeys("MENU T DPAD_DOWN ENTER");
this.sendKeys("T E S T R O U T E ENTER ENTER");
Assert.assertTrue("Title contains the current route name", this.mLoggermap.getTitle().toString().contains("testroute"));
Assert.assertEquals("The service should be logging", Constants.LOGGING, serviceManager.getLoggingState());
this.sendKeys("MENU T DPAD_DOWN DPAD_DOWN DPAD_DOWN DPAD_DOWN DPAD_CENTER");
Assert.assertEquals("The service should not be logging", Constants.STOPPED, serviceManager.getLoggingState());
serviceManager.shutdown();
}
Example 68
Project: WhatsApp-Web-master File: RequestTests.java View source code |
@MediumTest
@LargeTest
public void testExecuteSingleGet() {
final AccessToken accessToken = getAccessTokenForSharedUser();
GraphRequest request = new GraphRequest(accessToken, "TourEiffel");
GraphResponse response = request.executeAndWait();
assertTrue(response != null);
assertTrue(response.getError() == null);
assertNotNull(response.getJSONObject());
assertNotNull(response.getRawResponse());
JSONObject graphPlace = response.getJSONObject();
assertEquals("Paris", graphPlace.optJSONObject("location").optString("city"));
}
Example 69
Project: WS171-development-master File: ForwardingTest.java View source code |
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
Forwarding activity = startActivity(mStartIntent, null, null);
mButton = (Button) activity.findViewById(R.id.go);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
assertNotNull(getStartedActivityIntent());
assertTrue(isFinishCalled());
}
Example 70
Project: android-packages-apps-calendar-compiled-master File: RecurrenceProcessorTest.java View source code |
@MediumTest
public void testFromGoogleCalendar0() throws Exception {
// Tuesday, Thursday (10/2)
verifyRecurrence("20061002T050000", "FREQ=WEEKLY;UNTIL=20071031T200000Z;INTERVAL=1;BYDAY=TU,TH;WKST=SU", null, /* rdate */
null, /* exrule */
null, /* exdate */
"20060101T000000", "20090101T000000", new String[] { "20061002T050000", "20061003T050000", "20061005T050000", "20061010T050000", "20061012T050000", "20061017T050000", "20061019T050000", "20061024T050000", "20061026T050000", "20061031T050000", "20061102T050000", "20061107T050000", "20061109T050000", "20061114T050000", "20061116T050000", "20061121T050000", "20061123T050000", "20061128T050000", "20061130T050000", "20061205T050000", "20061207T050000", "20061212T050000", "20061214T050000", "20061219T050000", "20061221T050000", "20061226T050000", "20061228T050000", "20070102T050000", "20070104T050000", "20070109T050000", "20070111T050000", "20070116T050000", "20070118T050000", "20070123T050000", "20070125T050000", "20070130T050000", "20070201T050000", "20070206T050000", "20070208T050000", "20070213T050000", "20070215T050000", "20070220T050000", "20070222T050000", "20070227T050000", "20070301T050000", "20070306T050000", "20070308T050000", "20070313T050000", "20070315T050000", "20070320T050000", "20070322T050000", "20070327T050000", "20070329T050000", "20070403T050000", "20070405T050000", "20070410T050000", "20070412T050000", "20070417T050000", "20070419T050000", "20070424T050000", "20070426T050000", "20070501T050000", "20070503T050000", "20070508T050000", "20070510T050000", "20070515T050000", "20070517T050000", "20070522T050000", "20070524T050000", "20070529T050000", "20070531T050000", "20070605T050000", "20070607T050000", "20070612T050000", "20070614T050000", "20070619T050000", "20070621T050000", "20070626T050000", "20070628T050000", "20070703T050000", "20070705T050000", "20070710T050000", "20070712T050000", "20070717T050000", "20070719T050000", "20070724T050000", "20070726T050000", "20070731T050000", "20070802T050000", "20070807T050000", "20070809T050000", "20070814T050000", "20070816T050000", "20070821T050000", "20070823T050000", "20070828T050000", "20070830T050000", "20070904T050000", "20070906T050000", "20070911T050000", "20070913T050000", "20070918T050000", "20070920T050000", "20070925T050000", "20070927T050000", "20071002T050000", "20071004T050000", "20071009T050000", "20071011T050000", "20071016T050000", "20071018T050000", "20071023T050000", "20071025T050000", "20071030T050000" }, "20071031T130000");
}
Example 71
Project: android-sdk-master File: SyncFormUploadTest.java View source code |
@MediumTest
public void testFile() throws Throwable {
final String expectKey = "世/界";
final File f = TempFile.createFile(1);
Map<String, String> params = new HashMap<String, String>();
params.put("x:foo", "fooval");
final UploadOptions opt = new UploadOptions(params, null, true, null, null);
info = uploadManager.syncPut(f, expectKey, TestConfig.token_z0, opt);
resp = info.response;
key = resp.optString("key");
Assert.assertEquals(info.toString(), expectKey, key);
Assert.assertTrue(info.toString(), info.isOK());
//ä¸Šä¼ ç–ç•¥å?«ç©ºæ ¼ \"fname\":\" $(fname) \"
Assert.assertEquals(f.getName(), resp.optString("fname", "res doesn't include the FNAME").trim());
Assert.assertNotNull(info.reqId);
Assert.assertNotNull(resp);
String hash = resp.getString("hash");
Assert.assertEquals(hash, Etag.file(f));
TempFile.remove(f);
}
Example 72
Project: android-thaiime-master File: OperationSchedulerTest.java View source code |
@MediumTest
public void testScheduler() throws Exception {
TimeTravelScheduler scheduler = new TimeTravelScheduler();
OperationScheduler.Options options = new OperationScheduler.Options();
assertEquals(Long.MAX_VALUE, scheduler.getNextTimeMillis(options));
assertEquals(0, scheduler.getLastSuccessTimeMillis());
assertEquals(0, scheduler.getLastAttemptTimeMillis());
long beforeTrigger = scheduler.timeMillis;
scheduler.setTriggerTimeMillis(beforeTrigger + 1000000);
assertEquals(beforeTrigger + 1000000, scheduler.getNextTimeMillis(options));
// It will schedule for the later of the trigger and the moratorium...
scheduler.setMoratoriumTimeMillis(beforeTrigger + 500000);
assertEquals(beforeTrigger + 1000000, scheduler.getNextTimeMillis(options));
scheduler.setMoratoriumTimeMillis(beforeTrigger + 1500000);
assertEquals(beforeTrigger + 1500000, scheduler.getNextTimeMillis(options));
// Test enable/disable toggle
scheduler.setEnabledState(false);
assertEquals(Long.MAX_VALUE, scheduler.getNextTimeMillis(options));
scheduler.setEnabledState(true);
assertEquals(beforeTrigger + 1500000, scheduler.getNextTimeMillis(options));
// Backoff interval after an error
long beforeError = (scheduler.timeMillis += 100);
scheduler.onTransientError();
assertEquals(0, scheduler.getLastSuccessTimeMillis());
assertEquals(beforeError, scheduler.getLastAttemptTimeMillis());
assertEquals(beforeTrigger + 1500000, scheduler.getNextTimeMillis(options));
options.backoffFixedMillis = 1000000;
options.backoffIncrementalMillis = 500000;
assertEquals(beforeError + 1500000, scheduler.getNextTimeMillis(options));
// Two errors: backoff interval increases
beforeError = (scheduler.timeMillis += 100);
scheduler.onTransientError();
assertEquals(beforeError, scheduler.getLastAttemptTimeMillis());
assertEquals(beforeError + 2000000, scheduler.getNextTimeMillis(options));
// Reset transient error: no backoff interval
scheduler.resetTransientError();
assertEquals(0, scheduler.getLastSuccessTimeMillis());
assertEquals(beforeTrigger + 1500000, scheduler.getNextTimeMillis(options));
assertEquals(beforeError, scheduler.getLastAttemptTimeMillis());
// Permanent error holds true even if transient errors are reset
// However, we remember that the transient error was reset...
scheduler.onPermanentError();
assertEquals(Long.MAX_VALUE, scheduler.getNextTimeMillis(options));
scheduler.resetTransientError();
assertEquals(Long.MAX_VALUE, scheduler.getNextTimeMillis(options));
scheduler.resetPermanentError();
assertEquals(beforeTrigger + 1500000, scheduler.getNextTimeMillis(options));
// Success resets the trigger
long beforeSuccess = (scheduler.timeMillis += 100);
scheduler.onSuccess();
assertEquals(beforeSuccess, scheduler.getLastAttemptTimeMillis());
assertEquals(beforeSuccess, scheduler.getLastSuccessTimeMillis());
assertEquals(Long.MAX_VALUE, scheduler.getNextTimeMillis(options));
// The moratorium is not reset by success!
scheduler.setTriggerTimeMillis(0);
assertEquals(beforeTrigger + 1500000, scheduler.getNextTimeMillis(options));
scheduler.setMoratoriumTimeMillis(0);
assertEquals(beforeSuccess, scheduler.getNextTimeMillis(options));
// Periodic interval after success
options.periodicIntervalMillis = 250000;
scheduler.setTriggerTimeMillis(Long.MAX_VALUE);
assertEquals(beforeSuccess + 250000, scheduler.getNextTimeMillis(options));
// Trigger minimum is also since the last success
options.minTriggerMillis = 1000000;
assertEquals(beforeSuccess + 1000000, scheduler.getNextTimeMillis(options));
}
Example 73
Project: AndroidBaseUtils-master File: PreferencesUtilTest.java View source code |
@MediumTest
public void testStoreSerializable() {
final String key = "TEST_SERIALIZABLE";
final ArrayList<String> expected = new ArrayList<>();
expected.add("Lorem ipsum");
expected.add("dolor sit amet");
expected.add("consectetur adipiscing elit");
final ArrayList<String> defValue = new ArrayList<>();
defValue.add("Proin mollis dictum");
PreferencesUtil.put(key, expected);
ArrayList<String> actual = PreferencesUtil.get(key, defValue);
assertEquals(expected, actual);
}
Example 74
Project: android_packages_apps-master File: ProviderTests.java View source code |
/**
* Test simple message save/retrieve
*
* TODO: serverId vs. serverIntId
*/
@MediumTest
public void testMessageSave() {
Account account1 = ProviderTestUtils.setupAccount("message-save", true, mMockContext);
long account1Id = account1.mId;
Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, true, mMockContext);
long box1Id = box1.mId;
// Test a simple message (saved with no body)
Message message1 = ProviderTestUtils.setupMessage("message1", account1Id, box1Id, false, true, mMockContext);
long message1Id = message1.mId;
Message message1get = EmailContent.Message.restoreMessageWithId(mMockContext, message1Id);
ProviderTestUtils.assertMessageEqual("testMessageSave", message1, message1get);
// Test a message saved with a body
// Note that it will read back w/o the text & html so we must extract those
Message message2 = ProviderTestUtils.setupMessage("message1", account1Id, box1Id, true, true, mMockContext);
long message2Id = message2.mId;
String text2 = message2.mText;
String html2 = message2.mHtml;
String textReply2 = message2.mTextReply;
String htmlReply2 = message2.mHtmlReply;
long sourceKey2 = message2.mSourceKey;
String introText2 = message2.mIntroText;
message2.mText = null;
message2.mHtml = null;
message2.mTextReply = null;
message2.mHtmlReply = null;
message2.mSourceKey = 0;
message2.mIntroText = null;
Message message2get = EmailContent.Message.restoreMessageWithId(mMockContext, message2Id);
ProviderTestUtils.assertMessageEqual("testMessageSave", message2, message2get);
// Now see if there's a body saved with the right stuff
Body body2 = loadBodyForMessageId(message2Id);
assertEquals("body text", text2, body2.mTextContent);
assertEquals("body html", html2, body2.mHtmlContent);
assertEquals("reply text", textReply2, body2.mTextReply);
assertEquals("reply html", htmlReply2, body2.mHtmlReply);
assertEquals("source key", sourceKey2, body2.mSourceKey);
assertEquals("intro text", introText2, body2.mIntroText);
}
Example 75
Project: Calendar_lunar-master File: FormatDateRangeTest.java View source code |
@MediumTest
public void testAll() throws Exception {
int len = tests.length;
for (int index = 0; index < len; index++) {
DateTest dateTest = tests[index];
long startMillis = dateTest.date1.toMillis(false);
long endMillis = dateTest.date2.toMillis(false);
int flags = dateTest.flags;
String output = DateUtils.formatDateRange(mContext, startMillis, endMillis, flags);
if (!dateTest.expectedOutput.equals(output)) {
Log.i("FormatDateRangeTest", "index " + index + " expected: " + dateTest.expectedOutput + " actual: " + output);
}
assertEquals(dateTest.expectedOutput, output);
}
}
Example 76
Project: Jerome-s-Project-master File: FormatDateRangeTest.java View source code |
@MediumTest
public void testAll() throws Exception {
int len = tests.length;
for (int index = 0; index < len; index++) {
DateTest dateTest = tests[index];
long startMillis = dateTest.date1.toMillis(false);
long endMillis = dateTest.date2.toMillis(false);
int flags = dateTest.flags;
String output = DateUtils.formatDateRange(mContext, startMillis, endMillis, flags);
if (!dateTest.expectedOutput.equals(output)) {
Log.i("FormatDateRangeTest", "index " + index + " expected: " + dateTest.expectedOutput + " actual: " + output);
}
assertEquals(dateTest.expectedOutput, output);
}
}
Example 77
Project: levelup-sdk-android-master File: LevelUpCodeViewTest.java View source code |
/**
* Tests {@link com.scvngr.levelup.core.ui.view.LevelUpCodeView#setLevelUpCode(String, com.scvngr.levelup.core.ui.view.LevelUpCodeLoader)} with a cache hit.
*
* @throws InterruptedException
*/
@MediumTest
public void testShowCode_cacheHit() throws InterruptedException {
final String key1 = mLoader.getKey(MockQrCodeGenerator.TEST_CONTENT1);
final LatchingOnCodeLoadListener onCodeLoadListener = new LatchingOnCodeLoadListener();
mLevelUpCodeView.setOnCodeLoadListener(onCodeLoadListener);
mCache.putCode(key1, mQrCodeGenerator.mTestImage1);
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
mLevelUpCodeView.setLevelUpCode(MockQrCodeGenerator.TEST_CONTENT1, mLoader);
}
});
getInstrumentation().waitForIdleSync();
/*
* The callback should only be called once with loading=false, so progress bars and such can
* be handled properly.
*/
assertOnCodeLoaded(onCodeLoadListener, false, 1);
assertOnCodeLoaded(onCodeLoadListener, true, 0);
MockQrCodeGenerator.isBitmapForCode(mLevelUpCodeView.mCurrentCode, MockQrCodeGenerator.TEST_CONTENT1);
}
Example 78
Project: open-bixi-gpstracker-master File: LoggerMapTest.java View source code |
/**
* Usecase A: Start logging
*
* Start the MapView and start / stop the logging
* @throws InterruptedException
*
*/
@MediumTest
@Suppress
public void testStartTracking() throws InterruptedException {
GPSLoggerServiceManager serviceManager = new GPSLoggerServiceManager(this.getInstrumentation().getContext());
serviceManager.startup(getActivity(), null);
Assert.assertEquals("The service should not be logging", Constants.STOPPED, serviceManager.getLoggingState());
this.sendKeys("MENU T DPAD_DOWN ENTER");
this.sendKeys("T E S T R O U T E ENTER ENTER");
Assert.assertTrue("Title contains the current route name", this.mLoggermap.getTitle().toString().contains("testroute"));
Assert.assertEquals("The service should be logging", Constants.LOGGING, serviceManager.getLoggingState());
this.sendKeys("MENU T DPAD_DOWN DPAD_DOWN DPAD_DOWN DPAD_DOWN DPAD_CENTER");
Assert.assertEquals("The service should not be logging", Constants.STOPPED, serviceManager.getLoggingState());
serviceManager.shutdown(getActivity());
}
Example 79
Project: platform_packages_apps_calendar-master File: FormatDateRangeTest.java View source code |
@MediumTest
public void testAll() throws Exception {
int len = tests.length;
for (int index = 0; index < len; index++) {
DateTest dateTest = tests[index];
long startMillis = dateTest.date1.toMillis(false);
long endMillis = dateTest.date2.toMillis(false);
int flags = dateTest.flags;
String output = DateUtils.formatDateRange(mContext, startMillis, endMillis, flags);
if (!dateTest.expectedOutput.equals(output)) {
Log.i("FormatDateRangeTest", "index " + index + " expected: " + dateTest.expectedOutput + " actual: " + output);
}
assertEquals(dateTest.expectedOutput, output);
}
}
Example 80
Project: WS171-packages-apps-Calendar-master File: FormatDateRangeTest.java View source code |
@MediumTest
public void testAll() throws Exception {
int len = tests.length;
for (int index = 0; index < len; index++) {
DateTest dateTest = tests[index];
long startMillis = dateTest.date1.toMillis(false);
long endMillis = dateTest.date2.toMillis(false);
int flags = dateTest.flags;
String output = DateUtils.formatDateRange(mContext, startMillis, endMillis, flags);
if (!dateTest.expectedOutput.equals(output)) {
Log.i("FormatDateRangeTest", "index " + index + " expected: " + dateTest.expectedOutput + " actual: " + output);
}
assertEquals(dateTest.expectedOutput, output);
}
}
Example 81
Project: agit-master File: GitAsyncTaskTest.java View source code |
@MediumTest
public void testCloneRepoWithEmptyBlobInPack() throws Exception {
Clone cloneOp = new Clone(true, integrationGitServerURIFor("tiny-repo.with-empty-file.git"), helper().newFolder());
Repository repo = executeAndWaitFor(cloneOp);
// empty blob
assertThat(repo, hasGitObject("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"));
// populated blob
assertThat(repo, hasGitObject("adcb77d8f74590f54b4c1919b322aed456b22aeb"));
}
Example 82
Project: ohmagePhone-master File: CampaignInfoActivityTest.java View source code |
@MediumTest
public void testDeletedState() {
Campaign c = getBasicCampaign();
c.mStatus = Campaign.STATUS_NO_EXIST;
provider.setCampaigns(c);
solo.searchText(FAKE_TITLE);
assertEquals("deleted on server", mStatusValue.getText());
assertEquals(true, mErrorBox.getVisibility() == View.VISIBLE);
assertEquals(false, surveysButton.getVisibility() == View.VISIBLE);
assertEquals(false, participateButton.getVisibility() == View.VISIBLE);
assertEquals(true, removeButton.getVisibility() == View.VISIBLE);
}
Example 83
Project: cgeo-master File: GCParserTest.java View source code |
/**
* Test {@link GCParser#parseAndSaveCacheFromText(String, DisposableHandler)} with "mocked" data
*
*/
@MediumTest
public static void testParseCacheFromTextWithMockedData() {
final String gcCustomDate = Settings.getGcCustomDate();
try {
for (final MockedCache mockedCache : MockedCache.MOCKED_CACHES) {
// to get the same results we have to use the date format used when the mocked data was created
Settings.setGcCustomDate(MockedCache.getDateFormat());
final SearchResult searchResult = GCParser.parseAndSaveCacheFromText(mockedCache.getData(), null);
final Geocache parsedCache = searchResult.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
assertThat(parsedCache).isNotNull();
// To keep editors happy
assert parsedCache != null;
assertThat(StringUtils.isNotBlank(mockedCache.getMockedDataUser())).isTrue();
// Workaround for issue #3777
if (mockedCache.getGeocode().equals("GC3XX5J") && Settings.getUserName().equals("mucek4")) {
parsedCache.setFound(true);
}
Compare.assertCompareCaches(mockedCache, parsedCache, true);
}
} finally {
Settings.setGcCustomDate(gcCustomDate);
}
}
Example 84
Project: Contacts_Eclair_Mod-master File: RecentCallsListActivityTests.java View source code |
/**
* Checks that the call icon is not visible for private and
* unknown numbers.
* Use 2 passes, one where new views are created and one where
* half of the total views are updated and the other half created.
*/
@MediumTest
public void testCallViewIsNotVisibleForPrivateAndUnknownNumbers() {
final int SIZE = 100;
mList = new View[SIZE];
// Insert the first batch of entries.
mCursor.moveToFirst();
insertRandomEntries(SIZE / 2);
int startOfSecondBatch = mCursor.getPosition();
buildViewListFromDb();
checkCallStatus();
// Append the rest of the entries. We keep the first set of
// views around so they get updated and not built from
// scratch, this exposes some bugs that are not there when the
// call log is launched for the 1st time but show up when the
// call log gets updated afterwards.
mCursor.move(startOfSecondBatch);
insertRandomEntries(SIZE / 2);
buildViewListFromDb();
checkCallStatus();
}
Example 85
Project: packages_providers_ContactsProvider-master File: GroupsTest.java View source code |
@MediumTest
public void testMarkAsDirtyParameter() {
Uri uri = ContentUris.withAppendedId(Groups.CONTENT_URI, createGroup(mAccount, "gsid1", "title1"));
clearDirty(uri);
Uri updateUri = setCallerIsSyncAdapter(uri, mAccount);
ContentValues values = new ContentValues();
values.put(Groups.NOTES, "New notes");
mResolver.update(updateUri, values, null, null);
assertDirty(uri, false);
}
Example 86
Project: SPD8810GA-master File: RecentCallsListActivityTests.java View source code |
/**
* Checks that the call icon is not visible for private and
* unknown numbers.
* Use 2 passes, one where new views are created and one where
* half of the total views are updated and the other half created.
*/
@MediumTest
public void testCallViewIsNotVisibleForPrivateAndUnknownNumbers() {
final int SIZE = 100;
mList = new View[SIZE];
// Insert the first batch of entries.
mCursor.moveToFirst();
insertRandomEntries(SIZE / 2);
int startOfSecondBatch = mCursor.getPosition();
buildViewListFromDb();
checkCallStatus();
// Append the rest of the entries. We keep the first set of
// views around so they get updated and not built from
// scratch, this exposes some bugs that are not there when the
// call log is launched for the 1st time but show up when the
// call log gets updated afterwards.
mCursor.move(startOfSecondBatch);
insertRandomEntries(SIZE / 2);
buildViewListFromDb();
checkCallStatus();
}
Example 87
Project: themes-platform-packages-apps-Contacts-master File: RecentCallsListActivityTests.java View source code |
/**
* Checks that the call icon is not visible for private and
* unknown numbers.
* Use 2 passes, one where new views are created and one where
* half of the total views are updated and the other half created.
*/
@MediumTest
public void testCallViewIsNotVisibleForPrivateAndUnknownNumbers() {
final int SIZE = 100;
mList = new View[SIZE];
// Insert the first batch of entries.
mCursor.moveToFirst();
insertRandomEntries(SIZE / 2);
int startOfSecondBatch = mCursor.getPosition();
buildViewListFromDb();
checkCallStatus();
// Append the rest of the entries. We keep the first set of
// views around so they get updated and not built from
// scratch, this exposes some bugs that are not there when the
// call log is launched for the 1st time but show up when the
// call log gets updated afterwards.
mCursor.move(startOfSecondBatch);
insertRandomEntries(SIZE / 2);
buildViewListFromDb();
checkCallStatus();
}
Example 88
Project: android-groovy-dagger-espresso-demo-master File: SpockTestRequestBuilder.java View source code |
/**
* Run only tests with given size
* @param testSize
*/
public void addTestSizeFilter(String testSize) {
if (SMALL_SIZE.equals(testSize)) {
mFilter = mFilter.intersect(new SizeFilter(SmallTest.class));
} else if (MEDIUM_SIZE.equals(testSize)) {
mFilter = mFilter.intersect(new SizeFilter(MediumTest.class));
} else if (LARGE_SIZE.equals(testSize)) {
mFilter = mFilter.intersect(new SizeFilter(LargeTest.class));
} else {
Log.e(LOG_TAG, String.format("Unrecognized test size '%s'", testSize));
}
}
Example 89
Project: platform_packages_providers_calendarprovider-master File: CalendarDatabaseHelperTest.java View source code |
@MediumTest
public void testUpgradeToVersion69() {
// Create event tables
createVersion67EventsTable(mBadDb);
createVersion67EventsTable(mGoodDb);
// Fill in good and bad events
addVersion67Events();
// Run the upgrade on the bad events
CalendarDatabaseHelper.upgradeToVersion69(mBadDb);
Cursor badCursor = null;
Cursor goodCursor = null;
try {
badCursor = mBadDb.rawQuery("SELECT _id,dtstart,dtend,duration,dtstart2,dtend2," + "eventTimezone,eventTimezone2,rrule FROM Events WHERE allDay=?", new String[] { "1" });
goodCursor = mGoodDb.rawQuery("SELECT _id,dtstart,dtend,duration,dtstart2,dtend2," + "eventTimezone,eventTimezone2,rrule FROM Events WHERE allDay=?", new String[] { "1" });
// Check that we get the correct results back
assertTrue(compareCursors(badCursor, goodCursor));
} finally {
if (badCursor != null) {
badCursor.close();
}
if (goodCursor != null) {
goodCursor.close();
}
}
}
Example 90
Project: soulissapp-master File: TaskerEditActivityTest.java View source code |
/**
* Tests editing a new condition with screen rotations.
*/
@MediumTest
public void testNewSetting_screen_rotation() throws Throwable {
/*
* At this point, nothing is selected. Rotate the screen to make sure that this state is preserved.
*/
//$NON-NLS-1$
assertMessageAutoSync("");
setActivityOrientationSync(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setActivityOrientationSync(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setActivityOrientationSync(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//$NON-NLS-1$
assertMessageAutoSync("");
/*
* Select something and rotate the screen to make sure that this state is preserved.
*/
//$NON-NLS-1$
setMessageAutoSync("foo");
//$NON-NLS-1$
assertMessageAutoSync("foo");
setActivityOrientationSync(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setActivityOrientationSync(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setActivityOrientationSync(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//$NON-NLS-1$
assertMessageAutoSync("foo");
/*
* Select something and rotate the screen to make sure that this state is preserved.
*/
//$NON-NLS-1$
setMessageAutoSync("bar");
//$NON-NLS-1$
assertMessageAutoSync("bar");
setActivityOrientationSync(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setActivityOrientationSync(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setActivityOrientationSync(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//$NON-NLS-1$
assertMessageAutoSync("bar");
}
Example 91
Project: ValidatorForAndroid-master File: ValidatorTest.java View source code |
@MediumTest
public void testRequiredValidator() throws Exception {
startActivity(mStartIntent, null, null);
final RequiredValidator validator = new RequiredValidator(INVALID);
// success
edit.setText("�����");
assertTrue(validator.isValid(edit));
// invalid
edit.setText("");
assertFalse(validator.isValid(edit));
edit.setText(null);
assertFalse(validator.isValid(edit));
edit.setText("    ");
assertFalse(validator.isValid(edit));
edit.setText(" ");
assertFalse(validator.isValid(edit));
edit.setText("    ");
assertFalse(validator.isValid(edit));
}
Example 92
Project: cm10_apps_Gallery2-master File: BlobCacheTest.java View source code |
@MediumTest
public void testChecksum() throws IOException {
BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
byte[] buf = new byte[0];
assertEquals(0x1, bc.checkSum(buf));
buf = new byte[1];
assertEquals(0x10001, bc.checkSum(buf));
buf[0] = 0x47;
assertEquals(0x480048, bc.checkSum(buf));
buf = new byte[3];
buf[0] = 0x10;
buf[1] = 0x30;
buf[2] = 0x01;
assertEquals(0x940042, bc.checkSum(buf));
assertEquals(0x310031, bc.checkSum(buf, 1, 1));
assertEquals(0x1, bc.checkSum(buf, 1, 0));
assertEquals(0x630032, bc.checkSum(buf, 1, 2));
buf = new byte[1024];
for (int i = 0; i < buf.length; i++) {
buf[i] = (byte) (i * i);
}
assertEquals(0x3574a610, bc.checkSum(buf));
bc.close();
}
Example 93
Project: CyclismoProject-master File: TrackRecordingServiceTest.java View source code |
@MediumTest
public void testResumeAfterReboot_shouldResume() throws Exception {
// Insert a dummy track and mark it as recording track.
createDummyTrack(123L, System.currentTimeMillis(), true);
// Clear the number of attempts and set the timeout to 10 min.
updateAutoResumePrefs(PreferencesUtils.AUTO_RESUME_TRACK_CURRENT_RETRY_DEFAULT, PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_DEFAULT);
// Start the service in "resume" mode (simulates the on-reboot action).
Intent startIntent = createStartIntent();
startIntent.putExtra(RESUME_TRACK_EXTRA_NAME, true);
startService(startIntent);
assertNotNull(getService());
// We expect to resume the previous track.
assertTrue(getService().isRecording());
ITrackRecordingService service = bindAndGetService(createStartIntent());
assertEquals(123L, service.getRecordingTrackId());
}
Example 94
Project: Gallery3D_EVO_3D-master File: BlobCacheTest.java View source code |
@MediumTest
public void testChecksum() throws IOException {
BlobCache bc = new BlobCache(TEST_FILE_NAME, MAX_ENTRIES, MAX_BYTES, true);
byte[] buf = new byte[0];
assertEquals(0x1, bc.checkSum(buf));
buf = new byte[1];
assertEquals(0x10001, bc.checkSum(buf));
buf[0] = 0x47;
assertEquals(0x480048, bc.checkSum(buf));
buf = new byte[3];
buf[0] = 0x10;
buf[1] = 0x30;
buf[2] = 0x01;
assertEquals(0x940042, bc.checkSum(buf));
assertEquals(0x310031, bc.checkSum(buf, 1, 1));
assertEquals(0x1, bc.checkSum(buf, 1, 0));
assertEquals(0x630032, bc.checkSum(buf, 1, 2));
buf = new byte[1024];
for (int i = 0; i < buf.length; i++) {
buf[i] = (byte) (i * i);
}
assertEquals(0x3574a610, bc.checkSum(buf));
bc.close();
}
Example 95
Project: MyTracks-master File: TrackRecordingServiceTest.java View source code |
@MediumTest
public void testResumeAfterReboot_shouldResume() throws Exception {
// Insert a dummy track and mark it as recording track.
createDummyTrack(123L, System.currentTimeMillis(), true);
// Clear the number of attempts and set the timeout to 10 min.
updateAutoResumePrefs(PreferencesUtils.AUTO_RESUME_TRACK_CURRENT_RETRY_DEFAULT, PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_DEFAULT);
// Start the service in "resume" mode (simulates the on-reboot action).
Intent startIntent = createStartIntent();
startIntent.putExtra(TrackRecordingService.RESUME_TRACK_EXTRA_NAME, true);
startService(startIntent);
assertNotNull(getService());
// We expect to resume the previous track.
assertTrue(getService().isRecording());
ITrackRecordingService service = bindAndGetService(createStartIntent());
assertEquals(123L, service.getRecordingTrackId());
}
Example 96
Project: packages-apps-Email-master File: ProviderTests.java View source code |
/**
* Test simple message save/retrieve
*
* TODO: serverId vs. serverIntId
*/
@MediumTest
public void testMessageSave() {
Account account1 = ProviderTestUtils.setupAccount("message-save", true, mMockContext);
long account1Id = account1.mId;
Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, true, mMockContext);
long box1Id = box1.mId;
// Test a simple message (saved with no body)
Message message1 = ProviderTestUtils.setupMessage("message1", account1Id, box1Id, false, true, mMockContext);
long message1Id = message1.mId;
Message message1get = EmailContent.Message.restoreMessageWithId(mMockContext, message1Id);
ProviderTestUtils.assertMessageEqual("testMessageSave", message1, message1get);
// Test a message saved with a body
// Note that it will read back w/o the text & html so we must extract
// those
Message message2 = ProviderTestUtils.setupMessage("message1", account1Id, box1Id, true, true, mMockContext);
long message2Id = message2.mId;
String text2 = message2.mText;
String html2 = message2.mHtml;
long sourceKey2 = message2.mSourceKey;
message2.mText = null;
message2.mHtml = null;
message2.mSourceKey = 0;
Message message2get = EmailContent.Message.restoreMessageWithId(mMockContext, message2Id);
ProviderTestUtils.assertMessageEqual("testMessageSave", message2, message2get);
// Now see if there's a body saved with the right stuff
Body body2 = loadBodyForMessageId(message2Id);
assertEquals("body text", text2, body2.mTextContent);
assertEquals("body html", html2, body2.mHtmlContent);
assertEquals("source key", sourceKey2, body2.mSourceKey);
}
Example 97
Project: platform_packages_apps_email-master File: ProviderTests.java View source code |
/**
* Test simple message save/retrieve
*
* TODO: serverId vs. serverIntId
*/
@MediumTest
public void testMessageSave() {
Account account1 = ProviderTestUtils.setupAccount("message-save", true, mMockContext);
long account1Id = account1.mId;
Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, true, mMockContext);
long box1Id = box1.mId;
// Test a simple message (saved with no body)
Message message1 = ProviderTestUtils.setupMessage("message1", account1Id, box1Id, false, true, mMockContext);
long message1Id = message1.mId;
Message message1get = EmailContent.Message.restoreMessageWithId(mMockContext, message1Id);
ProviderTestUtils.assertMessageEqual("testMessageSave", message1, message1get);
// Test a message saved with a body
// Note that it will read back w/o the text & html so we must extract
// those
Message message2 = ProviderTestUtils.setupMessage("message1", account1Id, box1Id, true, true, mMockContext);
long message2Id = message2.mId;
String text2 = message2.mText;
String html2 = message2.mHtml;
long sourceKey2 = message2.mSourceKey;
message2.mText = null;
message2.mHtml = null;
message2.mSourceKey = 0;
Message message2get = EmailContent.Message.restoreMessageWithId(mMockContext, message2Id);
ProviderTestUtils.assertMessageEqual("testMessageSave", message2, message2get);
// Now see if there's a body saved with the right stuff
Body body2 = loadBodyForMessageId(message2Id);
assertEquals("body text", text2, body2.mTextContent);
assertEquals("body html", html2, body2.mHtmlContent);
assertEquals("source key", sourceKey2, body2.mSourceKey);
}
Example 98
Project: AndroidJUnit4-master File: AnnotatedWithMediumTest.java View source code |
@MediumTest
@Test
public void assertPreconditions() {
}
Example 99
Project: foursquared-dz-master File: FoursquaredAppTestCase.java View source code |
@MediumTest
public void testLocationMethods() {
createApplication();
getApplication().getLastKnownLocation();
getApplication().getLocationListener();
}
Example 100
Project: foursquared-master File: FoursquaredAppTestCase.java View source code |
@MediumTest
public void testLocationMethods() {
createApplication();
getApplication().getLastKnownLocation();
getApplication().getLocationListener();
}
Example 101
Project: Hancel-master File: ActivityTest.java View source code |
@MediumTest
@UiThreadTest
public void testSharedPreferencesJSON() {
testSharedPreferencesImpl(PreferenceImpl.JSON);
}