Search in sources :

Example 56 with SmallTest

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

the class IpPrefixTest method testMappedAddressesAreBroken.

@SmallTest
public void testMappedAddressesAreBroken() {
    // 192.0.2.0/24 != ::ffff:c000:0204/120, but because we use InetAddress,
    // we are unable to comprehend that.
    byte[] ipv6bytes = { (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0xff, (byte) 0xff, (byte) 192, (byte) 0, (byte) 2, (byte) 0 };
    IpPrefix p = new IpPrefix(ipv6bytes, 120);
    // Fine.
    assertEquals(16, p.getRawAddress().length);
    // Fine.
    assertArrayEquals(ipv6bytes, p.getRawAddress());
    // Broken.
    assertEquals("192.0.2.0/120", p.toString());
    assertEquals(InetAddress.parseNumericAddress("192.0.2.0"), p.getAddress());
}
Also used : IpPrefix(android.net.IpPrefix) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 57 with SmallTest

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

the class IpPrefixTest method testHashCode.

@SmallTest
public void testHashCode() {
    IpPrefix p;
    int oldCode = -1;
    Random random = new Random();
    for (int i = 0; i < 100; i++) {
        if (random.nextBoolean()) {
            // IPv4.
            byte[] b = new byte[4];
            random.nextBytes(b);
            p = new IpPrefix(b, random.nextInt(33));
            assertNotEqual(oldCode, p.hashCode());
            oldCode = p.hashCode();
        } else {
            // IPv6.
            byte[] b = new byte[16];
            random.nextBytes(b);
            p = new IpPrefix(b, random.nextInt(129));
            assertNotEqual(oldCode, p.hashCode());
            oldCode = p.hashCode();
        }
    }
}
Also used : IpPrefix(android.net.IpPrefix) Random(java.util.Random) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 58 with SmallTest

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

the class PaintTest method testHintingWidth.

@SmallTest
public void testHintingWidth() {
    final Typeface fontTypeface = Typeface.createFromAsset(getInstrumentation().getContext().getAssets(), FONT_PATH);
    Paint paint = new Paint();
    paint.setTypeface(fontTypeface);
    for (int i = 0; i < HINTING_TESTCASES.length; ++i) {
        HintingTestCase testCase = HINTING_TESTCASES[i];
        paint.setTextSize(testCase.mTextSize);
        float[] widths = new float[testCase.mText.length()];
        paint.setHinting(Paint.HINTING_OFF);
        paint.getTextWidths(String.valueOf(testCase.mText), widths);
        assertEquals("Text width of '" + testCase.mText + "' without hinting is not expected.", testCase.mWidthWithoutHinting, widths);
        paint.setHinting(Paint.HINTING_ON);
        paint.getTextWidths(String.valueOf(testCase.mText), widths);
        assertEquals("Text width of '" + testCase.mText + "' with hinting is not expected.", testCase.mWidthWithHinting, widths);
    }
}
Also used : Paint(android.graphics.Paint) Paint(android.graphics.Paint) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 59 with SmallTest

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

the class SpannedTest method testWrapParcel.

@SmallTest
public void testWrapParcel() {
    SpannableString s = new SpannableString("Hello there world");
    CharacterStyle mark = new StyleSpan(Typeface.BOLD);
    s.setSpan(mark, 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    s.setSpan(CharacterStyle.wrap(mark), 3, 7, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    s.setSpan(new TextAppearanceSpan("mono", 0, -1, null, null), 7, 8, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    s.setSpan(CharacterStyle.wrap(new TypefaceSpan("mono")), 8, 9, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    Parcel p = Parcel.obtain();
    TextUtils.writeToParcel(s, p, 0);
    p.setDataPosition(0);
    Spanned s2 = (Spanned) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(p);
    StyleSpan[] style;
    style = s2.getSpans(1, 2, StyleSpan.class);
    assertEquals(1, style.length);
    assertEquals(1, s2.getSpanStart(style[0]));
    assertEquals(2, s2.getSpanEnd(style[0]));
    style = s2.getSpans(3, 7, StyleSpan.class);
    assertEquals(1, style.length);
    assertEquals(3, s2.getSpanStart(style[0]));
    assertEquals(7, s2.getSpanEnd(style[0]));
    TextAppearanceSpan[] appearance = s2.getSpans(7, 8, TextAppearanceSpan.class);
    assertEquals(1, appearance.length);
    assertEquals(7, s2.getSpanStart(appearance[0]));
    assertEquals(8, s2.getSpanEnd(appearance[0]));
    TypefaceSpan[] tf = s2.getSpans(8, 9, TypefaceSpan.class);
    assertEquals(1, tf.length);
    assertEquals(8, s2.getSpanStart(tf[0]));
    assertEquals(9, s2.getSpanEnd(tf[0]));
}
Also used : Parcel(android.os.Parcel) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 60 with SmallTest

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

the class TextUtilsTest method testCharSequenceCreatorNull.

@SmallTest
public void testCharSequenceCreatorNull() {
    Parcel p;
    CharSequence text;
    p = Parcel.obtain();
    TextUtils.writeToParcel(null, p, 0);
    p.setDataPosition(0);
    text = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(p);
    assertNull("null CharSequence should generate null from parcel", text);
}
Also used : Parcel(android.os.Parcel) 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