|
| 1 | +package com.d4rk.androidtutorials.java.utils; |
| 2 | + |
| 3 | +import static org.mockito.Mockito.mock; |
| 4 | +import static org.mockito.Mockito.verify; |
| 5 | + |
| 6 | +import android.graphics.Typeface; |
| 7 | + |
| 8 | +import com.amrdeveloper.codeview.CodeView; |
| 9 | + |
| 10 | +import org.junit.Test; |
| 11 | + |
| 12 | +public class CodeViewUtilsTest { |
| 13 | + |
| 14 | + private void verifyDefaults(CodeView view, Typeface typeface) { |
| 15 | + verify(view).setTypeface(typeface); |
| 16 | + verify(view).setTextSize(14f); |
| 17 | + verify(view).setLineNumberTextSize(14f); |
| 18 | + verify(view).setEnableLineNumber(false); |
| 19 | + verify(view).setHorizontallyScrolling(false); |
| 20 | + verify(view).setKeyListener(null); |
| 21 | + verify(view).setCursorVisible(false); |
| 22 | + verify(view).setTextIsSelectable(true); |
| 23 | + verify(view).setHorizontalScrollBarEnabled(false); |
| 24 | + verify(view).setVerticalScrollBarEnabled(false); |
| 25 | + verify(view).setBackground(null); |
| 26 | + } |
| 27 | + |
| 28 | + @Test |
| 29 | + public void applyDefaults_configuresAllViews() { |
| 30 | + Typeface typeface = mock(Typeface.class); |
| 31 | + CodeView first = mock(CodeView.class); |
| 32 | + CodeView second = mock(CodeView.class); |
| 33 | + |
| 34 | + CodeViewUtils.applyDefaults(typeface, first, second, null); |
| 35 | + |
| 36 | + verifyDefaults(first, typeface); |
| 37 | + verifyDefaults(second, typeface); |
| 38 | + } |
| 39 | +} |
| 40 | + |
0 commit comments