use of com.facebook.drawee.interfaces.DraweeHierarchy in project fresco by facebook.
the class DraweeMocks method stubGetAndSetHierarchy.
/**
* Stubs setHierarchy and getHierarchy methods.
*
* @param controller controller to stub methods of
*/
public static void stubGetAndSetHierarchy(DraweeController controller) {
final DraweeHierarchy[] dhHolder = new DraweeHierarchy[1];
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return dhHolder[0];
}
}).when(controller).getHierarchy();
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return dhHolder[0] = (DraweeHierarchy) invocation.getArguments()[0];
}
}).when(controller).setHierarchy((DraweeHierarchy) any());
}
use of com.facebook.drawee.interfaces.DraweeHierarchy in project fresco by facebook.
the class DraweeHolderTest method testTouchEventWithInvalidController.
@Test
public void testTouchEventWithInvalidController() {
final DraweeHierarchy draweeHierarchy2 = DraweeMocks.mockDraweeHierarchyOf(mTopLevelDrawable);
final DraweeHolder draweeHolder2 = new DraweeHolder(draweeHierarchy2);
mDraweeHolder.setController(mController);
draweeHolder2.setController(mController);
mDraweeHolder.onTouchEvent(mock(MotionEvent.class));
verify(mController, never()).onTouchEvent(any(MotionEvent.class));
}
use of com.facebook.drawee.interfaces.DraweeHierarchy in project fresco by facebook.
the class DraweeHolderTest method testOverrideControllerHierarchy.
@Test
public void testOverrideControllerHierarchy() {
DraweeHierarchy otherHierarchy = mock(DraweeHierarchy.class);
mController.setHierarchy(otherHierarchy);
assertSame(otherHierarchy, mController.getHierarchy());
mDraweeHolder.setController(mController);
assertSame(mController, mDraweeHolder.getController());
assertSame(mDraweeHierarchy, mDraweeHolder.getHierarchy());
assertSame(mDraweeHierarchy, mController.getHierarchy());
}
use of com.facebook.drawee.interfaces.DraweeHierarchy in project fresco by facebook.
the class DraweeHolderTest method testSetNewControllerWithInvalidController.
@Test
public void testSetNewControllerWithInvalidController() {
final DraweeHierarchy draweeHierarchy2 = DraweeMocks.mockDraweeHierarchyOf(mTopLevelDrawable);
final DraweeHolder draweeHolder2 = new DraweeHolder(draweeHierarchy2);
mDraweeHolder.onAttach();
mDraweeHolder.setController(mController);
draweeHolder2.setController(mController);
mDraweeHolder.setController(null);
verify(mController, never()).onDetach();
assertEquals(draweeHierarchy2, mController.getHierarchy());
}
use of com.facebook.drawee.interfaces.DraweeHierarchy in project fresco by facebook.
the class DraweeHolderTest method testOnDetachWithInvalidController.
@Test
public void testOnDetachWithInvalidController() {
final DraweeHierarchy draweeHierarchy2 = DraweeMocks.mockDraweeHierarchyOf(mTopLevelDrawable);
final DraweeHolder draweeHolder2 = new DraweeHolder(draweeHierarchy2);
mDraweeHolder.onAttach();
mDraweeHolder.setController(mController);
draweeHolder2.setController(mController);
mDraweeHolder.onDetach();
verify(mController, never()).onDetach();
}
Aggregations