Skip to content
Permalink
Browse files

dismiss the "unsaved changes" dialog if it appears

  • Loading branch information...
pabender committed Jun 14, 2019
1 parent d062999 commit 137652fcc790b137ba8b8632eb368f5ceff1a240
Showing with 26 additions and 0 deletions.
  1. +26 −0 java/acceptancetest/step_definitions/apps/ApplicationTestAcceptanceSteps.java
@@ -11,6 +11,8 @@
import jmri.util.JmriJFrame;
import jmri.util.JUnitAppender;
import jmri.util.JUnitUtil;
import org.netbeans.jemmy.operators.JButtonOperator;
import org.netbeans.jemmy.operators.JDialogOperator;

/**
* Cucumber step definitions for Application Acceptance tests.
@@ -68,6 +70,7 @@ public ApplicationTestAcceptanceSteps(jmri.InstanceManager instance) {
});

After(tags,() -> {
dismissClosingDialogs(); // this method starts a new thread
try{
// gracefully shutdown, but don't exit
((DefaultShutDownManager)instance.getDefault(jmri.ShutDownManager.class)).shutdown(0, false);
@@ -83,4 +86,27 @@ public ApplicationTestAcceptanceSteps(jmri.InstanceManager instance) {
});

}

private void dismissClosingDialogs(){
// the Unsaved Changes dialog doesn't appear every time we close,
// so put pressing No button in that dialog into a thread by itself.
// If the dialog appears, the button will be clicked, but it's not
// an error if the dialog doesn't appear.
Thread t = new Thread( () -> {
try {
JDialogOperator d = new JDialogOperator(Bundle.getMessage("UnsavedChangesTitle"));
// Find the button that deletes the panel
JButtonOperator bo = new JButtonOperator(d,Bundle.getMessage("ButtonNo"));

// Click button to delete panel and close window
bo.push();
} catch (Exception e) {
// exceptions in this thread are not considered an error.
return;
}
});
t.setName("Unsaved Changes Dialog Close Thread");
t.start();
}

}

0 comments on commit 137652f

Please sign in to comment.
You can’t perform that action at this time.