use of android.test.suitebuilder.annotation.MediumTest in project android_frameworks_base by ParanoidAndroid.
the class AccessibilityManagerTest method testGetAccessibilityServiceList.
@MediumTest
public void testGetAccessibilityServiceList() throws Exception {
// create a list of installed accessibility services the mock service returns
List<AccessibilityServiceInfo> expectedServices = new ArrayList<AccessibilityServiceInfo>();
AccessibilityServiceInfo accessibilityServiceInfo = new AccessibilityServiceInfo();
accessibilityServiceInfo.packageNames = new String[] { "foo.bar" };
expectedServices.add(accessibilityServiceInfo);
// configure the mock service behavior
IAccessibilityManager mockServiceInterface = mMockServiceInterface;
expect(mockServiceInterface.addClient(anyIAccessibilityManagerClient(), UserHandle.USER_OWNER)).andReturn(AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED);
expect(mockServiceInterface.getInstalledAccessibilityServiceList(UserHandle.USER_OWNER)).andReturn(expectedServices);
replay(mockServiceInterface);
// invoke the method under test
AccessibilityManager manager = new AccessibilityManager(mContext, mockServiceInterface, UserHandle.USER_OWNER);
List<AccessibilityServiceInfo> receivedServices = manager.getInstalledAccessibilityServiceList();
// check expected result (list equals() compares it contents as well)
assertEquals("All expected services must be returned", receivedServices, expectedServices);
// verify the mock service was properly called
verify(mockServiceInterface);
}
use of android.test.suitebuilder.annotation.MediumTest in project android_frameworks_base by ParanoidAndroid.
the class TestContext method testAuthorityRenaming.
@MediumTest
public void testAuthorityRenaming() throws Exception {
final Account account1 = new Account("acc1", "type1");
final Account account2 = new Account("acc2", "type2");
final String authorityContacts = "contacts";
final String authorityCalendar = "calendar";
final String authorityOther = "other";
final String authorityContactsNew = "com.android.contacts";
final String authorityCalendarNew = "com.android.calendar";
MockContentResolver mockResolver = new MockContentResolver();
final TestContext testContext = new TestContext(mockResolver, getContext());
byte[] accountsFileData = ("<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n" + "<accounts>\n" + "<authority id=\"0\" account=\"acc1\" type=\"type1\" authority=\"contacts\" />\n" + "<authority id=\"1\" account=\"acc1\" type=\"type1\" authority=\"calendar\" />\n" + "<authority id=\"2\" account=\"acc1\" type=\"type1\" authority=\"other\" />\n" + "<authority id=\"3\" account=\"acc2\" type=\"type2\" authority=\"contacts\" />\n" + "<authority id=\"4\" account=\"acc2\" type=\"type2\" authority=\"calendar\" />\n" + "<authority id=\"5\" account=\"acc2\" type=\"type2\" authority=\"other\" />\n" + "<authority id=\"6\" account=\"acc2\" type=\"type2\" enabled=\"false\"" + " authority=\"com.android.calendar\" />\n" + "<authority id=\"7\" account=\"acc2\" type=\"type2\" enabled=\"false\"" + " authority=\"com.android.contacts\" />\n" + "</accounts>\n").getBytes();
File syncDir = new File(new File(testContext.getFilesDir(), "system"), "sync");
syncDir.mkdirs();
AtomicFile accountInfoFile = new AtomicFile(new File(syncDir, "accounts.xml"));
FileOutputStream fos = accountInfoFile.startWrite();
fos.write(accountsFileData);
accountInfoFile.finishWrite(fos);
SyncStorageEngine engine = SyncStorageEngine.newTestInstance(testContext);
assertEquals(false, engine.getSyncAutomatically(account1, 0, authorityContacts));
assertEquals(false, engine.getSyncAutomatically(account1, 0, authorityCalendar));
assertEquals(true, engine.getSyncAutomatically(account1, 0, authorityOther));
assertEquals(true, engine.getSyncAutomatically(account1, 0, authorityContactsNew));
assertEquals(true, engine.getSyncAutomatically(account1, 0, authorityCalendarNew));
assertEquals(false, engine.getSyncAutomatically(account2, 0, authorityContacts));
assertEquals(false, engine.getSyncAutomatically(account2, 0, authorityCalendar));
assertEquals(true, engine.getSyncAutomatically(account2, 0, authorityOther));
assertEquals(false, engine.getSyncAutomatically(account2, 0, authorityContactsNew));
assertEquals(false, engine.getSyncAutomatically(account2, 0, authorityCalendarNew));
}
use of android.test.suitebuilder.annotation.MediumTest in project android_frameworks_base by ParanoidAndroid.
the class TestContext method testListenForTicklesParsing.
@MediumTest
public void testListenForTicklesParsing() throws Exception {
byte[] accountsFileData = ("<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n" + "<accounts>\n" + "<listenForTickles user=\"0\" enabled=\"false\" />" + "<listenForTickles user=\"1\" enabled=\"true\" />" + "<authority id=\"0\" user=\"0\" account=\"account1\" type=\"type1\" authority=\"auth1\" />\n" + "<authority id=\"1\" user=\"1\" account=\"account1\" type=\"type1\" authority=\"auth1\" />\n" + "</accounts>\n").getBytes();
MockContentResolver mockResolver = new MockContentResolver();
final TestContext testContext = new TestContext(mockResolver, getContext());
File syncDir = getSyncDir();
syncDir.mkdirs();
AtomicFile accountInfoFile = new AtomicFile(new File(syncDir, "accounts.xml"));
FileOutputStream fos = accountInfoFile.startWrite();
fos.write(accountsFileData);
accountInfoFile.finishWrite(fos);
SyncStorageEngine engine = SyncStorageEngine.newTestInstance(testContext);
assertEquals(false, engine.getMasterSyncAutomatically(0));
assertEquals(true, engine.getMasterSyncAutomatically(1));
assertEquals(true, engine.getMasterSyncAutomatically(2));
}
use of android.test.suitebuilder.annotation.MediumTest in project android_frameworks_base by ParanoidAndroid.
the class AnimatorSetEventsTest method testPlayingCancelDuringChildDelay.
/**
* Tests that an AnimatorSet can be correctly canceled during the delay of one of
* its children
*/
@MediumTest
public void testPlayingCancelDuringChildDelay() throws Exception {
yAnim.setStartDelay(500);
final AnimatorSet animSet = new AnimatorSet();
animSet.playSequentially(xAnim, yAnim);
mFutureListener = new FutureReleaseListener(mFuture);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
try {
Handler handler = new Handler();
animSet.addListener(mFutureListener);
mRunning = true;
animSet.start();
handler.postDelayed(new Canceler(animSet, mFuture), ANIM_DURATION + 250);
} catch (junit.framework.AssertionFailedError e) {
mFuture.setException(new RuntimeException(e));
}
}
});
mFuture.get(getTimeout(), TimeUnit.MILLISECONDS);
}
use of android.test.suitebuilder.annotation.MediumTest in project android_frameworks_base by ParanoidAndroid.
the class EventsTest method testPlayingEnd.
/**
* Verify that ending an animator that is playing does the right thing.
*/
@MediumTest
public void testPlayingEnd() throws Exception {
mFutureListener = new FutureReleaseListener(mFuture);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
try {
Handler handler = new Handler();
mAnimator.addListener(mFutureListener);
mRunning = true;
mAnimator.start();
handler.postDelayed(new Ender(mAnimator, mFuture), ANIM_MID_DURATION);
} catch (junit.framework.AssertionFailedError e) {
mFuture.setException(new RuntimeException(e));
}
}
});
mFuture.get(getTimeout(), TimeUnit.MILLISECONDS);
}
Aggregations