private static Object getOptionSelectionInt(final Object[] options) { // first, we record that the SUT has issued a call // to JOptionPane.showOptionDialog() JOptionPaneInputs.getInstance().addDialog(GUIAction.OPTION_SELECTION); // second, we check if an input is specified for that GUI stimulus if (JOptionPaneInputs.getInstance().containsOptionSelection()) { // return the specified input final int selection = JOptionPaneInputs.getInstance().dequeueOptionSelection(); if (selection < 0 || options == null) { // truncate lower return null; } else { if (selection >= options.length) { // truncate upper return options[options.length - 1]; } else { return options[selection]; } } } else { // return null by default if no input was specified return null; } }
public synchronized static JOptionPaneInputs getInstance() { if (instance == null) { instance = new JOptionPaneInputs(); } return instance; }
private static int getInputOkCancelSelection() { // first, we record that the SUT has issued a call // to JOptionPane.showConfirmDialog() JOptionPaneInputs.getInstance().addDialog(GUIAction.OK_CANCEL_SELECTION); // second, we check if an input is specified for that GUI stimulus if (JOptionPaneInputs.getInstance().containsOkCancelSelection()) { // return the specified input final int str = JOptionPaneInputs.getInstance().dequeueOkCancelSelection(); return str; } else { // return -1 by default if no input was specified return JOptionPane.CLOSED_OPTION; } }
/** * Enqueues a string in the queue for input strings. These strings will be * consumed by those GUI elements that required a string input * * @param data * the string to be queued */ public static void enqueueInputString(String data) { getInstance().enqueueInputString0(data); }
private static String getStringInput() { // first, we record that the SUT issued a call to // JOptionPane.showInputDialog() JOptionPaneInputs.getInstance().addDialog(GUIAction.STRING_INPUT); // second, we check if an input is specified for that GUI stimulus if (JOptionPaneInputs.getInstance().containsStringInput()) { // return the specified input final String str = JOptionPaneInputs.getInstance().dequeueStringInput(); return str; } else { // return null by default if no input was specified return null; } }
@Test public void testNoDialogBeforeExecution() { boolean hasStringDialog0 = JOptionPaneInputs.getInstance().hasDialog(GUIAction.STRING_INPUT); assertFalse(hasStringDialog0); }
private static int getInputYesNoSelection() { // first, we record that the SUT has issued a call // to JOptionPane.showConfirmDialog() JOptionPaneInputs.getInstance().addDialog(GUIAction.YES_NO_SELECTION); // second, we check if an input is specified for that GUI stimulus if (JOptionPaneInputs.getInstance().containsYesNoSelection()) { // return the specified input final int str = JOptionPaneInputs.getInstance().dequeueYesNoSelection(); return str; } else { // return -1 by default if no input was specified return JOptionPane.CLOSED_OPTION; } }
private static int getInputYesNoCancelSelection() { // first, we record that the SUT has issued a call // to JOptionPane.showConfirmDialog() JOptionPaneInputs.getInstance().addDialog(GUIAction.YES_NO_CANCEL_SELECTION); // second, we check if an input is specified for that GUI stimulus if (JOptionPaneInputs.getInstance().containsYesNoCancelSelection()) { // return the specified input final int str = JOptionPaneInputs.getInstance().dequeueYesNoCancelSelection(); return str; } else { // return -1 by default if no input was specified return JOptionPane.CLOSED_OPTION; } }
|| JOptionPaneInputs.getInstance().hasAnyDialog() || !Properties.NO_RUNTIME_DEPENDENCY || TestSuiteWriterUtils.doesUseMocks(results)) { list.add(org.junit.BeforeClass.class.getCanonicalName());
public static void enqueueYesNoCancelSelection(int selection) { getInstance().enqueueYesNoCancelSelection0(selection); }
public static void enqueueYesNoSelection(int selection) { getInstance().enqueueYesNoSelection0(selection); }
public static void enqueueOptionSelection(int selection) { getInstance().enqueueOptionSelection0(selection); }
public static void enqueueOkCancelSelection(int selection) { getInstance().enqueueOkCancelSelection0(selection); }
JOptionPaneInputs.getInstance().initForTestCase();
private void handleGUI() { if (!hasAddedJOptionPaneInputsForStrings && JOptionPaneInputs.getInstance().hasDialog(GUIAction.STRING_INPUT)) { hasAddedJOptionPaneInputsForStrings = true; && JOptionPaneInputs.getInstance().hasDialog(GUIAction.YES_NO_CANCEL_SELECTION)) { hasAddedJOptionPaneYesNoCancelSelection = true; && JOptionPaneInputs.getInstance().hasDialog(GUIAction.YES_NO_SELECTION)) { hasAddedJOptionPaneYesNoSelection = true; && JOptionPaneInputs.getInstance().hasDialog(GUIAction.OK_CANCEL_SELECTION)) { hasAddedJOptionPaneOkCancelSelection = true; && JOptionPaneInputs.getInstance().hasDialog(GUIAction.OPTION_SELECTION)) { hasAddedJOptionPaneOptionSelection = true;
if (JOptionPaneInputs.getInstance().hasAnyDialog()) { bd.append(BLOCK_SPACE); bd.append(JOptionPaneInputs.class.getName() + ".getInstance().initForTestCase(); \n");
@Test public void testShowInputDialogWasFound() throws Exception { boolean hasStringDialog0 = JOptionPaneInputs.getInstance().hasDialog(GUIAction.STRING_INPUT); assertFalse(hasStringDialog0); InstrumentingClassLoader cl = new InstrumentingClassLoader(); TestCase t1 = buildTestCase0(cl); TestCaseExecutor.getInstance().execute(t1); boolean hasStringDialog = JOptionPaneInputs.getInstance().hasDialog(GUIAction.STRING_INPUT); assertTrue(hasStringDialog); }
JOptionPaneInputs.getInstance().addDialog(GUIAction.OPTION_SELECTION); if (JOptionPaneInputs.getInstance().containsOptionSelection()) { final int selection = JOptionPaneInputs.getInstance().dequeueOptionSelection(); if (selection < JOptionPane.CLOSED_OPTION) {