use of com.gemserk.commons.gdx.input.MockPointer in project commons-gdx by gemserk.
the class ToggleableImageButtonTest method shouldToggleIfPointerPressedAndInside.
@Test
public void shouldToggleIfPointerPressedAndInside() {
MockPointer pointer = new MockPointer();
MockToggleHandler toggleHandler = new MockToggleHandler();
ToggleableImageButton toggleableImageButton = new ToggleableImageButton() {
@Override
protected void recalculateBounds() {
}
};
toggleableImageButton.setPointer(pointer);
toggleableImageButton.setToggleHandler(toggleHandler);
toggleableImageButton.setPosition(0f, 0f);
toggleableImageButton.setBounds(new Rectangle(20, 20, 100, 100));
pointer.wasReleased = true;
pointer.releasedPosition.set(25, 25);
toggleableImageButton.update();
assertThat(toggleHandler.toggleCalled, IsEqual.equalTo(true));
}
use of com.gemserk.commons.gdx.input.MockPointer in project commons-gdx by gemserk.
the class ToggleableImageButtonTest method shouldNotToggleIfPointerPressedButOutside.
@Test
public void shouldNotToggleIfPointerPressedButOutside() {
MockPointer pointer = new MockPointer();
MockToggleHandler toggleHandler = new MockToggleHandler();
ToggleableImageButton toggleableImageButton = new ToggleableImageButton() {
@Override
protected void recalculateBounds() {
}
};
toggleableImageButton.setPointer(pointer);
toggleableImageButton.setToggleHandler(toggleHandler);
toggleableImageButton.setPosition(0f, 0f);
toggleableImageButton.setBounds(new Rectangle(20, 20, 100, 100));
pointer.wasReleased = true;
pointer.releasedPosition.set(-20, -20);
toggleableImageButton.update();
assertThat(toggleHandler.toggleCalled, IsEqual.equalTo(false));
}
use of com.gemserk.commons.gdx.input.MockPointer in project commons-gdx by gemserk.
the class ToggleableImageButtonTest method shouldToggleIfPointerPressedAndInsideOnlyOnce.
@Test
public void shouldToggleIfPointerPressedAndInsideOnlyOnce() {
MockPointer pointer = new MockPointer();
MockToggleHandler toggleHandler = new MockToggleHandler();
ToggleableImageButton toggleableImageButton = new ToggleableImageButton() {
@Override
protected void recalculateBounds() {
}
};
toggleableImageButton.setPointer(pointer);
toggleableImageButton.setToggleHandler(toggleHandler);
toggleableImageButton.setPosition(0f, 0f);
toggleableImageButton.setBounds(new Rectangle(20, 20, 100, 100));
pointer.wasReleased = true;
pointer.releasedPosition.set(25, 25);
toggleableImageButton.update();
assertThat(toggleHandler.toggleCalled, IsEqual.equalTo(true));
pointer.wasReleased = false;
toggleHandler.toggleCalled = false;
toggleableImageButton.update();
assertThat(toggleHandler.toggleCalled, IsEqual.equalTo(false));
}
use of com.gemserk.commons.gdx.input.MockPointer in project commons-gdx by gemserk.
the class ToggleableImageButtonTest method shouldNotToggleIfPointerIsNotPressed.
@Test
public void shouldNotToggleIfPointerIsNotPressed() {
MockPointer pointer = new MockPointer();
MockToggleHandler toggleHandler = new MockToggleHandler();
ToggleableImageButton toggleableImageButton = new ToggleableImageButton() {
@Override
protected void recalculateBounds() {
}
};
toggleableImageButton.setPointer(pointer);
toggleableImageButton.setToggleHandler(toggleHandler);
toggleableImageButton.setPosition(0f, 0f);
toggleableImageButton.setBounds(new Rectangle(20, 20, 100, 100));
pointer.wasReleased = false;
toggleableImageButton.update();
assertThat(toggleHandler.toggleCalled, IsEqual.equalTo(false));
}
Aggregations