// Path: app/src/mixedbit/speechtrainer/controller/RecordPlayTaskManager.java
// enum RecordPlayTaskPriority {
//     HIGH, TEST,
// }
// 
// Path: app/src/mixedbit/speechtrainer/controller/RecordPlayTaskManager.java
// enum RecordPlayTaskState {
//     RECORD, PLAY, TERMINATE
// }


import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import junit.framework.TestCase;
import mixedbit.speechtrainer.controller.RecordPlayTaskManager.RecordPlayTaskPriority;
import mixedbit.speechtrainer.controller.RecordPlayTaskManager.RecordPlayTaskState;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
import org.easymock.IMocksControl;
        recordPlayTaskManager.startTask(RecordPlayTaskState.PLAY, mockStrategy);
        waitForTaskToFinish();
        verifyAll();
        recordPlayTaskManager.terminateTaskIfRunning();
    }

    public void testSwichBetweenRecordingAndPlaying() {
        // The task starts in the recording state, recorder should be started.
        mockRecorder.startRecording();
        // The first invocation of handleRecord requests the task to switch to
        // the playing state.
        EasyMock.expect(mockStrategy.handleRecord(mockRecorder))
        .andReturn(RecordPlayTaskState.PLAY);
        // Recorder should be stopped.
        mockRecorder.stopRecording();
        // And Player should be started.
        mockPlayer.startPlaying();
        // The first invocation of handlePlay requests the task to switch to the
        // recording state again.
        EasyMock.expect(mockStrategy.handlePlay(mockPlayer)).andReturn(RecordPlayTaskState.RECORD);
        // Player should be stopped.
        mockPlayer.stopPlaying();
        // And Recorder started.
        mockRecorder.startRecording();
        // Finally, the task is requested to terminate.
        EasyMock.expect(mockStrategy.handleRecord(mockRecorder)).andReturn(
                RecordPlayTaskState.TERMINATE);
        mockRecorder.stopRecording();
        replayAll();

// Path: app/src/mixedbit/speechtrainer/controller/RecordPlayTaskManager.java
// enum RecordPlayTaskPriority {
//     HIGH, TEST,
// }
// 
// Path: app/src/mixedbit/speechtrainer/controller/RecordPlayTaskManager.java
// enum RecordPlayTaskState {
//     RECORD, PLAY, TERMINATE
// }


// Path: app_tests/src/mixedbit/speechtrainer/controller/RecordPlayTaskManagerTest.java
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import junit.framework.TestCase;
import mixedbit.speechtrainer.controller.RecordPlayTaskManager.RecordPlayTaskPriority;
import mixedbit.speechtrainer.controller.RecordPlayTaskManager.RecordPlayTaskState;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
import org.easymock.IMocksControl;

        recordPlayTaskManager.startTask(RecordPlayTaskState.PLAY, mockStrategy);
        waitForTaskToFinish();
        verifyAll();
        recordPlayTaskManager.terminateTaskIfRunning();
    }

    public void testSwichBetweenRecordingAndPlaying() {
        // The task starts in the recording state, recorder should be started.
        mockRecorder.startRecording();
        // The first invocation of handleRecord requests the task to switch to
        // the playing state.
        EasyMock.expect(mockStrategy.handleRecord(mockRecorder))
        .andReturn(RecordPlayTaskState.PLAY);
        // Recorder should be stopped.
        mockRecorder.stopRecording();
        // And Player should be started.
        mockPlayer.startPlaying();
        // The first invocation of handlePlay requests the task to switch to the
        // recording state again.
        EasyMock.expect(mockStrategy.handlePlay(mockPlayer)).andReturn(RecordPlayTaskState.RECORD);
        // Player should be stopped.
        mockPlayer.stopPlaying();
        // And Recorder started.
        mockRecorder.startRecording();
        // Finally, the task is requested to terminate.
        EasyMock.expect(mockStrategy.handleRecord(mockRecorder)).andReturn(
                RecordPlayTaskState.TERMINATE);
        mockRecorder.stopRecording();
        replayAll();

        recordPlayTaskManager.startTask(RecordPlayTaskState.RECORD, mockStrategy);