|
| 1 | +package com.google.unity.ads.nativead; |
| 2 | + |
| 3 | +import static com.google.common.truth.Truth.assertThat; |
| 4 | + |
| 5 | +import com.google.testing.junit.testparameterinjector.TestParameter; |
| 6 | +import org.junit.Test; |
| 7 | +import org.junit.runner.RunWith; |
| 8 | +import org.robolectric.RobolectricTestParameterInjector; |
| 9 | + |
| 10 | +/** Tests for {@link UnityNativeTemplateFontStyle} */ |
| 11 | +@RunWith(RobolectricTestParameterInjector.class) |
| 12 | +public final class UnityNativeTemplateFontStyleTest { |
| 13 | + |
| 14 | + private enum FontStyleTestCase { |
| 15 | + INVALID_INDEX(-1, UnityNativeTemplateFontStyle.NORMAL), // should return default value |
| 16 | + NORMAL(0, UnityNativeTemplateFontStyle.NORMAL), |
| 17 | + BOLD(1, UnityNativeTemplateFontStyle.BOLD), |
| 18 | + ITALIC(2, UnityNativeTemplateFontStyle.ITALIC), |
| 19 | + MONOSPACE(3, UnityNativeTemplateFontStyle.MONOSPACE), |
| 20 | + MISSING_INDEX(4, UnityNativeTemplateFontStyle.NORMAL); // should return default value |
| 21 | + |
| 22 | + final int intValue; |
| 23 | + final UnityNativeTemplateFontStyle expectedFontStyle; |
| 24 | + |
| 25 | + FontStyleTestCase(int intValue, UnityNativeTemplateFontStyle expectedFontStyle) { |
| 26 | + this.intValue = intValue; |
| 27 | + this.expectedFontStyle = expectedFontStyle; |
| 28 | + } |
| 29 | + } |
| 30 | + |
| 31 | + @Test |
| 32 | + public void fromIntValue_returnsCorrectFontStyle(@TestParameter FontStyleTestCase testCase) |
| 33 | + throws Exception { |
| 34 | + UnityNativeTemplateFontStyle gotFontStyle = |
| 35 | + UnityNativeTemplateFontStyle.fromIntValue(testCase.intValue); |
| 36 | + assertThat(gotFontStyle).isEqualTo(testCase.expectedFontStyle); |
| 37 | + assertThat(gotFontStyle.getTypeface()).isNotNull(); |
| 38 | + assertThat(gotFontStyle.getTypeface()).isEqualTo(testCase.expectedFontStyle.getTypeface()); |
| 39 | + } |
| 40 | +} |
0 commit comments