discord: Fix action timeout, add in game time elapsed option (#12471)
Co-authored-by: Matthew C <66925241+Matthew-nop@users.noreply.github.com> Co-authored-by: Tomas Slusny <slusnucky@gmail.com> Co-authored-by: Jordan Atwood <jordan.atwood423@gmail.com>
This commit is contained in:
@@ -35,6 +35,7 @@ import net.runelite.api.Client;
|
||||
import net.runelite.client.discord.DiscordPresence;
|
||||
import net.runelite.client.discord.DiscordService;
|
||||
import net.runelite.client.ws.PartyService;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -77,10 +78,10 @@ public class DiscordStateTest
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatusTimeout()
|
||||
public void testStatusReset()
|
||||
{
|
||||
when(discordConfig.actionTimeout()).thenReturn(0);
|
||||
when(discordConfig.hideElapsedTime()).thenReturn(false);
|
||||
when(discordConfig.actionTimeout()).thenReturn(-1);
|
||||
when(discordConfig.elapsedTimeType()).thenReturn(DiscordConfig.ElapsedTimeType.ACTIVITY);
|
||||
|
||||
discordState.triggerEvent(DiscordGameEventType.IN_MENU);
|
||||
verify(discordService).updatePresence(any(DiscordPresence.class));
|
||||
@@ -91,4 +92,39 @@ public class DiscordStateTest
|
||||
List<DiscordPresence> captured = captor.getAllValues();
|
||||
assertNull(captured.get(captured.size() - 1).getEndTimestamp());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatusTimeout()
|
||||
{
|
||||
when(discordConfig.actionTimeout()).thenReturn(-1);
|
||||
when(discordConfig.elapsedTimeType()).thenReturn(DiscordConfig.ElapsedTimeType.ACTIVITY);
|
||||
|
||||
discordState.triggerEvent(DiscordGameEventType.TRAINING_AGILITY);
|
||||
verify(discordService).updatePresence(any(DiscordPresence.class));
|
||||
|
||||
discordState.checkForTimeout();
|
||||
verify(discordService, times(1)).clearPresence();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAreaChange()
|
||||
{
|
||||
when(discordConfig.elapsedTimeType()).thenReturn(DiscordConfig.ElapsedTimeType.TOTAL);
|
||||
|
||||
// Start with state of IN_GAME
|
||||
ArgumentCaptor<DiscordPresence> captor = ArgumentCaptor.forClass(DiscordPresence.class);
|
||||
discordState.triggerEvent(DiscordGameEventType.IN_GAME);
|
||||
verify(discordService, times(1)).updatePresence(captor.capture());
|
||||
assertEquals(DiscordGameEventType.IN_GAME.getState(), captor.getValue().getState());
|
||||
|
||||
// IN_GAME -> CITY
|
||||
discordState.triggerEvent(DiscordGameEventType.CITY_VARROCK);
|
||||
verify(discordService, times(2)).updatePresence(captor.capture());
|
||||
assertEquals(DiscordGameEventType.CITY_VARROCK.getState(), captor.getValue().getState());
|
||||
|
||||
// CITY -> IN_GAME
|
||||
discordState.triggerEvent(DiscordGameEventType.IN_GAME);
|
||||
verify(discordService, times(3)).updatePresence(captor.capture());
|
||||
assertEquals(DiscordGameEventType.IN_GAME.getState(), captor.getValue().getState());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user