npchighlight: Apply correct highlights to changed NPCs

This commit is contained in:
Jordan Atwood
2021-02-12 23:40:34 -08:00
committed by Adam
parent e8fd08fa41
commit 7c59815869
2 changed files with 62 additions and 0 deletions

View File

@@ -37,9 +37,12 @@ import net.runelite.api.MenuAction;
import net.runelite.api.MenuEntry;
import net.runelite.api.NPC;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.NpcChanged;
import net.runelite.api.events.NpcSpawned;
import net.runelite.client.ui.overlay.OverlayManager;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -137,4 +140,42 @@ public class NpcIndicatorsPluginTest
target.setTarget("<col=0000ff>Goblin"); // blue
verify(client).setMenuEntries(new MenuEntry[]{target});
}
@Test
public void taggedNpcChanges()
{
when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("Joseph");
npcIndicatorsPlugin.rebuildAllNpcs();
NPC npc = mock(NPC.class);
when(npc.getName()).thenReturn("Joseph");
npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc));
assertTrue(npcIndicatorsPlugin.getHighlightedNpcs().contains(npc));
when(npc.getName()).thenReturn("Werewolf");
npcIndicatorsPlugin.onNpcChanged(new NpcChanged(npc, null));
assertFalse(npcIndicatorsPlugin.getHighlightedNpcs().contains(npc));
}
@Test
public void npcChangesToTagged()
{
when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("Werewolf");
npcIndicatorsPlugin.rebuildAllNpcs();
NPC npc = mock(NPC.class);
when(npc.getName()).thenReturn("Joseph");
npcIndicatorsPlugin.onNpcSpawned(new NpcSpawned(npc));
assertFalse(npcIndicatorsPlugin.getHighlightedNpcs().contains(npc));
when(npc.getName()).thenReturn("Werewolf");
npcIndicatorsPlugin.onNpcChanged(new NpcChanged(npc, null));
assertTrue(npcIndicatorsPlugin.getHighlightedNpcs().contains(npc));
}
}