blob: aab771494726a4bb6fe42ec91a0a192993027d04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package com.mapbox.weartestapp.utils;
import android.view.View;
import org.junit.Test;
import org.mockito.InjectMocks;
import static junit.framework.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class OffsettingHelperTest {
private static final double DELTA = 1e-15;
@InjectMocks
View view = mock(View.class);
@Test
public void testAnchorOffset() {
float[] offset = new float[2];
int viewHeight = 50;
when(view.getHeight()).thenReturn(viewHeight);
OffsettingHelper offsettingHelper = new OffsettingHelper();
offsettingHelper.adjustAnchorOffsetXY(view, offset);
assertEquals("Offset of " + viewHeight + " should be divided by 2: ", viewHeight / 2, offset[0], DELTA);
}
}
|