Merge pull request #12430 from usa-usa-usa-usa/feature/update-tzhaar-timer
This commit is contained in:
@@ -48,13 +48,13 @@ public class ElapsedTimerTest
|
||||
assertEquals("05:00", timerText(fiveMinutesAgo, null));
|
||||
assertEquals("55:00", timerText(oneHourAgo, fiveMinutesAgo));
|
||||
assertEquals("59:55", timerText(oneHourAgo, fiveSecondsAgo));
|
||||
assertEquals("01:00", timerText(oneHourAgo, now));
|
||||
assertEquals("01:00", timerText(oneHourAgo, null));
|
||||
assertEquals("04:00", timerText(fiveHoursAgo, oneHourAgo));
|
||||
assertEquals("04:55", timerText(fiveHoursAgo, fiveMinutesAgo));
|
||||
assertEquals("04:59", timerText(fiveHoursAgo, fiveSecondsAgo));
|
||||
assertEquals("05:00", timerText(fiveHoursAgo, now));
|
||||
assertEquals("05:00", timerText(fiveHoursAgo, null));
|
||||
assertEquals("60:00", timerText(oneHourAgo, now));
|
||||
assertEquals("60:00", timerText(oneHourAgo, null));
|
||||
assertEquals("240:00", timerText(fiveHoursAgo, oneHourAgo));
|
||||
assertEquals("295:00", timerText(fiveHoursAgo, fiveMinutesAgo));
|
||||
assertEquals("299:55", timerText(fiveHoursAgo, fiveSecondsAgo));
|
||||
assertEquals("300:00", timerText(fiveHoursAgo, now));
|
||||
assertEquals("300:00", timerText(fiveHoursAgo, null));
|
||||
}
|
||||
|
||||
private static String timerText(final Instant startTime, final Instant lastTime)
|
||||
|
||||
@@ -63,8 +63,6 @@ import org.mockito.stubbing.Answer;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class TimersPluginTest
|
||||
{
|
||||
private static final int FIGHT_CAVES_REGION_ID = 9551;
|
||||
|
||||
@Inject
|
||||
private TimersPlugin timersPlugin;
|
||||
|
||||
@@ -270,7 +268,7 @@ public class TimersPluginTest
|
||||
public void testTzhaarTimer()
|
||||
{
|
||||
when(timersConfig.showTzhaarTimers()).thenReturn(true);
|
||||
when(client.getMapRegions()).thenReturn(new int[]{FIGHT_CAVES_REGION_ID});
|
||||
when(client.getMapRegions()).thenReturn(new int[]{TimersPlugin.FIGHT_CAVES_REGION_ID});
|
||||
|
||||
class InstantRef
|
||||
{
|
||||
@@ -327,4 +325,34 @@ public class TimersPluginTest
|
||||
verify(infoBoxManager, times(3)).removeInfoBox(captor.capture());
|
||||
verify(infoBoxManager, times(3)).addInfoBox(captor.capture());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInfernoTimerStartOffset()
|
||||
{
|
||||
when(timersConfig.showTzhaarTimers()).thenReturn(true);
|
||||
when(client.getMapRegions()).thenReturn(new int[]{TimersPlugin.INFERNO_REGION_ID});
|
||||
|
||||
class InstantRef
|
||||
{
|
||||
Instant i;
|
||||
}
|
||||
|
||||
InstantRef startTime = new InstantRef();
|
||||
when(timersConfig.tzhaarStartTime()).then(a -> startTime.i);
|
||||
doAnswer((Answer<Void>) invocationOnMock ->
|
||||
{
|
||||
Object argument = invocationOnMock.getArguments()[0];
|
||||
startTime.i = (Instant) argument;
|
||||
return null;
|
||||
}).when(timersConfig).tzhaarStartTime(nullable(Instant.class));
|
||||
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", "<col=ef1020>Wave: 1</col>", "", 0);
|
||||
timersPlugin.onChatMessage(chatMessage);
|
||||
|
||||
ArgumentCaptor<InfoBox> captor = ArgumentCaptor.forClass(InfoBox.class);
|
||||
verify(infoBoxManager, times(1)).addInfoBox(captor.capture());
|
||||
assertTrue(captor.getValue() instanceof ElapsedTimer);
|
||||
ElapsedTimer timer = (ElapsedTimer) captor.getValue();
|
||||
assertEquals("00:06", timer.getText());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user