Esempio n. 1
0
 public void omapCreate(IConsole console) {
   try {
     createRuntime(getFixtureHeader(), console, MarathonMode.RECORDING);
     runtime.createScript(getFixtureHeader(), "Objectmap Creation", false, true);
     startApplicationIfNecessary();
     runtime.startRecording(new DummyRecorder());
     setState(State.STOPPED_WITH_APP_OPEN);
   } catch (ScriptException e) {
     setState(State.STOPPED_WITH_APP_CLOSED);
     destroyRuntime();
     stopApplicationIfNecessary();
     reportException(e);
   }
 }
Esempio n. 2
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 + "'");
   }
 }
Esempio n. 3
0
 public String evaluateScript(String code) {
   if (state.isRecordingPaused()) {
     return runtime.evaluate(code);
   } else {
     return script.getDebugger().evaluateScriptWhenPaused(code);
   }
 }
Esempio n. 4
0
 public void openApplication(IConsole console) {
   logHeader(console, "Open");
   createRuntime(getFixtureHeader(), console, MarathonMode.RECORDING);
   runtime.createScript(getFixtureHeader(), "", false, false);
   startApplicationIfNecessary();
   setState(State.STOPPED_WITH_APP_OPEN);
   shouldClose = false;
 }
Esempio n. 5
0
 public void resume() {
   if (state.isRecordingPaused()) {
     runtime.startRecording(recorder);
     setState(State.RECORDING);
   } else {
     script.getDebugger().resume();
     setState(State.PLAYING);
   }
 }
Esempio n. 6
0
 private void destroyRuntime() {
   if (runtime != null) {
     logger.info("Destroying VM. autShutdown = " + autShutdown);
     try {
       if (!autShutdown) runtime.destroy();
     } finally {
       runtime = null;
     }
   }
 }
Esempio n. 7
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);
   }
 }
Esempio n. 8
0
 public void pauseRecording() {
   if (state.isRecording()) {
     try {
       runtime.stopRecording();
       setState(State.RECORDINGPAUSED);
     } catch (MarathonRuntimeException e) {
       setState(State.STOPPED_WITH_APP_CLOSED);
       destroyRuntime();
       throw e;
     }
   } else {
     throw new IllegalStateException("must be recording for the pause to happen");
   }
 }
Esempio n. 9
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);
 }
Esempio 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);
   }
 }
Esempio n. 11
0
 public Module getModuleFuctions() {
   if (runtime == null) return null;
   return runtime.getModuleFunctions();
 }
Esempio n. 12
0
 public String getTopWindowName() {
   if (runtime == null || runtime.getTopWindowId() == null) return null;
   return runtime.getTopWindowId().getTitle();
 }
Esempio n. 13
0
 public void recordShowChecklist(String fileName) {
   recorder.recordShowChecklistElement(runtime.getTopWindowId(), fileName);
 }
Esempio n. 14
0
 public File getScreenCapture() {
   return runtime.getScreenCapture();
 }
Esempio n. 15
0
 public void insertChecklist(String name) {
   recorder.recordInsertChecklistElement(runtime.getTopWindowId(), name);
 }
Esempio n. 16
0
 private void startApplicationIfNecessary() {
   if (state.isStoppedWithAppClosed()) {
     runtime.startApplication();
   }
 }
Esempio n. 17
0
 public void setRawRecording(boolean selected) {
   runtime.setRawRecording(selected);
 }
Esempio n. 18
0
 public String insertScript(String function) {
   WindowId topWindowId = runtime.getTopWindowId();
   runtime.insertScript(function);
   String s = recorder.recordInsertScriptElement(topWindowId, function);
   return s;
 }