Skip to content

Commit

Permalink
Update TextStyleBuilderTest.java
Browse files Browse the repository at this point in the history
  • Loading branch information
rtz333 authored and burhanrashid52 committed Jul 9, 2021
1 parent de2c685 commit 70af8ba
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public void testFillSomeRandomItemsAndLetOthersUnset() {
Assert.assertFalse(builder.getValues().containsKey(TextStyleBuilder.TextStyle.BACKGROUND));

Assert.assertFalse(builder.getValues().containsKey(TextStyleBuilder.TextStyle.TEXT_APPEARANCE));

Assert.assertFalse(builder.getValues().containsKey(TextStyleBuilder.TextStyle.TEXT_STYLE));
Assert.assertFalse(builder.getValues().containsKey(TextStyleBuilder.TextStyle.TEXT_FLAG));
Assert.assertFalse(builder.getValues().containsKey(TextStyleBuilder.TextStyle.SHADOW));
Assert.assertFalse(builder.getValues().containsKey(TextStyleBuilder.TextStyle.BORDER));
}

@Test
Expand All @@ -117,6 +122,10 @@ public void testApplyStyleShouldCallTheCorrectApplyMethod() {
Assert.assertTrue(builder.backgroundColorApplied);
Assert.assertTrue(builder.textAppearanceApplied);
Assert.assertFalse(builder.backgroundDrawableApplied);
Assert.assertTrue(builder.textStyle);
Assert.assertTrue(builder.textFlag);
Assert.assertTrue(builder.textShadow1);
Assert.assertTrue(builder.textBorder1);
}

@Test
Expand All @@ -134,6 +143,10 @@ public void testApplyBackgroundDrawableStyleShouldCallBackgroundDrawableApplyMet
Assert.assertFalse(builder.backgroundColorApplied);
Assert.assertFalse(builder.textAppearanceApplied);
Assert.assertTrue(builder.backgroundDrawableApplied);
Assert.assertFalse(builder.textStyle);
Assert.assertFalse(builder.textFlag);
Assert.assertFalse(builder.textShadow1);
Assert.assertFalse(builder.textBorder1);
}

@Test
Expand All @@ -150,6 +163,10 @@ public void testApplyStyleShouldCallNoOneApplyMethod() {
Assert.assertFalse(builder.backgroundColorApplied);
Assert.assertFalse(builder.textAppearanceApplied);
Assert.assertFalse(builder.backgroundDrawableApplied);
Assert.assertFalse(builder.textStyle);
Assert.assertFalse(builder.textFlag);
Assert.assertFalse(builder.textShadow1);
Assert.assertFalse(builder.textBorder1);
}

private class MockTextStyleBuilder extends TextStyleBuilder {
Expand All @@ -160,6 +177,30 @@ private class MockTextStyleBuilder extends TextStyleBuilder {
boolean backgroundColorApplied = false;
boolean backgroundDrawableApplied = false;
boolean textAppearanceApplied = false;
boolean textStyle=false;
boolean textFlag=false;
boolean textShadow1=false;
boolean textBorder1=false;

@Override
protected void applyTextStyle(TextView textView, int typeface) {
textStyle=true;
}

@Override
protected void applyTextFlag(TextView textView, int flag) {
textFlag=true;
}

@Override
protected void applyTextShadow(TextView textView, TextShadow textShadow) {
textShadow1=true;
}

@Override
protected void applyTextBorder(TextView textView, TextBorder textBorder) {
textBorder1=true;
}

@Override
protected void applyTextSize(TextView textView, float size) {
Expand Down Expand Up @@ -195,5 +236,7 @@ protected void applyBackgroundColor(TextView textView, int color) {
protected void applyBackgroundDrawable(TextView textView, Drawable bg) {
backgroundDrawableApplied = true;
}


}
}

0 comments on commit 70af8ba

Please sign in to comment.