use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ParanoidAndroid.
the class SafeSaxTest method testListener.
@SmallTest
public void testListener() throws Exception {
String xml = "<feed xmlns='http://www.w3.org/2005/Atom'>\n" + "<entry>\n" + "<id>a</id>\n" + "</entry>\n" + "<entry>\n" + "<id>b</id>\n" + "</entry>\n" + "</feed>\n";
RootElement root = new RootElement(ATOM_NAMESPACE, "feed");
Element entry = root.requireChild(ATOM_NAMESPACE, "entry");
Element id = entry.requireChild(ATOM_NAMESPACE, "id");
ElementCounter rootCounter = new ElementCounter();
ElementCounter entryCounter = new ElementCounter();
TextElementCounter idCounter = new TextElementCounter();
root.setElementListener(rootCounter);
entry.setElementListener(entryCounter);
id.setTextElementListener(idCounter);
Xml.parse(xml, root.getContentHandler());
assertEquals(1, rootCounter.starts);
assertEquals(1, rootCounter.ends);
assertEquals(2, entryCounter.starts);
assertEquals(2, entryCounter.ends);
assertEquals(2, idCounter.starts);
assertEquals("ab", idCounter.bodies);
}
use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ParanoidAndroid.
the class SafeSaxTest method testMissingRequiredChild.
@SmallTest
public void testMissingRequiredChild() throws Exception {
String xml = "<feed></feed>";
RootElement root = new RootElement("feed");
root.requireChild("entry");
try {
Xml.parse(xml, root.getContentHandler());
fail("expected exception not thrown");
} catch (SAXException e) {
// Expected.
}
}
use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ParanoidAndroid.
the class TestContext method testSyncableMigration.
@SmallTest
public void testSyncableMigration() throws Exception {
final Account account = new Account("acc", "type");
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=\"acc\" authority=\"other1\" />\n" + "<authority id=\"1\" account=\"acc\" type=\"type\" authority=\"other2\" />\n" + "<authority id=\"2\" account=\"acc\" type=\"type\" syncable=\"false\"" + " authority=\"other3\" />\n" + "<authority id=\"3\" account=\"acc\" type=\"type\" syncable=\"true\"" + " authority=\"other4\" />\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(-1, engine.getIsSyncable(account, 0, "other1"));
assertEquals(1, engine.getIsSyncable(account, 0, "other2"));
assertEquals(0, engine.getIsSyncable(account, 0, "other3"));
assertEquals(1, engine.getIsSyncable(account, 0, "other4"));
}
use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ParanoidAndroid.
the class SocketTest method testServerSocketClose.
// Regression test for #865753: server sockets not closing properly
@SmallTest
public void testServerSocketClose() throws Exception {
ServerSocket s3 = new ServerSocket(23456);
s3.close();
ServerSocket s4 = new ServerSocket(23456);
s4.close();
}
use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ParanoidAndroid.
the class SocketTest method testSocketSimple.
// Test for basic bind/connect/accept behavior.
@SmallTest
public void testSocketSimple() throws Exception {
ServerSocket ss;
Socket s, s1;
int port;
IOException lastEx = null;
ss = new ServerSocket();
for (port = 9900; port < 9999; port++) {
try {
ss.bind(new InetSocketAddress("127.0.0.1", port));
lastEx = null;
break;
} catch (IOException ex) {
lastEx = ex;
}
}
if (lastEx != null) {
throw lastEx;
}
s = new Socket("127.0.0.1", port);
s1 = ss.accept();
s.getOutputStream().write(0xa5);
assertEquals(0xa5, s1.getInputStream().read());
s1.getOutputStream().write(0x5a);
assertEquals(0x5a, s.getInputStream().read());
}
Aggregations