[test] Fix the test of history text listener
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
45fa90c75e
commit
0f731270d5
@ -69,15 +69,14 @@ package net.bigeon.gclc.swt;
|
|||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.*;
|
||||||
import static org.mockito.Mockito.times;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.KeyEvent;
|
import org.eclipse.swt.events.KeyEvent;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import net.bigeon.gclc.swt.api.ConsoleDelayIO;
|
import net.bigeon.gclc.swt.api.ConsoleDelayIO;
|
||||||
import net.bigeon.gclc.swt.tools.HistoryTextKeyListener;
|
import net.bigeon.gclc.swt.tools.HistoryTextKeyListener;
|
||||||
@ -149,12 +148,23 @@ public class HistoryTextKeyListenerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKeyPressed() throws IOException {
|
public void testKeyPressedA() throws IOException {
|
||||||
final ConsoleDelayIO io = mock(ConsoleDelayIO.class);
|
final ConsoleDelayIO io = mock(ConsoleDelayIO.class);
|
||||||
final KeyEvent event = mock(KeyEvent.class);
|
final KeyEvent event = mock(KeyEvent.class);
|
||||||
event.keyCode = 'a';
|
event.keyCode = 'a';
|
||||||
final HistoryTextKeyListener listener = new HistoryTextKeyListener(io);
|
final HistoryTextKeyListener listener = new HistoryTextKeyListener(io);
|
||||||
listener.keyPressed(event);
|
listener.keyPressed(event);
|
||||||
|
verifyNoInteractions(io);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testKeyPressedReturn() throws IOException {
|
||||||
|
final ConsoleDelayIO io = mock(ConsoleDelayIO.class);
|
||||||
|
Mockito.when(io.getInput()).thenReturn("Alpha");
|
||||||
|
final KeyEvent event = mock(KeyEvent.class);
|
||||||
|
event.keyCode = '\r';
|
||||||
|
final HistoryTextKeyListener listener = new HistoryTextKeyListener(io);
|
||||||
|
listener.keyPressed(event);
|
||||||
verify(io, times(1)).validateInput();
|
verify(io, times(1)).validateInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user