Skip to content

Commit

Permalink
Add static imports in order to improve the readability.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfarid committed Jan 19, 2016
1 parent 43d02d3 commit e344ca9
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions library/src/test/java/com/r0adkll/slidr/widget/SliderPanelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
import static org.mockito.internal.util.reflection.Whitebox.setInternalState;

/**
* Created by farid on 18/01/16.
Expand All @@ -38,7 +40,7 @@ public class SliderPanelTest {
public void testOnInterceptTouchEvent_whenLocked() throws Exception {
//given
SliderPanel sliderPanel = new SliderPanel(context);
Whitebox.setInternalState(sliderPanel, "mIsLocked", true);
setInternalState(sliderPanel, "mIsLocked", true);

//when
boolean result = sliderPanel.onInterceptTouchEvent(motionEvent);
Expand All @@ -55,12 +57,12 @@ public void testOnInterceptTouchEvent_whenNotLoacked_edgeOnly() throws Exception
PowerMockito.when(sliderPanel, "getWidth").thenReturn(10);

SlidrConfig slidrConfig = Mockito.mock(SlidrConfig.class);
Mockito.when(slidrConfig.isEdgeOnly()).thenReturn(true);
Mockito.when(slidrConfig.getPosition()).thenReturn(SlidrPosition.LEFT);
Mockito.when(slidrConfig.getEdgeSize(Matchers.anyInt())).thenReturn(10.1f);
when(slidrConfig.isEdgeOnly()).thenReturn(true);
when(slidrConfig.getPosition()).thenReturn(SlidrPosition.LEFT);
when(slidrConfig.getEdgeSize(Matchers.anyInt())).thenReturn(10.1f);

Whitebox.setInternalState(sliderPanel, "mIsLocked", false);
Whitebox.setInternalState(sliderPanel, "mConfig", slidrConfig);
setInternalState(sliderPanel, "mIsLocked", false);
setInternalState(sliderPanel, "mConfig", slidrConfig);

//when
boolean result = sliderPanel.onInterceptTouchEvent(motionEvent);
Expand All @@ -73,7 +75,7 @@ public void testOnInterceptTouchEvent_whenNotLoacked_edgeOnly() throws Exception
public void testOnTouchEvent_whenLocked() throws Exception {
//given
SliderPanel sliderPanel = Mockito.spy(new SliderPanel(context));
Whitebox.setInternalState(sliderPanel, "mIsLocked", true);
setInternalState(sliderPanel, "mIsLocked", true);

//when
boolean result = sliderPanel.onTouchEvent(motionEvent);
Expand All @@ -86,10 +88,10 @@ public void testOnTouchEvent_whenLocked() throws Exception {
public void testOnTouchEvent_whenNotLocked() throws Exception {
//given
SliderPanel sliderPanel = Mockito.spy(new SliderPanel(context));
Whitebox.setInternalState(sliderPanel, "mIsLocked", false);
setInternalState(sliderPanel, "mIsLocked", false);

ViewDragHelper viewDragHelper = Mockito.mock(ViewDragHelper.class);
Whitebox.setInternalState(sliderPanel, "mDragHelper", viewDragHelper);
setInternalState(sliderPanel, "mDragHelper", viewDragHelper);

//when
boolean result = sliderPanel.onTouchEvent(motionEvent);
Expand All @@ -102,11 +104,11 @@ public void testOnTouchEvent_whenNotLocked() throws Exception {
public void testOnTouchEvent_whenNotLocked_butExceptionInProcessTouchEvent() throws Exception {
//given
SliderPanel sliderPanel = Mockito.spy(new SliderPanel(context));
Whitebox.setInternalState(sliderPanel, "mIsLocked", false);
setInternalState(sliderPanel, "mIsLocked", false);

ViewDragHelper viewDragHelper = Mockito.mock(ViewDragHelper.class);
PowerMockito.doThrow(new IllegalArgumentException()).when(viewDragHelper).processTouchEvent(motionEvent);
Whitebox.setInternalState(sliderPanel, "mDragHelper", viewDragHelper);
setInternalState(sliderPanel, "mDragHelper", viewDragHelper);

//when
boolean result = sliderPanel.onTouchEvent(motionEvent);
Expand Down

0 comments on commit e344ca9

Please sign in to comment.