runelite-client: Test Overlay equality
If Overlay::equals returns true for different subclasses it breaks the OverlayManager, because it can no longer remove overlays correctly.
This commit is contained in:
@@ -29,6 +29,8 @@ import java.awt.Graphics2D;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
public class OverlayManagerTest
|
||||
@@ -48,6 +50,38 @@ public class OverlayManagerTest
|
||||
}
|
||||
}
|
||||
|
||||
private static class OverlayA extends Overlay
|
||||
{
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class OverlayB extends Overlay
|
||||
{
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquality()
|
||||
{
|
||||
Overlay a1 = new OverlayA();
|
||||
Overlay a2 = new OverlayA();
|
||||
Overlay b = new OverlayB();
|
||||
// The same instance of the same overlay should be equal
|
||||
assertTrue(a1.equals(a1));
|
||||
// A different instance of the same overlay should not be equal by default
|
||||
assertFalse(a1.equals(a2));
|
||||
// A different instance of a different overlay should not be equal
|
||||
assertFalse(a1.equals(b));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSort()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user