I need to check if the text size on a button have the size 37sp.
I found a method to get the size with: .getTextSize()
, but the size with I receive is: 126.0
, and not 48sp
.
The code off button:
<Button
android:id="@+id/buttoneql"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="="
android:textColor="@android:color/black"
android:textSize="48sp" />
The test:
buttoneql = (Button) currentActivity.findViewById(R.id.buttoneql);
assertEquals( 48.0f, buttoneql.getTextSize() );
How I should do to recive the ral value of the text size?
I solved the problem by multiplying the value I need (128.0) by 2.625 and rounding it up correctly to make it an integer.
int size = (int) Math.round (48.0 * 2.625);
And after, comparing to the receive value:
assertEquals(size, (int) buttoneql.getTextSize());