Permalink
Browse files

Proved need to quit. All the logic moved away from communicator.

  • Loading branch information...
1 parent 2d82502 commit d1cbc54410ac8b5319a6dc3da3e3f929ecad713a @lrozenblyum committed Nov 25, 2012
@@ -100,47 +100,9 @@ public void setOnMoveListener( Listener listenerToSet ) {
public void run() {
while( true ) {
commander.getInput();
- //TODO: any Thread.sleep needed?
- String line = communicator.receive();
-
- //TODO: what does it mean?
- if ( line == null ) {
- continue;
- }
-
- if ( line.equals( "quit" ) ) {
- logger.info( "Received quit command" );
+ if ( needQuit ) {
break;
}
-
- // xboard
- // This command will be sent once immediately after your engine process is started.
- // You can use it to put your engine into "xboard mode" if that is needed.
- // If your engine prints a prompt to ask for user input,
- // you must turn off the prompt and output a newline when the "xboard" command comes in.
-
- //LR: because we don't print any prompt, I don't put any newline here
- if ( line.equals( "xboard" ) ) {
- logger.info( "Ready to work" );
- }
-
-
- if ( line.startsWith( "protover" ) ) {
-
- }
-
- //this is received only if we play white, is it true?
- //otherwise we'll get usermove commands instead
-
- //the 2'nd check works because we enabled v2 feature...
- if ( line.equals( "go" ) || line.startsWith( "usermove" ) ) {
- listener.onCommandReceived();
- }
-
- //another player offers draw - accept always
- if ( line.equals( "draw" ) ) {
- communicator.send( "offer draw" );
- }
}
}
@@ -38,6 +38,23 @@ public void useCommanderForQuitCommand() {
controller.run();
}
+ //ensure need of refactoring into commander instead of communicator
+ @Test( timeout = 5000 )
+ public void useCommanderForQuitCommandRealTest() {
+ //dummy implementation - each time anybody sets a protover listener -
+ //we quit IMMEDIATELY
+ WinboardCommander commander = new MockCommander() {
+ @Override
+ public void setQuitListener( final QuitListener quitListener ) {
+ quitListener.execute();
+ }
+ };
+
+ WinboardPlayer controller = new WinboardPlayer( commander );
+
+ controller.run();
+ }
+
@Test
public void correctProtoverReaction() {
//dummy implementation - each time anybody sets a protover listener -

0 comments on commit d1cbc54

Please sign in to comment.