Search in sources :

Example 1 with SmallTest

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);
}
Also used : RootElement(android.sax.RootElement) Element(android.sax.Element) RootElement(android.sax.RootElement) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 2 with SmallTest

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.
    }
}
Also used : RootElement(android.sax.RootElement) SAXException(org.xml.sax.SAXException) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 3 with SmallTest

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"));
}
Also used : Account(android.accounts.Account) AtomicFile(com.android.internal.os.AtomicFile) FileOutputStream(java.io.FileOutputStream) MockContentResolver(android.test.mock.MockContentResolver) File(java.io.File) AtomicFile(com.android.internal.os.AtomicFile) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 4 with SmallTest

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();
}
Also used : ServerSocket(java.net.ServerSocket) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 5 with SmallTest

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());
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ServerSocket(java.net.ServerSocket) IOException(java.io.IOException) Socket(java.net.Socket) ServerSocket(java.net.ServerSocket) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

SmallTest (android.test.suitebuilder.annotation.SmallTest)2108 Test (org.junit.Test)235 Parcel (android.os.Parcel)153 ArrayList (java.util.ArrayList)104 Time (android.text.format.Time)97 Rect (android.graphics.Rect)94 TelephonyTest (com.android.internal.telephony.TelephonyTest)84 Bundle (android.os.Bundle)77 ByteBuffer (java.nio.ByteBuffer)71 Intent (android.content.Intent)69 LinkProperties (android.net.LinkProperties)68 SpannableString (android.text.SpannableString)61 FlakyTest (android.support.test.filters.FlakyTest)58 DhcpPacket (android.net.dhcp.DhcpPacket)52 Rational (android.util.Rational)50 NetworkRequest (android.net.NetworkRequest)48 File (java.io.File)47 RouteInfo (android.net.RouteInfo)45 BitwiseOutputStream (com.android.internal.util.BitwiseOutputStream)45 ParcelUuid (android.os.ParcelUuid)43