TypefaceTestpublic class TypefaceTest extends TestCase
Fields Summary |
---|
private final android.graphics.Typeface[] | mFaces |
Methods Summary |
---|
public void | testBasic()
assertTrue("basic", Typeface.DEFAULT != null);
assertTrue("basic", Typeface.DEFAULT_BOLD != null);
assertTrue("basic", Typeface.SANS_SERIF != null);
assertTrue("basic", Typeface.SERIF != null);
assertTrue("basic", Typeface.MONOSPACE != null);
| public void | testStyles()
assertTrue("style", mFaces[0].getStyle() == Typeface.NORMAL);
assertTrue("style", mFaces[1].getStyle() == Typeface.BOLD);
assertTrue("style", mFaces[2].getStyle() == Typeface.NORMAL);
assertTrue("style", mFaces[3].getStyle() == Typeface.BOLD);
assertTrue("style", mFaces[4].getStyle() == Typeface.ITALIC);
assertTrue("style", mFaces[5].getStyle() == Typeface.BOLD_ITALIC);
assertTrue("style", mFaces[6].getStyle() == Typeface.NORMAL);
| public void | testUniformY()
Paint p = new Paint();
final int n = mFaces.length;
for (int i = 1; i <= 36; i++) {
p.setTextSize(i);
float ascent = 0;
float descent = 0;
for (int j = 0; j < n; j++) {
p.setTypeface(mFaces[j]);
Paint.FontMetrics fm = p.getFontMetrics();
if (j == 0) {
ascent = fm.ascent;
descent = fm.descent;
} else {
assertTrue("fontMetrics", fm.ascent == ascent);
assertTrue("fontMetrics", fm.descent == descent);
}
}
}
| public void | testUnique()
final int n = mFaces.length;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
assertTrue("unique", mFaces[i] != mFaces[j]);
}
}
|
|