From: <gjo...@us...> - 2007-10-18 00:51:14
|
Revision: 2563 http://abbot.svn.sourceforge.net/abbot/?rev=2563&view=rev Author: gjohnsto Date: 2007-10-17 17:51:17 -0700 (Wed, 17 Oct 2007) Log Message: ----------- Made Formatters more generally useful for formatting single entities (e.g., Widgets). Fixed a ComboTester selection index problem due to a GTK / Windows difference. Ditto for ListTester. Modified Paths: -------------- abbot.swt/trunk/abbot.swt.test/src/abbot/swt/tester/test/ComboTesterTest.java Modified: abbot.swt/trunk/abbot.swt.test/src/abbot/swt/tester/test/ComboTesterTest.java =================================================================== --- abbot.swt/trunk/abbot.swt.test/src/abbot/swt/tester/test/ComboTesterTest.java 2007-10-17 17:01:32 UTC (rev 2562) +++ abbot.swt/trunk/abbot.swt.test/src/abbot/swt/tester/test/ComboTesterTest.java 2007-10-18 00:51:17 UTC (rev 2563) @@ -1,5 +1,7 @@ package abbot.swt.tester.test; +import java.io.PrintStream; + import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; @@ -8,10 +10,12 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; +import abbot.swt.Robot; import abbot.swt.script.Condition; import abbot.swt.tester.ComboTester; import abbot.swt.tester.WidgetTester; import abbot.swt.utilities.Wait; +import abbot.swt.utilities.WidgetFormatter; import abbot.swt.utilities.Displays.IntResult; public class ComboTesterTest extends WidgetTestFixture { @@ -22,8 +26,7 @@ private static final int ENTRY_COUNT = 10; - private static final int[] INDICES = new int[] { 2, 5, 8, 9, 5, 5, 9, 9, 0, - 0 }; + private static final int[] INDICES = new int[] { 2, 0, 0, 5, 8, 9, 9, 5 }; /** See constructor. */ private final ComboTester tester; @@ -67,23 +70,27 @@ new Label(shell, SWT.NONE).setText("Simple read/write:"); simpleRWCombo = new Combo(shell, SWT.SIMPLE | SWT.BORDER); simpleRWCombo.setItems(entries); + simpleRWCombo.setData("id", "simple, read/write"); // Simple read-only. new Label(shell, SWT.NONE).setText("Simple read-only:"); simpleROCombo = new Combo(shell, SWT.SIMPLE | SWT.READ_ONLY | SWT.BORDER); simpleROCombo.setItems(entries); + simpleROCombo.setData("id", "simple, read-only"); // Drop-down read/write. new Label(shell, SWT.NONE).setText("Drop-down read/write:"); dropDownRWCombo = new Combo(shell, SWT.DROP_DOWN | SWT.BORDER); dropDownRWCombo.setItems(entries); + dropDownRWCombo.setData("id", "drop-down, read/write"); // Drop-down read-only. new Label(shell, SWT.NONE).setText("Drop-down read-only:"); dropDownROCombo = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER); dropDownROCombo.setItems(entries); + dropDownROCombo.setData("id", "drop-down, read-only"); shell.pack(); shell.open(); @@ -331,4 +338,81 @@ tester.setText(combo, text); assertEquals(expected, tester.getText(combo)); } + + public void testRecon() { + +// sleep(900000); + + recon("first", simpleRWCombo); + recon("second", simpleRWCombo); + + recon("first", simpleROCombo); + recon("second", simpleROCombo); + + recon("first", dropDownRWCombo); + recon("second", dropDownRWCombo); + + recon("first", dropDownROCombo); + recon("second", dropDownROCombo); + } + + private void recon(String prefix, final Combo combo) { + + PrintStream out = System.err; + + class Tester extends ComboTester { + public Tester(Robot robot) { + super(robot); + } + + public void dropDownCombo(Combo combo) { + super.dropDownCombo(combo); + } + } + Tester tester = new Tester(this.tester.getRobot()); + + String id = (String) tester.getData(combo, "id"); + + final WidgetFormatter formatter = new WidgetFormatter(); + syncExec(new Runnable() { + public void run() { + formatter.format(combo, 0); + } + }); + + out.printf("\n%s (%s): %s", id, prefix, formatter.out()); + + int initial0 = tester.getSelectionIndex(combo); + out.printf("\tinitial: %d\n", initial0); + + tester.actionFocus(combo); + int style = tester.getStyle(combo); + if ((style & SWT.DROP_DOWN) != 0) + tester.dropDownCombo(combo); + + int initial1 = tester.getSelectionIndex(combo); + out.printf("\tdropped: %d\n", initial1); + + tester.actionKey(SWT.ARROW_DOWN); + sleep(250); + int down1 = tester.getSelectionIndex(combo); + out.printf("\tdown 1: %d\n", down1); + + tester.actionKey(SWT.CR); + sleep(250); + int cr = tester.getSelectionIndex(combo); + out.printf("\tcr: %d\n", cr); + + final String bogusText = "bogus"; + final String entryText = "entry5"; + String text0 = tester.getText(combo); + tester.setText(combo, bogusText); + sleep(250); + String text1 = tester.getText(combo); + tester.setText(combo, entryText); + String text2 = tester.getText(combo); + out.printf("bogus text %s: %s --> %s\n", bogusText, text0, text1); + out.printf("entry text %s: %s --> %s\n", entryText, text1, text2); + + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |