Search in sources :

Example 81 with SmallTest

use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ResurrectionRemix.

the class PatternsTest method testIanaTopLevelDomains_matchesIriTLD.

@SmallTest
public void testIanaTopLevelDomains_matchesIriTLD() throws Exception {
    Pattern pattern = Pattern.compile(Patterns.IANA_TOP_LEVEL_DOMAINS);
    assertTrue("Should match IRI TLD", pattern.matcher("한국").matches());
}
Also used : Pattern(java.util.regex.Pattern) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 82 with SmallTest

use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ResurrectionRemix.

the class StateMachineTest method testStateMachineQuitNow.

@SmallTest
public void testStateMachineQuitNow() throws Exception {
    if (WAIT_FOR_DEBUGGER)
        Debug.waitForDebugger();
    StateMachineQuitNowTest smQuitNowTest = new StateMachineQuitNowTest("smQuitNowTest");
    smQuitNowTest.start();
    if (smQuitNowTest.isDbg())
        tlog("testStateMachineQuitNow E");
    synchronized (smQuitNowTest) {
        // we send 6 only one will be processed.
        for (int i = 1; i <= 6; i++) {
            smQuitNowTest.sendMessage(smQuitNowTest.obtainMessage(i));
        }
        try {
            // wait for the messages to be handled
            smQuitNowTest.wait();
        } catch (InterruptedException e) {
            tloge("testStateMachineQuitNow: exception while waiting " + e.getMessage());
        }
    }
    tlog("testStateMachineQuiteNow: logRecs=" + smQuitNowTest.mLogRecs);
    assertEquals(3, smQuitNowTest.mLogRecs.size());
    Iterator<LogRec> itr = smQuitNowTest.mLogRecs.iterator();
    LogRec lr = itr.next();
    assertEquals(1, lr.getWhat());
    assertEquals(smQuitNowTest.mS1, lr.getState());
    assertEquals(smQuitNowTest.mS1, lr.getOriginalState());
    lr = itr.next();
    assertEquals(EXIT, lr.getInfo());
    assertEquals(smQuitNowTest.mS1, lr.getState());
    lr = itr.next();
    assertEquals(ON_QUITTING, lr.getInfo());
    if (smQuitNowTest.isDbg())
        tlog("testStateMachineQuitNow X");
}
Also used : LogRec(com.android.internal.util.StateMachine.LogRec) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 83 with SmallTest

use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ResurrectionRemix.

the class RationalTest method testConstructor.

@SmallTest
public void testConstructor() {
    // Simple case
    Rational r = new Rational(1, 2);
    assertEquals(1, r.getNumerator());
    assertEquals(2, r.getDenominator());
    // Denominator negative
    r = new Rational(-1, 2);
    assertEquals(-1, r.getNumerator());
    assertEquals(2, r.getDenominator());
    // Numerator negative
    r = new Rational(1, -2);
    assertEquals(-1, r.getNumerator());
    assertEquals(2, r.getDenominator());
    // Both negative
    r = new Rational(-1, -2);
    assertEquals(1, r.getNumerator());
    assertEquals(2, r.getDenominator());
    // Infinity.
    r = new Rational(1, 0);
    assertEquals(1, r.getNumerator());
    assertEquals(0, r.getDenominator());
    // Negative infinity.
    r = new Rational(-1, 0);
    assertEquals(-1, r.getNumerator());
    assertEquals(0, r.getDenominator());
    // NaN.
    r = new Rational(0, 0);
    assertEquals(0, r.getNumerator());
    assertEquals(0, r.getDenominator());
}
Also used : Rational(android.util.Rational) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 84 with SmallTest

use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ResurrectionRemix.

the class RationalTest method testCompareTo.

@SmallTest
public void testCompareTo() {
    // unit is equal to itself
    assertCompareEquals(UNIT, new Rational(1, 1));
    // NaN is greater than anything but NaN
    assertCompareEquals(NaN, new Rational(0, 0));
    assertGreaterThan(NaN, UNIT);
    assertGreaterThan(NaN, POSITIVE_INFINITY);
    assertGreaterThan(NaN, NEGATIVE_INFINITY);
    assertGreaterThan(NaN, ZERO);
    // Positive infinity is greater than any other non-NaN
    assertCompareEquals(POSITIVE_INFINITY, new Rational(1, 0));
    assertGreaterThan(POSITIVE_INFINITY, UNIT);
    assertGreaterThan(POSITIVE_INFINITY, NEGATIVE_INFINITY);
    assertGreaterThan(POSITIVE_INFINITY, ZERO);
    // Negative infinity is smaller than any other non-NaN
    assertCompareEquals(NEGATIVE_INFINITY, new Rational(-1, 0));
    assertLessThan(NEGATIVE_INFINITY, UNIT);
    assertLessThan(NEGATIVE_INFINITY, POSITIVE_INFINITY);
    assertLessThan(NEGATIVE_INFINITY, ZERO);
    // A finite number with the same denominator is trivially comparable
    assertGreaterThan(new Rational(3, 100), new Rational(1, 100));
    assertGreaterThan(new Rational(3, 100), ZERO);
    // Compare finite numbers with different divisors
    assertGreaterThan(new Rational(5, 25), new Rational(1, 10));
    assertGreaterThan(new Rational(5, 25), ZERO);
    // Compare finite numbers with different signs
    assertGreaterThan(new Rational(5, 25), new Rational(-1, 10));
    assertLessThan(new Rational(-5, 25), ZERO);
}
Also used : Rational(android.util.Rational) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 85 with SmallTest

use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ResurrectionRemix.

the class RationalTest method testEquals.

@SmallTest
public void testEquals() {
    Rational r = new Rational(1, 2);
    assertEquals(1, r.getNumerator());
    assertEquals(2, r.getDenominator());
    assertEquals(r, r);
    assertFalse(r.equals(null));
    assertFalse(r.equals(new Object()));
    Rational twoThirds = new Rational(2, 3);
    assertFalse(r.equals(twoThirds));
    assertFalse(twoThirds.equals(r));
    Rational fourSixths = new Rational(4, 6);
    assertEquals(twoThirds, fourSixths);
    assertEquals(fourSixths, twoThirds);
    Rational moreComplicated = new Rational(5 * 6 * 7 * 8 * 9, 1 * 2 * 3 * 4 * 5);
    Rational moreComplicated2 = new Rational(5 * 6 * 7 * 8 * 9 * 78, 1 * 2 * 3 * 4 * 5 * 78);
    assertEquals(moreComplicated, moreComplicated2);
    assertEquals(moreComplicated2, moreComplicated);
    // Ensure negatives are fine
    twoThirds = new Rational(-2, 3);
    fourSixths = new Rational(-4, 6);
    assertEquals(twoThirds, fourSixths);
    assertEquals(fourSixths, twoThirds);
    moreComplicated = new Rational(-5 * 6 * 7 * 8 * 9, 1 * 2 * 3 * 4 * 5);
    moreComplicated2 = new Rational(-5 * 6 * 7 * 8 * 9 * 78, 1 * 2 * 3 * 4 * 5 * 78);
    assertEquals(moreComplicated, moreComplicated2);
    assertEquals(moreComplicated2, moreComplicated);
    // Zero is always equal to itself
    Rational zero2 = new Rational(0, 100);
    assertEquals(ZERO, zero2);
    assertEquals(zero2, ZERO);
    // NaN is always equal to itself
    Rational nan = NaN;
    Rational nan2 = new Rational(0, 0);
    assertTrue(nan.equals(nan));
    assertTrue(nan.equals(nan2));
    assertTrue(nan2.equals(nan));
    assertFalse(nan.equals(r));
    assertFalse(r.equals(nan));
    // Infinities of the same sign are equal.
    Rational posInf = POSITIVE_INFINITY;
    Rational posInf2 = new Rational(2, 0);
    Rational negInf = NEGATIVE_INFINITY;
    Rational negInf2 = new Rational(-2, 0);
    assertEquals(posInf, posInf);
    assertEquals(negInf, negInf);
    assertEquals(posInf, posInf2);
    assertEquals(negInf, negInf2);
    // Infinities aren't equal to anything else.
    assertFalse(posInf.equals(negInf));
    assertFalse(negInf.equals(posInf));
    assertFalse(negInf.equals(r));
    assertFalse(posInf.equals(r));
    assertFalse(r.equals(negInf));
    assertFalse(r.equals(posInf));
    assertFalse(posInf.equals(nan));
    assertFalse(negInf.equals(nan));
    assertFalse(nan.equals(posInf));
    assertFalse(nan.equals(negInf));
}
Also used : Rational(android.util.Rational) 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