use of com.gemserk.commons.gdx.box2d.Contacts.Contact in project commons-gdx by gemserk.
the class ContactsTest method removesSecondContactIfItMatches.
@Test
public void removesSecondContactIfItMatches() {
final Fixture fixtureC = mockery.mock(Fixture.class);
mockery.checking(new Expectations() {
{
ignoring(fixtureA);
ignoring(fixtureB);
ignoring(fixtureC);
}
});
contacts.addContact(fixtureA, fixtureC, new Vector2());
contacts.addContact(fixtureA, fixtureB, normal);
assertTrue(contacts.isInContact());
assertThat(2, IsEqual.equalTo(contacts.getContactCount()));
contacts.removeContact(fixtureA, fixtureB);
assertTrue(contacts.isInContact());
assertThat(1, IsEqual.equalTo(contacts.getContactCount()));
Contact stillValidContact = contacts.contacts.get(0);
assertTrue(stillValidContact.inContact);
assertSame(fixtureA, stillValidContact.myFixture);
assertSame(fixtureC, stillValidContact.otherFixture);
Contact removedContact = contacts.contacts.get(1);
assertFalse(removedContact.inContact);
assertNull(removedContact.myFixture);
assertNull(removedContact.otherFixture);
}
use of com.gemserk.commons.gdx.box2d.Contacts.Contact in project commons-gdx by gemserk.
the class ContactsTest method removesFirstOfTwoContactIfItMatches.
@Test
public void removesFirstOfTwoContactIfItMatches() {
final Fixture fixtureC = mockery.mock(Fixture.class);
mockery.checking(new Expectations() {
{
ignoring(fixtureA);
ignoring(fixtureB);
ignoring(fixtureC);
}
});
contacts.addContact(fixtureA, fixtureB, normal);
contacts.addContact(fixtureA, fixtureC, new Vector2());
assertTrue(contacts.isInContact());
assertThat(2, IsEqual.equalTo(contacts.getContactCount()));
contacts.removeContact(fixtureA, fixtureB);
assertTrue(contacts.isInContact());
assertThat(1, IsEqual.equalTo(contacts.getContactCount()));
Contact stillValidContact = contacts.contacts.get(0);
assertTrue(stillValidContact.inContact);
assertSame(fixtureA, stillValidContact.myFixture);
assertSame(fixtureC, stillValidContact.otherFixture);
Contact removedContact = contacts.contacts.get(1);
assertFalse(removedContact.inContact);
assertNull(removedContact.myFixture);
assertNull(removedContact.otherFixture);
}
Aggregations