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());
}
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();
}
}
}
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);
}
}
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]));
}
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);
}
Aggregations