Exemplo n.º 1
0
 /* Implementation of IPlaybackListener * */
 public void playbackFinished(final PlaybackResult result, boolean shutdown) {
   this.autShutdown = shutdown;
   displayView.endTest(result);
   if (ddTestRunner != null && ddTestRunner.hasNext() && !playbackStopped) {
     ddTestRunner.next();
     SwingUtilities.invokeLater(
         new Runnable() {
           public void run() {
             if (result.failureCount() == 0) {
               shouldClose = !reuseFixture;
               displayView.trackProgress();
               ignoreReuse = false;
             } else {
               ignoreReuse = true;
               shouldClose = false;
             }
             stopApplicationIfNecessary();
             runTest();
           }
         });
     return;
   }
   displayView.endTestRun();
   displayView.stopInserting();
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           showResult(result);
         }
       });
   ddTestRunner = null;
 }
Exemplo n.º 2
0
 public void play(IConsole console) {
   try {
     String scriptText = displayView.getScript();
     if (!validTestCase(scriptText)) {
       reportException(new Exception("No test() function or fixture found in the script"));
       return;
     }
     try {
       playbackStopped = false;
       ddTestRunner = new DDTestRunner(console, scriptText);
     } catch (Exception e) {
       reportException(new Exception(e.getMessage()));
       return;
     }
     if (ddTestRunner.hasNext()) {
       logHeader(console, "Play");
       ddTestRunner.next();
       displayView.startTestRun();
       runTest();
       return;
     }
   } catch (Throwable t) {
     reportException(t);
     destroyRuntime();
     return;
   }
   reportException(new Exception("No test() function or fixture found in the script"));
 }
Exemplo n.º 3
0
 public void stop() {
   if (state.isRecording()) {
     try {
       runtime.stopRecording();
     } catch (MarathonRuntimeException e) {
       setState(State.STOPPED_WITH_APP_CLOSED);
       destroyRuntime();
       throw e;
     } finally {
       displayView.stopInserting();
     }
     stopApplicationIfNecessary();
     displayView.updateOMapFile();
   } else if (state.isPlaying()) {
     try {
       player.halt();
     } catch (MarathonRuntimeException e) {
       reportException(e);
     } finally {
       playbackStopped = true;
       playbackFinished(playbackResultProvider.get(), false);
     }
   } else {
     throw new IllegalStateException("must be recording or playing to stop, not '" + state + "'");
   }
 }
Exemplo n.º 4
0
 public void abortRecording() {
   if (state.isRecording()) {
     displayView.stopInserting();
   }
   shouldClose = true;
   runtime = null;
   displayView.updateOMapFile();
   setState(State.STOPPED_WITH_APP_CLOSED);
 }
Exemplo n.º 5
0
 private void runTest() {
   if (ddTestRunner == null) return;
   displayView.startTest();
   createRuntime(
       ddTestRunner.getScriptText(), ddTestRunner.getConsole(), MarathonMode.PLAYING.getMode());
   script =
       runtime.createScript(ddTestRunner.getScriptText(), displayView.getFilePath(), false, true);
   script.setDataVariables(ddTestRunner.getDataVariables());
   player = script.getPlayer(this, playbackResultProvider.get());
   player.setAcceptCheckList(acceptingChecklists);
   boolean shouldRunFixture = state.isStoppedWithAppClosed();
   setState(State.PLAYING);
   displayView.startInserting();
   player.play(shouldRunFixture);
 }
Exemplo n.º 6
0
 /** Implementation IExceptionReporter * */
 public void reportException(Throwable e) {
   if (e instanceof ApplicationLaunchException) destroyRuntime();
   displayView.setError(
       e,
       e.getClass().getName().substring(e.getClass().getName().lastIndexOf('.') + 1)
           + " : "
           + e.getMessage());
 }
Exemplo n.º 7
0
 public void showResult(PlaybackResult result) {
   if (result.failureCount() == 0) {
     shouldClose = !reuseFixture;
     displayView.trackProgress();
     ignoreReuse = false;
   } else {
     ignoreReuse = true;
     shouldClose = false;
   }
   stopApplicationIfNecessary();
   showResults(result);
 }
Exemplo n.º 8
0
 public void record(IConsole console) {
   logHeader(console, "Record");
   String scriptText = displayView.getScript();
   if (!validTestCase(scriptText)) {
     scriptText = getFixtureHeader() + scriptText;
   }
   try {
     createRuntime(scriptText, console, MarathonMode.RECORDING);
     displayView.startInserting();
     runtime.createScript(scriptText, displayView.getFilePath(), false, true);
     recorder = recorderProvider.get();
     startApplicationIfNecessary();
     runtime.startRecording(recorder);
     setState(State.RECORDING);
   } catch (Throwable e) {
     setState(State.STOPPED_WITH_APP_CLOSED);
     destroyRuntime();
     displayView.stopInserting();
     stopApplicationIfNecessary();
     reportException(e);
   }
 }
Exemplo n.º 9
0
 private void logHeader(IConsole console, String type) {
   String filePath = displayView.getFilePath();
   int indexOf = filePath.indexOf(Constants.DIR_TESTCASES);
   if (indexOf != -1) {
     filePath.substring(indexOf + Constants.DIR_TESTCASES.length() + 1);
     String cbuf =
         "*****  "
             + type
             + " "
             + filePath
             + " ("
             + new SimpleDateFormat().format(new Date())
             + ") *****\n";
     console.writeScriptOut(cbuf.toCharArray(), 0, cbuf.length());
   }
 }
Exemplo n.º 10
0
 public void closeApplication(boolean closeApplicationNeeded) throws RuntimeException {
   /*
    * We need to actually call the stopApplication that calls the teardown
    * on the fixture. However, the fixture that created the application (by
    * using setup) is already lost and we can't communicate with the app
    * using fixture when manually starting the application. For making this
    * work, we need changes in the semantics of the Script and Runtime
    */
   try {
     if (closeApplicationNeeded && runtime != null && !autShutdown) runtime.stopApplication();
   } catch (Exception e) {
     displayView.setError(e, "Application Under Test Aborted");
   } finally {
     destroyRuntime();
     shouldClose = true;
     setState(State.STOPPED_WITH_APP_CLOSED);
   }
 }
Exemplo n.º 11
0
 public void insertChecklistAction(String name) {
   displayView.insertChecklistAction(name);
 }
Exemplo n.º 12
0
 protected void showResults(PlaybackResult result) {
   displayView.setResult(result);
 }
Exemplo n.º 13
0
 /** Implementation of IScriptListener * */
 public void setScript(String script) {
   displayView.insertScript(script);
 }
Exemplo n.º 14
0
 public int showChecklist(String fileName) {
   return displayView.showChecklist(fileName);
 }
Exemplo n.º 15
0
 public int acceptChecklist(String fileName) {
   return displayView.acceptChecklist(fileName);
 }
Exemplo n.º 16
0
 public int methodCalled(SourceLine line) {
   return displayView.trackProgress(line, METHOD_CALLED);
 }
Exemplo n.º 17
0
 public int methodReturned(SourceLine line) {
   return displayView.trackProgress(line, METHOD_RETURNED);
 }
Exemplo n.º 18
0
 public void setState(State pState) {
   state = pState;
   displayView.setState(state);
 }
Exemplo n.º 19
0
 public void pausePlay() {
   if (state.isPlaying()) {
     displayView.setState(State.PLAYINGPAUSED);
   }
 }
Exemplo n.º 20
0
 public void addImportStatement(String ims) {
   displayView.addImport(ims);
 }
Exemplo n.º 21
0
 public int lineReached(SourceLine line) {
   return displayView.trackProgress(line, LINE_REACHED);
 }