|
| 1 | +package com.google.unity.ads.nativead; |
| 2 | + |
| 3 | +import static com.google.common.truth.Truth.assertThat; |
| 4 | + |
| 5 | +import android.graphics.Color; |
| 6 | +import android.graphics.drawable.ColorDrawable; |
| 7 | +import org.junit.Before; |
| 8 | +import org.junit.Test; |
| 9 | +import org.junit.runner.RunWith; |
| 10 | +import org.robolectric.RobolectricTestRunner; |
| 11 | + |
| 12 | +/** Tests for {@link UnityNativeTemplateTextStyle} */ |
| 13 | +@RunWith(RobolectricTestRunner.class) |
| 14 | +public final class UnityNativeTemplateTextStyleTest { |
| 15 | + |
| 16 | + private UnityNativeTemplateTextStyle unityNativeTemplateTextStyle; |
| 17 | + |
| 18 | + @Before |
| 19 | + public void setUp() { |
| 20 | + unityNativeTemplateTextStyle = |
| 21 | + new UnityNativeTemplateTextStyle( |
| 22 | + /* textColor= */ new ColorDrawable(Color.RED), |
| 23 | + /* backgroundColor= */ new ColorDrawable(Color.BLUE), |
| 24 | + /* fontStyle= */ UnityNativeTemplateFontStyle.ITALIC, |
| 25 | + /* size= */ 10.0); |
| 26 | + } |
| 27 | + |
| 28 | + @Test |
| 29 | + public void unityNativeTemplateTextStyle_canBeInstantiated() throws Exception { |
| 30 | + assertThat(unityNativeTemplateTextStyle.getTextColor().getColor()).isEqualTo(Color.RED); |
| 31 | + assertThat(unityNativeTemplateTextStyle.getBackgroundColor().getColor()).isEqualTo(Color.BLUE); |
| 32 | + assertThat(unityNativeTemplateTextStyle.getFontStyle()) |
| 33 | + .isEqualTo(UnityNativeTemplateFontStyle.ITALIC); |
| 34 | + assertThat(unityNativeTemplateTextStyle.getSize()).isEqualTo(10.0f); |
| 35 | + assertThat(unityNativeTemplateTextStyle.hashCode()).isNotEqualTo(0); |
| 36 | + } |
| 37 | + |
| 38 | + @Test |
| 39 | + public void unityNativeTemplateTextStyle_canBeCompared() throws Exception { |
| 40 | + UnityNativeTemplateTextStyle anotherUnityNativeTemplateTextStyle = |
| 41 | + new UnityNativeTemplateTextStyle( |
| 42 | + new ColorDrawable(Color.GREEN), |
| 43 | + new ColorDrawable(Color.YELLOW), |
| 44 | + UnityNativeTemplateFontStyle.BOLD, |
| 45 | + 30.0); |
| 46 | + assertThat(unityNativeTemplateTextStyle).isNotEqualTo(anotherUnityNativeTemplateTextStyle); |
| 47 | + assertThat(unityNativeTemplateTextStyle.hashCode()) |
| 48 | + .isNotEqualTo(anotherUnityNativeTemplateTextStyle.hashCode()); |
| 49 | + } |
| 50 | +} |
0 commit comments