Extract interface as method return
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
ba61efaa4a
commit
c1ce1277d3
@ -79,6 +79,8 @@ import org.eclipse.swt.widgets.Text;
|
|||||||
|
|
||||||
import net.bigeon.gclc.manager.PipedConsoleInput;
|
import net.bigeon.gclc.manager.PipedConsoleInput;
|
||||||
import net.bigeon.gclc.manager.PipedConsoleOutput;
|
import net.bigeon.gclc.manager.PipedConsoleOutput;
|
||||||
|
import net.bigeon.gclc.swt.api.ConsoleDelayIO;
|
||||||
|
import net.bigeon.gclc.swt.api.ConsoleOutputDisplay;
|
||||||
import net.bigeon.gclc.swt.io.ConsoleInputManager;
|
import net.bigeon.gclc.swt.io.ConsoleInputManager;
|
||||||
import net.bigeon.gclc.swt.io.ConsoleOutputManager;
|
import net.bigeon.gclc.swt.io.ConsoleOutputManager;
|
||||||
import net.bigeon.gclc.swt.io.ConsolePromptManager;
|
import net.bigeon.gclc.swt.io.ConsolePromptManager;
|
||||||
@ -131,12 +133,12 @@ public final class SWTConsole extends Composite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @return the inputManager */
|
/** @return the inputManager */
|
||||||
public ConsoleInputManager getInputManager() {
|
public ConsoleDelayIO getInputManager() {
|
||||||
return inputManager;
|
return inputManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return the outputManager */
|
/** @return the outputManager */
|
||||||
public ConsoleOutputManager getOutputManager() {
|
public ConsoleOutputDisplay getOutputManager() {
|
||||||
return outputManager;
|
return outputManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +78,8 @@ import org.eclipse.swt.widgets.Text;
|
|||||||
import net.bigeon.gclc.ConsoleApplication;
|
import net.bigeon.gclc.ConsoleApplication;
|
||||||
import net.bigeon.gclc.manager.PipedConsoleInput;
|
import net.bigeon.gclc.manager.PipedConsoleInput;
|
||||||
import net.bigeon.gclc.manager.PipedConsoleOutput;
|
import net.bigeon.gclc.manager.PipedConsoleOutput;
|
||||||
|
import net.bigeon.gclc.swt.api.ConsoleDelayIO;
|
||||||
|
import net.bigeon.gclc.swt.api.ConsoleOutputDisplay;
|
||||||
import net.bigeon.gclc.swt.io.ConsoleInputManager;
|
import net.bigeon.gclc.swt.io.ConsoleInputManager;
|
||||||
import net.bigeon.gclc.swt.io.ConsoleOutputManager;
|
import net.bigeon.gclc.swt.io.ConsoleOutputManager;
|
||||||
import net.bigeon.gclc.swt.tools.HistoryTextKeyListener;
|
import net.bigeon.gclc.swt.tools.HistoryTextKeyListener;
|
||||||
@ -132,14 +134,14 @@ public final class SWTConsoleView extends Composite {
|
|||||||
/** Get the manager of console input.
|
/** Get the manager of console input.
|
||||||
*
|
*
|
||||||
* @return the input manager */
|
* @return the input manager */
|
||||||
public ConsoleInputManager getInputManager() {
|
public ConsoleDelayIO getInputManager() {
|
||||||
return inManager;
|
return inManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the manager of console output.
|
/** Get the manager of console output.
|
||||||
*
|
*
|
||||||
* @return the output manager */
|
* @return the output manager */
|
||||||
public ConsoleOutputManager getOutputManager() {
|
public ConsoleOutputDisplay getOutputManager() {
|
||||||
return outManager;
|
return outManager;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,7 @@ import java.util.logging.Logger;
|
|||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.stubbing.Answer;
|
|
||||||
|
|
||||||
import net.bigeon.gclc.swt.tools.PromptReadingRunnable;
|
import net.bigeon.gclc.swt.tools.PromptReadingRunnable;
|
||||||
|
|
||||||
@ -61,16 +60,10 @@ public class PromptReadingRunnableTest {
|
|||||||
private final Display display = mock(Display.class);
|
private final Display display = mock(Display.class);
|
||||||
{
|
{
|
||||||
when(view.getDisplay()).thenReturn(display);
|
when(view.getDisplay()).thenReturn(display);
|
||||||
doAnswer(new Answer<Object>() {
|
doAnswer(invocation -> {
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see
|
|
||||||
* org.mockito.stubbing.Answer#answer(org.mockito.invocation.InvocationOnMock) */
|
|
||||||
@Override
|
|
||||||
public Object answer(final InvocationOnMock invocation) throws Throwable {
|
|
||||||
final Runnable runnable = invocation.getArgument(0);
|
final Runnable runnable = invocation.getArgument(0);
|
||||||
runnable.run();
|
runnable.run();
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
}).when(display).syncExec(any(Runnable.class));
|
}).when(display).syncExec(any(Runnable.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +78,7 @@ public class PromptReadingRunnableTest {
|
|||||||
final PromptReadingRunnable runnable = new PromptReadingRunnable(reader, view);
|
final PromptReadingRunnable runnable = new PromptReadingRunnable(reader, view);
|
||||||
|
|
||||||
runnable.run();
|
runnable.run();
|
||||||
|
Mockito.verify(reader, Mockito.times(3)).readLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test method for {@link net.bigeon.gclc.swt.tools.PromptReadingRunnable#run()}.
|
/** Test method for {@link net.bigeon.gclc.swt.tools.PromptReadingRunnable#run()}.
|
||||||
@ -102,6 +96,7 @@ public class PromptReadingRunnableTest {
|
|||||||
|
|
||||||
runnable.run();
|
runnable.run();
|
||||||
logger.setLevel(back);
|
logger.setLevel(back);
|
||||||
|
Mockito.verify(reader, Mockito.times(3)).readLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user