Revision: 2829
http://abbot.svn.sourceforge.net/abbot/?rev=2829&view=rev
Author: gdavison
Date: 2012-05-09 16:02:38 +0000 (Wed, 09 May 2012)
Log Message:
-----------
2012-05-12 Gerard Davison
* Updated version number to 1.3.0RC1
* Added very basic cut/copy/paste clipboard support, don't support references from another file yet
* Added the ability to just delete a step
* Bug 3524725, using the incorrect version of actionClick when parameter is a number not a string
* sort methods so that we try to match boolean, primitives, Numbers, strings then any other object
* RecordingFailedException, now uses standard cause property
* ScriptEditorFrame, a coupld of EDT violations in normal operation
* JTextComponentTester, unreliable selection on text that is not visible as drag doesn't happen when
text is offset to the end of the text field. [Removed as doesn't quite work]
* EDT violations in JTreeTester
* EDT violation in JComboxBoxTester
* EDT vioaltions in JTableTester
* JDK 7 Fixes
* StringsTest failed on JDK 7, looks like a difference in classloading, using different property names
fixed the problems
* TreePath tests failed on JDK 7, you can no longer have a null root path
* AppClassLoaderTest, fixed tests to be more reliable under garbage collection
* FileDialogRecorderTest, fixed the difference in the returned strings on different platforms
* JTabbedPanelTester, not waiting for idle after tab click
* JTableTesterTest, EDT vioaltion causing test to intermittently fail
* WeakAWTEventListenerTest, gc code lead to unreliable test
* ComponentReference, failures due to inability to access parent reference correct. (Not sure why this
wasn't cauing a problem with JDK 6, should make things faster though)
* Added support for more recent JDK versions in the Platform class
TODO add tests for editor cut/copy/paste support
Modified Paths:
--------------
abbot/trunk/ChangeLog
abbot/trunk/build.xml
abbot/trunk/doc/FAQ.shtml
abbot/trunk/doc/Tutorial-1.shtml
abbot/trunk/doc/Tutorial-2.shtml
abbot/trunk/doc/Tutorial-3.shtml
abbot/trunk/doc/download.shtml
abbot/trunk/doc/examples.shtml
abbot/trunk/doc/help.shtml
abbot/trunk/doc/news.shtml
abbot/trunk/doc/overview.shtml
abbot/trunk/doc/quick-start.shtml
abbot/trunk/doc/tutorials.shtml
abbot/trunk/doc/user-guide.shtml
abbot/trunk/lib/costello.jar
abbot/trunk/projects/jdeveloper/Tests/Tests.jpr
abbot/trunk/src/abbot/Platform.java
abbot/trunk/src/abbot/Version.java
abbot/trunk/src/abbot/editor/EditorConstants.java
abbot/trunk/src/abbot/editor/ScriptEditor.java
abbot/trunk/src/abbot/editor/ScriptEditorFrame.java
abbot/trunk/src/abbot/editor/ScriptTable.java
abbot/trunk/src/abbot/editor/i18n/costello.properties
abbot/trunk/src/abbot/editor/recorder/RecordingFailedException.java
abbot/trunk/src/abbot/overview.html
abbot/trunk/src/abbot/script/Call.java
abbot/trunk/src/abbot/script/ComponentReference.java
abbot/trunk/src/abbot/script/Script.java
abbot/trunk/src/abbot/script/Sequence.java
abbot/trunk/src/abbot/script/Step.java
abbot/trunk/src/abbot/tester/JComboBoxTester.java
abbot/trunk/src/abbot/tester/JTabbedPaneTester.java
abbot/trunk/src/abbot/tester/JTableTester.java
abbot/trunk/src/abbot/tester/JTextComponentTester.java
abbot/trunk/src/abbot/tester/JTreeTester.java
abbot/trunk/src/abbot/tester/Robot.java
abbot/trunk/src/abbot/util/WeakAWTEventListener.java
abbot/trunk/test/abbot/editor/recorder/AbstractRecorderFixture.java
abbot/trunk/test/abbot/editor/recorder/FileDialogRecorderTest.java
abbot/trunk/test/abbot/i18n/StringsTest.java
abbot/trunk/test/abbot/script/ActionTest.java
abbot/trunk/test/abbot/script/AppClassLoaderTest.java
abbot/trunk/test/abbot/script/CallTest.java
abbot/trunk/test/abbot/script/parsers/TreePathParserTest.java
abbot/trunk/test/abbot/tester/JTableTesterTest.java
abbot/trunk/test/abbot/tester/JTextComponentTesterTest.java
abbot/trunk/test/abbot/tester/JTreeLocationTest.java
abbot/trunk/test/abbot/tester/JTreeTesterTest.java
abbot/trunk/test/abbot/util/WeakAWTEventListenerTest.java
Modified: abbot/trunk/ChangeLog
===================================================================
--- abbot/trunk/ChangeLog 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/ChangeLog 2012-05-09 16:02:38 UTC (rev 2829)
@@ -1,3 +1,37 @@
+2012-05-12 Gerard Davison
+
+ * Updated version number to 1.3.0RC1
+
+ * Added very basic cut/copy/paste clipboard support, don't support references from another file yet
+ * Added the ability to just delete a step
+ * Bug 3524725, using the incorrect version of actionClick when parameter is a number not a string
+ * sort methods so that we try to match boolean, primitives, Numbers, strings then any other object
+
+ * RecordingFailedException, now uses standard cause property
+ * ScriptEditorFrame, a coupld of EDT violations in normal operation
+ * JTextComponentTester, unreliable selection on text that is not visible as drag doesn't happen when
+ text is offset to the end of the text field. [Removed as doesn't quite work]
+ * EDT violations in JTreeTester
+ * EDT violation in JComboxBoxTester
+ * EDT vioaltions in JTableTester
+
+ * JDK 7 Fixes
+ * StringsTest failed on JDK 7, looks like a difference in classloading, using different property names
+ fixed the problems
+ * TreePath tests failed on JDK 7, you can no longer have a null root path
+ * AppClassLoaderTest, fixed tests to be more reliable under garbage collection
+ * FileDialogRecorderTest, fixed the difference in the returned strings on different platforms
+ * JTabbedPanelTester, not waiting for idle after tab click
+ * JTableTesterTest, EDT vioaltion causing test to intermittently fail
+ * WeakAWTEventListenerTest, gc code lead to unreliable test
+ * ComponentReference, failures due to inability to access parent reference correct. (Not sure why this
+ wasn't cauing a problem with JDK 6, should make things faster though)
+ * Added support for more recent JDK versions in the Platform class
+
+
+ TODO add tests for editor cut/copy/paste support
+
+
2012-04-26 Gerard Davison
* Make the code in JTreeLocation EDT safe
Modified: abbot/trunk/build.xml
===================================================================
--- abbot/trunk/build.xml 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/build.xml 2012-05-09 16:02:38 UTC (rev 2829)
@@ -11,7 +11,7 @@
</description>
<!-- global properties -->
<!-- This is the master version number. Changes here affect everything. -->
- <property name="abbot.version" value="1.2.0"/>
+ <property name="abbot.version" value="1.3.0RC1"/>
<property name="copyright"
value="Copyright © 2002-2011 Timothy Wall. All Rights Reserved."/>
<property name="company.full" value="Abbot Framework"/>
Modified: abbot/trunk/doc/FAQ.shtml
===================================================================
--- abbot/trunk/doc/FAQ.shtml 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/doc/FAQ.shtml 2012-05-09 16:02:38 UTC (rev 2829)
@@ -18,7 +18,7 @@
All materials Copyright © 2002-2011
<a href=mailto:twall_AT_users.sf.net>Timothy Wall</a>,
All Rights Reserved<br><p>
-This version 1.2.0<br>
+This version 1.3.0RC1<br>
</center>
<h1>FAQ:
Modified: abbot/trunk/doc/Tutorial-1.shtml
===================================================================
--- abbot/trunk/doc/Tutorial-1.shtml 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/doc/Tutorial-1.shtml 2012-05-09 16:02:38 UTC (rev 2829)
@@ -16,7 +16,7 @@
<font color="#00CC00">A</font><font color="#FF0000">b</font><font color="#00CC00">b</font>ot framework for testing Java GUI components and programs</i><br>
All materials Copyright © 2002-2011 All Rights Reserved
<a href=mailto:twall_AT_users.sourceforge.net>Timothy Wall</a><br><p>
-This version 1.2.0-RC2
+This version 1.3.0RC1-RC2
</center>
<h1>Tutorial 1: Unit Testing A Single GUI Component</h1>
Modified: abbot/trunk/doc/Tutorial-2.shtml
===================================================================
--- abbot/trunk/doc/Tutorial-2.shtml 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/doc/Tutorial-2.shtml 2012-05-09 16:02:38 UTC (rev 2829)
@@ -16,7 +16,7 @@
<font color="#00CC00">A</font><font color="#FF0000">b</font><font color="#00CC00">b</font>ot framework for testing Java GUI components and programs</i><br>
All materials Copyright © 2002-2011 All Rights Reserved
<a href=mailto:twall_AT_users.sourceforge.net>Timothy Wall</a><br><p>
-This version 1.2.0-RC2
+This version 1.3.0RC1-RC2
</center>
<h1>Tutorial 2: Testing A Group of Components (Part I)</h1>
Modified: abbot/trunk/doc/Tutorial-3.shtml
===================================================================
--- abbot/trunk/doc/Tutorial-3.shtml 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/doc/Tutorial-3.shtml 2012-05-09 16:02:38 UTC (rev 2829)
@@ -16,7 +16,7 @@
<font color="#00CC00">A</font><font color="#FF0000">b</font><font color="#00CC00">b</font>ot framework for testing Java GUI components and programs</i><br>
All materials Copyright © 2002-2011 All Rights Reserved
<a href=mailto:twall_AT_users.sourceforge.net>Timothy Wall</a><br><p>
-This version 1.2.0
+This version 1.3.0RC1
</center>
<h1>Tutorial 3: Testing A Group of Components (Part II)</h1>
Modified: abbot/trunk/doc/download.shtml
===================================================================
--- abbot/trunk/doc/download.shtml 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/doc/download.shtml 2012-05-09 16:02:38 UTC (rev 2829)
@@ -25,14 +25,14 @@
All materials Copyright \xA9 2002-2011 <a href="mailto:twall_AT_users.sf.net">Timothy
Wall</a>, All Rights Reserved</p>
-<p align=center style='text-align:center'>This version 1.2.0 </p>
+<p align=center style='text-align:center'>This version 1.3.0RC1 </p>
<h2>Download</h2>
<p>The latest abbot package is available in [<a
-href="http://prdownloads.sf.net/abbot/abbot-1.2.0.tgz?download"><span
+href="http://prdownloads.sf.net/abbot/abbot-1.3.0RC1.tgz?download"><span
style='color:black'>tgz</span></a>] [<a
-href="http://prdownloads.sf.net/abbot/abbot-1.2.0.zip?download"><span
+href="http://prdownloads.sf.net/abbot/abbot-1.3.0RC1.zip?download"><span
style='color:black'>zip</span></a>] formats, which includes source. You can
also browse the files available at <a
href="http://sourceforge.net/project/showfiles.php?group_id=50939">SourceForge</a>,
Modified: abbot/trunk/doc/examples.shtml
===================================================================
--- abbot/trunk/doc/examples.shtml 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/doc/examples.shtml 2012-05-09 16:02:38 UTC (rev 2829)
@@ -29,7 +29,7 @@
All materials Copyright \xA9 2002-2011 <a href="mailto:twall_AT_users.sf.net">Timothy
Wall</a>, All Rights Reserved</p>
-<p align=center style='text-align:center'>This version 1.2.0-RC2</p>
+<p align=center style='text-align:center'>This version 1.3.0RC1-RC2</p>
<h3>Examples</h3>
Modified: abbot/trunk/doc/help.shtml
===================================================================
--- abbot/trunk/doc/help.shtml 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/doc/help.shtml 2012-05-09 16:02:38 UTC (rev 2829)
@@ -29,7 +29,7 @@
All materials Copyright \xA9 2002-2011 <a href="mailto:twall_AT_users.sf.net">Timothy
Wall</a>, All Rights Reserved</p>
-<p align=center style='text-align:center'>This version 1.2.0</p>
+<p align=center style='text-align:center'>This version 1.3.0RC1</p>
<h3><a name=Support></a>Questions, Help, Support and Contributions</h3>
Modified: abbot/trunk/doc/news.shtml
===================================================================
--- abbot/trunk/doc/news.shtml 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/doc/news.shtml 2012-05-09 16:02:38 UTC (rev 2829)
@@ -16,7 +16,7 @@
<div class=Section1>
<p class=MsoNormal align=center style='text-align:center'><i><span style='color:lime'>A</span></i><i><span style='color:red'>b</span></i><i><span style='color:lime'>b</span>ot framework for automated testing of Java GUI components and programs</i><br>
All materials Copyright © 2002-2011 <a href="mailto:twall_AT_users.sf.net">Timothy Wall</a>, All Rights Reserved</p>
- <p align=center style='text-align:center'>This version 1.2.0-RC2 (111118)</p>
+ <p align=center style='text-align:center'>This version 1.3.0RC1-RC2 (111118)</p>
<h2>NEWS</h2>
<ul>
<li><b>12/2011</b> 1.2 Released
Modified: abbot/trunk/doc/overview.shtml
===================================================================
--- abbot/trunk/doc/overview.shtml 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/doc/overview.shtml 2012-05-09 16:02:38 UTC (rev 2829)
@@ -19,7 +19,7 @@
style='color:#00CC00'>A</span></i><i><span style='color:red'>b</span></i><i><span
style='color:#00CC00'>b</span>ot framework for automated testing of Java GUI components and programs</i><br>
All materials Copyright \xA9 2002-2011 <a href="mailto:twall_AT_users.sf.net">Timothy Wall</a>, All Rights Reserved</p>
- <p align=center style='text-align:center'>This version 1.2.0</p>
+ <p align=center style='text-align:center'>This version 1.3.0RC1</p>
<h1 align=center style='text-align:center'>Getting Started with the Abbot Java GUI Test Framework</h1>
<h2 align=center style='text-align:center'><i>Building unit tests and functional tests (AWTUnit/SwingUnit)</i></h2>
<p class=MsoBodyText>Abbot helps you test your Java UI. It comprises Abbot, which lets you programmatically drive UI components, and Costello (built on Abbot) which allows you to easily launch, explore and control an application. The framework may be used with both scripts and compiled code.</p>
Modified: abbot/trunk/doc/quick-start.shtml
===================================================================
--- abbot/trunk/doc/quick-start.shtml 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/doc/quick-start.shtml 2012-05-09 16:02:38 UTC (rev 2829)
@@ -25,7 +25,7 @@
All materials Copyright \xA9 2002-2011 <a href="mailto:twall_AT_users.sf.net">Timothy
Wall</a>, All Rights Reserved</p>
-<p align=center style='text-align:center'>This version 1.2.0</p>
+<p align=center style='text-align:center'>This version 1.3.0RC1</p>
<h2>Quick Start</h2>
Modified: abbot/trunk/doc/tutorials.shtml
===================================================================
--- abbot/trunk/doc/tutorials.shtml 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/doc/tutorials.shtml 2012-05-09 16:02:38 UTC (rev 2829)
@@ -25,7 +25,7 @@
All materials Copyright \xA9 2002-2011 <a href="mailto:twall_AT_users.sf.net">Timothy
Wall</a>, All Rights Reserved</p>
-<p align=center style='text-align:center'>This version 1.2.0 </p>
+<p align=center style='text-align:center'>This version 1.3.0RC1 </p>
<h3><a name=QuickStart></a>Tutorials</h3>
Modified: abbot/trunk/doc/user-guide.shtml
===================================================================
--- abbot/trunk/doc/user-guide.shtml 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/doc/user-guide.shtml 2012-05-09 16:02:38 UTC (rev 2829)
@@ -16,7 +16,7 @@
All materials Copyright © 2002-2011
<a href=mailto:twall_AT_users.sf.net>Timothy Wall</a>,
All Rights Reserved<br><p>
-This version 1.2.0<br>
+This version 1.3.0RC1<br>
</center>
<center><h1>Getting Started with Costello</h1></center>
Modified: abbot/trunk/lib/costello.jar
===================================================================
(Binary files differ)
Modified: abbot/trunk/projects/jdeveloper/Tests/Tests.jpr
===================================================================
--- abbot/trunk/projects/jdeveloper/Tests/Tests.jpr 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/projects/jdeveloper/Tests/Tests.jpr 2012-05-09 16:02:38 UTC (rev 2829)
@@ -95,6 +95,7 @@
<hash n="oracle.jdeveloper.model.PathsConfiguration">
<hash n="javaContentSet">
<list n="pattern-filters">
+ <string v="-test/"/>
<string v="-abbot/tester/extensions/JGraphTesterTest.java"/>
<string v="-abbot/tester/extensions/JGraphLocationTest.java"/>
<string v="+**"/>
Modified: abbot/trunk/src/abbot/Platform.java
===================================================================
--- abbot/trunk/src/abbot/Platform.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/Platform.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -15,6 +15,9 @@
public static final int JAVA_1_4 = 0x1400;
public static final int JAVA_1_5 = 0x1500;
public static final int JAVA_1_6 = 0x1600;
+ public static final int JAVA_1_7 = 0x1700;
+ public static final int JAVA_1_8 = 0x1800;
+ public static final int JAVA_1_9 = 0x1900;
public static final String OS_NAME;
public static final String JAVA_VERSION_STRING;
@@ -76,6 +79,20 @@
public static boolean isSolaris() { return isSunOS; }
public static boolean isHPUX() { return isHPUX; }
public static boolean isLinux() { return isLinux; }
+
+ public static boolean is6OrAfter() { return JAVA_VERSION>=JAVA_1_6; }
+ public static boolean is7OrAfter() { return JAVA_VERSION>=JAVA_1_7; }
+ public static boolean is8OrAfter() { return JAVA_VERSION>=JAVA_1_8; }
+
+ public static boolean isBefore7() { return JAVA_VERSION<JAVA_1_7; }
+ public static boolean isBefore8() { return JAVA_VERSION<JAVA_1_8; }
+
+
+ public static boolean is6() { return JAVA_VERSION>=JAVA_1_6 && JAVA_VERSION<JAVA_1_7; }
+ public static boolean is7() { return JAVA_VERSION>=JAVA_1_7 && JAVA_VERSION<JAVA_1_8; }
+ public static boolean is8() { return JAVA_VERSION>=JAVA_1_8 && JAVA_VERSION<JAVA_1_9; }
+
+
public static void main(String[] args) {
System.out.println("Java version is " + JAVA_VERSION_STRING);
System.out.println("Version number is " + Integer.toHexString(JAVA_VERSION));
Modified: abbot/trunk/src/abbot/Version.java
===================================================================
--- abbot/trunk/src/abbot/Version.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/Version.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -3,7 +3,7 @@
/** Current version of the framework. */
public interface Version {
- String VERSION = "1.2.0";
+ String VERSION = "1.3.0RC1";
}
Modified: abbot/trunk/src/abbot/editor/EditorConstants.java
===================================================================
--- abbot/trunk/src/abbot/editor/EditorConstants.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/editor/EditorConstants.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -34,7 +34,10 @@
String ACTION_SCRIPT_CLOSE = "script-close";
String ACTION_SCRIPT_DELETE = "script-delete";
String ACTION_SCRIPT_CLEAR = "script-clear";
+ String ACTION_STEP_DELETE = "step-delete";
String ACTION_STEP_CUT = "step-cut";
+ String ACTION_STEP_COPY = "step-copy";
+ String ACTION_STEP_PASTE = "step-paste";
String ACTION_STEP_MOVE_UP = "step-move-up";
String ACTION_STEP_MOVE_DOWN = "step-move-down";
String ACTION_STEP_GROUP = "step-group";
Modified: abbot/trunk/src/abbot/editor/ScriptEditor.java
===================================================================
--- abbot/trunk/src/abbot/editor/ScriptEditor.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/editor/ScriptEditor.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -33,6 +33,11 @@
import abbot.tester.Robot;
import abbot.util.*;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.StringSelection;
+import java.awt.datatransfer.Transferable;
+
/**
* This is the 'model' behind the script editor UI.<p>
*
@@ -278,6 +283,9 @@
{
MENU_EDIT,
ACTION_STEP_CUT,
+ ACTION_STEP_COPY,
+ ACTION_STEP_PASTE,
+ ACTION_STEP_DELETE,
null,
ACTION_STEP_MOVE_UP,
ACTION_STEP_MOVE_DOWN,
@@ -346,6 +354,9 @@
new ScriptDeleteAction(),
new ScriptClearAction(),
new StepCutAction(),
+ new StepCopyAction(),
+ new StepPasteAction(),
+ new StepDeleteAction(),
new StepMoveUpAction(),
new StepMoveDownAction(),
new StepGroupAction(),
@@ -523,7 +534,11 @@
// Override default "cut" action in table
ActionMap amap = scriptTable.getActionMap();
+ amap.put("delete", actionMap.get(ACTION_STEP_DELETE));
amap.put("cut", actionMap.get(ACTION_STEP_CUT));
+ amap.put("copy", actionMap.get(ACTION_STEP_COPY));
+ amap.put("paste", actionMap.get(ACTION_STEP_PASTE));
+
InputMap imap = scriptTable.getInputMap();
imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "toggle");
@@ -701,8 +716,8 @@
}
catch(RecordingFailedException e) {
String msg = Strings.get("editor.recording.stop_failure");
- Throwable error = e.getReason() instanceof BugReport
- ? e.getReason() : new BugReport(msg, e.getReason());
+ Throwable error = e.getCause() instanceof BugReport
+ ? e.getCause() : new BugReport(msg, e.getCause());
Log.log("Recording stop failure: " + error.toString());
view.showWarning(msg);
status = error.getMessage();
@@ -894,14 +909,60 @@
}
}
+
/** Remove the selected step. */
- private void cutSelection() {
+ private void deleteSelection() {
int row = scriptTable.getSelectedRow();
if (row == -1) {
+ Log.warn("Unexpected delete state");
+ return;
+ }
+ List<Step> stepsToRemove = scriptTable.getSelectedSteps();
+
+ // Remove elements as required
+ removeStepsFromModel(row, stepsToRemove);
+ }
+
+
+ /** Remove the selected step. */
+ private void copySelection(boolean cut) {
+ int row = scriptTable.getSelectedRow();
+ if (row == -1) {
Log.warn("Unexpected cut state");
return;
}
- scriptModel.removeSteps(scriptTable.getSelectedSteps());
+ List<Step> stepsToRemove = scriptTable.getSelectedSteps();
+
+ // Build a string of the selected characters
+ //
+
+ StringBuilder sb = new StringBuilder();
+ for (Step nextStep : stepsToRemove) {
+ sb.append(Step.toXMLString(nextStep));
+ sb.append("\n");
+ }
+
+ // Remove elements as required
+ if (cut)
+ {
+ removeStepsFromModel(row, stepsToRemove);
+ }
+
+ // Place the text on the clipboard
+
+ Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+ clipboard.setContents(new StringSelection(sb.toString()), null);
+
+ //
+ setActionsEnabledState();
+ setStatus("");
+ }
+
+
+ private void removeStepsFromModel(int row, List<Step> stepsToRemove) {
+ // Remove the steps from the model
+
+ scriptModel.removeSteps(stepsToRemove);
int count = scriptTable.getRowCount();
if (count > 0) {
if (row >= count)
@@ -909,10 +970,75 @@
scriptTable.setRowSelectionInterval(row, row);
scriptTable.setCursorLocation(row + 1);
}
+ }
+
+ /** Remove the selected step. */
+ private void pasteSteps() {
+
+ int row = scriptTable.getSelectedRow();
+ if (row == -1) {
+ Log.warn("Unexpected paste state");
+ return;
+ }
+
+ //
+
+ String status = "";
+
+ // Right lets get hold of the steps
+
+
+ Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+ Transferable transferable = clipboard.getContents(null);
+
+ if (transferable!=null
+ && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
+
+ try
+ {
+ String st = (String)transferable.getTransferData(DataFlavor.stringFlavor);
+ // Make this string into a sequence so we can parse it
+ String sequenceString = "<sequence>\n" +
+ st +
+ "</sequence>";
+
+ Sequence sequence = Sequence.createSequenceFromString(scriptModel.getScriptOf(row), sequenceString);
+ Step step = scriptModel.getStepAt(row);
+ Sequence parent;
+ int index;
+
+ if (step instanceof Sequence
+ && scriptModel.isOpen(step)) {
+ parent = (Sequence)step;
+ index = 0;
+ }
+ else {
+ parent = scriptModel.getParent(step);
+ index = parent.indexOf(step) +1;
+ }
+
+
+ scriptModel.insertSteps(
+ parent,
+ sequence.steps(),
+ index);
+
+
+ }
+ catch (Exception ex) {
+ Log.warn(ex);
+ status = ex.getMessage();
+ }
+ }
+
+
+
setActionsEnabledState();
- setStatus("");
+ setStatus(status);
}
+
+
private void moveSelectionUp() {
scriptTable.moveUp();
setActionsEnabledState();
@@ -1184,6 +1310,19 @@
setEnabled(ACTION_SCRIPT_CLOSE, haveScript);
setEnabled(ACTION_STEP_CUT, haveScript && haveSelection);
+ setEnabled(ACTION_STEP_COPY, haveScript && haveSelection);
+
+ // Only allow string pastes
+ Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
+ Transferable transferable = clipboard.getContents(null);
+
+ setEnabled(ACTION_STEP_PASTE, haveScript && haveSelection &&
+ (transferable!=null
+ && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)));
+
+ setEnabled(ACTION_STEP_DELETE, haveScript && haveSelection);
+
+
setEnabled(ACTION_STEP_MOVE_UP,
haveScript && haveSelection && scriptTable.canMoveUp());
setEnabled(ACTION_STEP_MOVE_DOWN,
@@ -2154,8 +2293,8 @@
// Stop recording, but keep what we've got so far
stopRecording(false);
String msg = Strings.get("editor.recording.failure");
- Throwable error = e.getReason() instanceof BugReport
- ? e.getReason() : new BugReport(msg, e.getReason());
+ Throwable error = e.getCause() instanceof BugReport
+ ? e.getCause() : new BugReport(msg, e.getCause());
Log.log("Recording failure: " + error.toString());
setStatus(error.getMessage(), error.toString(), ERROR);
view.showWarning(msg);
@@ -2579,9 +2718,17 @@
else if (cmd.equals(StepEvent.STEP_FAILURE)
|| cmd.equals(StepEvent.STEP_ERROR)) {
// Make sure the table updates its colors
- int index = scriptModel.getRowOf(step);
+ final int index = scriptModel.getRowOf(step);
if (index != -1) {
- scriptModel.fireTableRowsUpdated(index, index);
+ // FIX EDT voilation
+ //
+ AWT.invokeAndWait(new Runnable()
+ {
+ public void run()
+ {
+ scriptModel.fireTableRowsUpdated(index, index);
+ }
+ });
}
setStatusForStep(step);
}
@@ -3214,9 +3361,35 @@
private class StepCutAction extends EditorAction {
public StepCutAction() { super(ACTION_STEP_CUT); }
public void actionPerformed(ActionEvent e) {
- cutSelection();
+ copySelection(true);
}
}
+ private class StepCopyAction extends EditorAction {
+ public StepCopyAction() { super(ACTION_STEP_COPY); }
+ public void actionPerformed(ActionEvent e) {
+ copySelection(false);
+ }
+ }
+ private class StepPasteAction extends EditorAction {
+ public StepPasteAction() { super(ACTION_STEP_PASTE); }
+ public void actionPerformed(ActionEvent e) {
+ pasteSteps();
+ }
+ }
+
+ private class StepDeleteAction extends EditorAction {
+ public StepDeleteAction() {
+ super(ACTION_STEP_DELETE);
+ // Remove the extra modifiers
+ putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(
+ KeyEvent.VK_DELETE, 0));
+
+ }
+ public void actionPerformed(ActionEvent e) {
+ deleteSelection();
+ }
+ }
+
private class StepMoveUpAction extends EditorAction {
public StepMoveUpAction() { super(ACTION_STEP_MOVE_UP); }
public void actionPerformed(ActionEvent e) {
Modified: abbot/trunk/src/abbot/editor/ScriptEditorFrame.java
===================================================================
--- abbot/trunk/src/abbot/editor/ScriptEditorFrame.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/editor/ScriptEditorFrame.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -207,21 +207,24 @@
*/
public void setStatus(final String msg, final String extended,
final Color color) {
- // setText is thread-safe w/r/t the dispatch thread, but setForeground
- // is not
- statusBar.setText(msg);
- statusText.setText(msg + (extended != null
- ? "\n" + extended : ""));
- Runnable action = new Runnable() {
+ // Nothing is EDT safe with the more modern repaint managers
+ // note invokeAction more like invokeLater
+ abbot.util.AWT.invokeAction(new Runnable()
+ {
+ @Override
public void run() {
- statusBar.setForeground(color);
- statusText.setForeground(color);
- if (statusWindow.isShowing())
- resizeStatusWindow();
+ statusBar.setText(msg);
+ statusText.setText(msg + (extended != null
+ ? "\n" + extended : ""));
+
+ if (!color.equals(statusBar.getForeground())) {
+ statusBar.setForeground(color);
+ statusText.setForeground(color);
+ if (statusWindow.isShowing())
+ resizeStatusWindow();
+ }
}
- };
- if (!color.equals(statusBar.getForeground()))
- abbot.util.AWT.invokeAction(action);
+ });
}
public Dimension getPreferredSize() {
Modified: abbot/trunk/src/abbot/editor/ScriptTable.java
===================================================================
--- abbot/trunk/src/abbot/editor/ScriptTable.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/editor/ScriptTable.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -425,8 +425,8 @@
/** Return the set of selected steps, restricted to siblings of the first
selected row.
*/
- public List getSelectedSteps() {
- ArrayList list = new ArrayList();
+ public List<Step> getSelectedSteps() {
+ ArrayList<Step> list = new ArrayList<Step>();
int[] rows = getSelectedRows();
if (rows.length > 0) {
Step step = model.getStepAt(rows[0]);
Modified: abbot/trunk/src/abbot/editor/i18n/costello.properties
===================================================================
--- abbot/trunk/src/abbot/editor/i18n/costello.properties 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/editor/i18n/costello.properties 2012-05-09 16:02:38 UTC (rev 2829)
@@ -329,9 +329,18 @@
actions.editor-quit=E&xit
actions.editor-quit.desc=Exit the editor
actions.editor-quit.acc=Q
+actions.step-delete=Delete
+actions.step-delete.desc=Remove the selected steps
+actions.step-delete.acc=DELETE
actions.step-cut=Cu&t
-actions.step-cut.desc=Remove the selected steps
+actions.step-cut.desc=Remove the selected steps and place in the clipboard
actions.step-cut.acc=X
+actions.step-copy=C&opy
+actions.step-copy.desc=Copy the selected steps
+actions.step-copy.acc=C
+actions.step-paste=Paste
+actions.step-paste.desc=Attempt to paste selected stesp from the clipboard
+actions.step-paste.acc=V
actions.step-move-up=Move &Up
actions.step-move-up.desc=Move the selected steps up
actions.step-move-up.acc=UP
Modified: abbot/trunk/src/abbot/editor/recorder/RecordingFailedException.java
===================================================================
--- abbot/trunk/src/abbot/editor/recorder/RecordingFailedException.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/editor/recorder/RecordingFailedException.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -1,13 +1,17 @@
package abbot.editor.recorder;
+import java.lang.annotation.Documented;
+
public class RecordingFailedException extends RuntimeException {
- private Throwable reason = null;
- public RecordingFailedException(String msg) {
- super(msg);
+ public RecordingFailedException(String msg, Throwable cause) {
+ super(msg, cause);
}
public RecordingFailedException(Throwable thr) {
- super(thr.getMessage());
- reason = thr;
+ super(thr.getMessage(), thr);
}
- public Throwable getReason() { return reason != null ? reason : this; }
+
+ @Deprecated()
+ public Throwable getReason() {
+ return getCause();
+ }
}
Modified: abbot/trunk/src/abbot/overview.html
===================================================================
--- abbot/trunk/src/abbot/overview.html 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/overview.html 2012-05-09 16:02:38 UTC (rev 2829)
@@ -9,7 +9,7 @@
<!-- FIXME not sure how to get a title into the summary... -->
<HR>
<CENTER>
-<H2>Abbot Automated GUI Testing Framework, version 1.2.0-RC2</H2>
+<H2>Abbot Automated GUI Testing Framework, version 1.3.0RC1-RC2</H2>
</CENTER>
<body bgcolor="white">
This document is the API specification for the
Modified: abbot/trunk/src/abbot/script/Call.java
===================================================================
--- abbot/trunk/src/abbot/script/Call.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/script/Call.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -253,7 +253,7 @@
// use getDeclaredMethods to include class methods
Log.debug("Resolving methods on " + cls);
Method[] mlist = cls.getMethods();
- ArrayList found = new ArrayList();
+ ArrayList<Method> found = new ArrayList<Method>();
for (int i=0;i < mlist.length;i++) {
Method m = mlist[i];
Class[] params = m.getParameterTypes();
@@ -273,7 +273,59 @@
String.valueOf(args.length), cls }));
}
- // TODO Now sort according to restrictiveness of method arguments
+ // Now sort according to restrictiveness of method arguments
+ // We can assume that the methods are the same name, we just need
+ // to prioritized boolean and scalar numbers over other objects
+
+ Collections.sort(found,
+ new Comparator<Method>() {
+
+ @Override
+ public int compare(Method o1, Method o2) {
+
+ return score(o1) - score(o2);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return super.equals(obj);
+ }
+
+
+ private int score(Method method) {
+ int score = 0;
+ for (Class parameterType : method.getParameterTypes()) {
+ score += score(parameterType);
+ }
+
+ return score;
+ }
+
+ /**
+ * So basically scalar types need to be processed first, then numbers
+ * then strings.
+ */
+ private int score(Class class1) {
+
+ if (class1 == boolean.class) {
+ return 1;
+ }
+ else if (class1.isPrimitive()) {
+ return 2;
+ }
+ else if (Number.class.isAssignableFrom(class1)) {
+ return 4;
+ }
+ else if (String.class.isAssignableFrom(class1)) {
+ return 8;
+ }
+ else {
+ // Just any old object
+ return 16;
+ }
+ }
+ });
+
Method[] list = (Method[])found.toArray(new Method[found.size()]);
//Arrays.sort(list);
Modified: abbot/trunk/src/abbot/script/ComponentReference.java
===================================================================
--- abbot/trunk/src/abbot/script/ComponentReference.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/script/ComponentReference.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -832,17 +832,18 @@
}
}
- /** Return a measure of how well the given component matches the given
- * component reference. The weight performs two functions; one is to
- * loosely match so that we can find a component even if some of its
- * attributes have changed. The other is to distinguish between similar
- * components. <p>
- * In general, we want to match if we get any weight at all, and there's
- * only one component that matches.
- */
- int getMatchWeight(Component comp) {
- return getMatchWeight(comp, new HashMap());
- }
+// Removed as in some cases it mean we were not taking into account new references.
+// /** Return a measure of how well the given component matches the given
+// * component reference. The weight performs two functions; one is to
+// * loosely match so that we can find a component even if some of its
+// * attributes have changed. The other is to distinguish between similar
+// * components. <p>
+// * In general, we want to match if we get any weight at all, and there's
+// * only one component that matches.
+// */
+// int getMatchWeight(Component comp) {
+// return getMatchWeight(comp, new HashMap());
+// }
/** Return a measure of how well the given component matches the given
* component reference. The weight performs two functions; one is to
@@ -1110,7 +1111,7 @@
if (getAttribute(TAG_PARENT) != null)
minWeight -= MW_PARENT;
if (AWT.getWindow(preferred) == null
- && getMatchWeight(preferred) >= minWeight) {
+ && getMatchWeight(preferred, newReferences) >= minWeight) {
Log.debug("Using preferred component: "
+ Robot.toString(preferred));
found = preferred;
@@ -1188,7 +1189,7 @@
*/
public static ComponentReference matchExisting(final Component comp,
Collection existing,
- Map newReferences) {
+ final Map newReferences) {
Log.debug("Matching " + Robot.toString(comp)
+ " against existing refs");
@@ -1205,8 +1206,10 @@
// Sort such that the best match comes first
Map matches = new TreeMap(new Comparator() {
public int compare(Object o1, Object o2) {
- return ((ComponentReference)o2).getMatchWeight(comp)
- - ((ComponentReference)o1).getMatchWeight(comp);
+ // Ensure newReferences are used otherwise some parents won't match
+ //
+ return ((ComponentReference)o2).getMatchWeight(comp, newReferences)
+ - ((ComponentReference)o1).getMatchWeight(comp, newReferences);
}
});
while (iter.hasNext()) {
Modified: abbot/trunk/src/abbot/script/Script.java
===================================================================
--- abbot/trunk/src/abbot/script/Script.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/script/Script.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -323,6 +323,18 @@
((Script)child).setRelativeTo(getDirectory());
}
}
+
+
+ /**Parse XML attributes for the Script.
+ */
+ protected void parseAttributes(Map map) {
+ super.parseAttributes(map);
+ fork = Boolean.valueOf((String)map.get(TAG_FORKED)).booleanValue();
+ slow = Boolean.valueOf((String)map.get(TAG_SLOW)).booleanValue();
+ awt = Boolean.valueOf((String)map.get(TAG_AWT)).booleanValue();
+ vmargs = (String)map.get(TAG_VMARGS);
+ }
+
protected void parseChild(Element el) throws InvalidScriptException {
if (el.getName().equals(TAG_COMPONENT)) {
@@ -336,14 +348,6 @@
}
}
- /** Parse XML attributes for the Script. */
- protected void parseAttributes(Map map) {
- parseStepAttributes(map);
- fork = Boolean.valueOf((String)map.get(TAG_FORKED)).booleanValue();
- slow = Boolean.valueOf((String)map.get(TAG_SLOW)).booleanValue();
- awt = Boolean.valueOf((String)map.get(TAG_AWT)).booleanValue();
- vmargs = (String)map.get(TAG_VMARGS);
- }
/** Loads the XML test script. Performs a check against the XML schema.
@param reader Provides the script data
@@ -352,30 +356,11 @@
*/
public void load(Reader reader)
throws InvalidScriptException, IOException {
+
+ // Clear existing messages
clear();
- try {
- // Set things up to optionally validate on load
- SAXBuilder builder = new SAXBuilder(validate);
- if (validate) {
- URL url = getClass().getClassLoader().getResource("abbot/abbot.xsd");
- if (url != null) {
- builder.setFeature("http://apache.org/xml/features/validation/schema", true);
- builder.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", url.toString());
- }
- else {
- Log.warn("Could not find abbot/abbot.xsd, disabling XML validation");
- validate = false;
- }
- }
- Document doc = builder.build(reader);
- Element root = doc.getRootElement();
- Map map = createAttributeMap(root);
- parseAttributes(map);
- parseChildren(root);
- }
- catch(JDOMException e) {
- throw new InvalidScriptException(e.getMessage());
- }
+ //Create the children from the reader
+ createChildrenFromReader(reader, validate);
// Make sure we have all referenced components
synchronized(this) {
synchReferenceIDs();
@@ -384,6 +369,7 @@
lastSaved = getHash();
}
+
public void addStep(int index, Step step) {
super.addStep(index, step);
updateRelativePath(step);
Modified: abbot/trunk/src/abbot/script/Sequence.java
===================================================================
--- abbot/trunk/src/abbot/script/Sequence.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/script/Sequence.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -1,11 +1,24 @@
package abbot.script;
+import abbot.Log;
+
+import java.io.IOException;
+import java.io.Reader;
+
+import java.net.URL;
+
import java.util.*;
+import org.jdom.Document;
import org.jdom.Element;
import abbot.i18n.Strings;
+import java.io.StringReader;
+
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+
/** Script step which groups a sequence of other Steps. The sub-Steps have a
* fixed order and are executed in the order contained in the sequence.
* Events sent by sub-Steps are propagated by this one.
@@ -47,6 +60,9 @@
}
}
+
+
+
protected void parseChild(Element el) throws InvalidScriptException {
Step step = createStep(getResolver(), el);
addStep(step);
@@ -177,4 +193,46 @@
sequence.remove(index);
}
}
+
+ /**
+ * @param string A string that is the serialized for of just a sequence
+ * @return A sequence object containing the relavent items
+ */
+ public static Sequence createSequenceFromString(Resolver resolver, String string) throws IOException {
+ Sequence seq = new Sequence(resolver, "Temporary Sequence");
+ seq.createChildrenFromReader(new StringReader(string), false);
+ return seq;
+ }
+
+ /**
+ * This method takes the given input reader and tries to load the contained elements, this
+ * is exposed here so that it is possible to create a sequence from a clipboard snippet.
+ * @param reader
+ * @param validate Whether to perform validation, use false for the moment for snippets
+ * @throws IOException
+ */
+ protected void createChildrenFromReader(Reader reader, boolean validate) throws IOException {
+ try {
+ // Set things up to optionally validate on load
+ SAXBuilder builder = new SAXBuilder(validate);
+ if (validate) {
+ URL url = getClass().getClassLoader().getResource("abbot/abbot.xsd");
+ if (url != null) {
+ builder.setFeature("http://apache.org/xml/features/validation/schema", true);
+ builder.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
+ url.toString());
+ } else {
+ Log.warn("Could not find abbot/abbot.xsd, disabling XML validation");
+ validate = false;
+ }
+ }
+ Document doc = builder.build(reader);
+ Element root = doc.getRootElement();
+ Map map = createAttributeMap(root);
+ parseAttributes(map);
+ parseChildren(root);
+ } catch (JDOMException e) {
+ throw new InvalidScriptException(e.getMessage());
+ }
+ }
}
Modified: abbot/trunk/src/abbot/script/Step.java
===================================================================
--- abbot/trunk/src/abbot/script/Step.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/script/Step.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -56,7 +56,7 @@
Log.debug(key + "=" + attributes.get(key));
}
}
- parseStepAttributes(attributes);
+ parseAttributes(attributes);
}
public Step(Resolver resolver, String description) {
@@ -77,7 +77,7 @@
}
/** Only exposed so that Script may invoke it on load from disk. */
- protected final void parseStepAttributes(Map attributes) {
+ protected void parseAttributes(Map attributes) {
Log.debug("Parsing attributes for " + getClass());
description = (String)attributes.get(TAG_DESC);
}
Modified: abbot/trunk/src/abbot/tester/JComboBoxTester.java
===================================================================
--- abbot/trunk/src/abbot/tester/JComboBoxTester.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/tester/JComboBoxTester.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -13,9 +13,11 @@
import abbot.finder.*;
import abbot.finder.matchers.*;
+import java.util.concurrent.Callable;
+
/**
* JComboBoxTester for testing JComboBox instances.
- *
+ *
* <p>In the case where you need to create a tester for JComboBox subclasses that
* use novel components in the popup, for example jtree, you can quickly subclass
* this tester to deal with those cases without the need to create a seperate
@@ -77,6 +79,10 @@
}
});
}
+
+ // Wait for all the events to processed
+
+ waitForIdle();
}
/** Provide an override point to select the correct index in whatever index
@@ -153,24 +159,36 @@
- public void actionSelectItem(Component comp, String item) {
- JComboBox cb = (JComboBox)comp;
+ public void actionSelectItem(Component comp, final String item) {
+ final JComboBox cb = (JComboBox)comp;
Object obj = cb.getSelectedItem();
if ((obj == null && item == null)
|| (obj != null
&& ExtendedComparator.stringsMatch(item, obj.toString())))
return;
- for (int i=0;i < cb.getItemCount();i++) {
- obj = cb.getItemAt(i);
- Log.debug("Comparing against '" + obj + "'");
- if ((obj == null && item == null)
- || (obj != null
- && ExtendedComparator.stringsMatch(item, obj.toString()))){
- actionSelectIndex(comp, i);
- return;
+ int matchedIndex = Robot.callAndWait(cb, new Callable<Integer>() {
+ @Override
+ public Integer call() {
+ for (int i=0;i < cb.getItemCount();i++) {
+ Object obj = cb.getItemAt(i);
+ Log.debug("Comparing against '" + obj + "'");
+ if ((obj == null && item == null)
+ || (obj != null
+ && ExtendedComparator.stringsMatch(item, obj.toString()))){
+ return i;
+ }
+ }
+
+ return -1;
}
+ });
+
+ if (matchedIndex!=-1) {
+ actionSelectIndex(comp, matchedIndex);
+ return;
}
+
// While actions are supposed to represent real user actions, it's
// possible that the current environment does not match sufficiently,
// so we need to throw an appropriate exception that can be used to
Modified: abbot/trunk/src/abbot/tester/JTabbedPaneTester.java
===================================================================
--- abbot/trunk/src/abbot/tester/JTabbedPaneTester.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/tester/JTabbedPaneTester.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -35,6 +35,8 @@
((JTabbedPane)comp).setSelectedIndex(e.index);
}});
}
+
+ waitForIdle();
}
/** Parse the String representation of a JTableLocation into the actual
Modified: abbot/trunk/src/abbot/tester/JTableTester.java
===================================================================
--- abbot/trunk/src/abbot/tester/JTableTester.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/tester/JTableTester.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -8,8 +8,9 @@
import javax.swing.JTable;
import abbot.script.ArgumentParser;
-import abbot.script.Condition;
+import abbot.util.Condition;
+
import java.util.concurrent.Callable;
/** Provide user actions on a JTable.
@@ -60,7 +61,7 @@
final JTableLocation.Cell found[] = new JTableLocation.Cell[1];
try {
- wait(new Condition()
+ wait(new Robot.ConditionEDTDecorator(table, new Condition()
{
public boolean test() {
try{
@@ -75,7 +76,7 @@
return Strings.get("tester.Component.show_wait",
new Object[] { loc.toString() });
}
- }, timeout);
+ }), timeout);
} catch(WaitTimedOutError e) {
throw new LocationUnavailableException(e.getMessage());
}
@@ -110,7 +111,7 @@
final JTableLocation.Cell found[] = new JTableLocation.Cell[1];
try {
- wait(new Condition()
+ wait(new Robot.ConditionEDTDecorator(table, new Condition()
{
public boolean test() {
try{
@@ -125,7 +126,7 @@
return Strings.get("tester.Component.show_wait",
new Object[] { loc.toString() });
}
- }, timeout);
+ }), timeout);
return true;
} catch(WaitTimedOutError e) {
return false;
Modified: abbot/trunk/src/abbot/tester/JTextComponentTester.java
===================================================================
--- abbot/trunk/src/abbot/tester/JTextComponentTester.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/tester/JTextComponentTester.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -164,7 +164,7 @@
}
}
-
+
/** Account for differences in scrolling {@link javax.swing.JTextField}.
@see JComponentTester#scrollRectToVisible
@see JComponent#scrollRectToVisible
@@ -219,14 +219,14 @@
*/
protected void endSelection(Component comp, int index) {
- final JTextComponent jc = (JTextComponent)comp;
+ final JTextComponent tc = (JTextComponent)comp;
// Depending on whether we are performing a normal
// or revese select we need to nudge the co-ordinate slightly
- int caretPos = callAndWait(jc, new Callable<Integer>(){
+ final int caretPos = callAndWait(tc, new Callable<Integer>(){
@Override
public Integer call() {
- return jc.getCaretPosition();
+ return tc.getCaretPosition();
}
});
@@ -239,8 +239,39 @@
}
Point where = scrollToVisible(comp, index);
- // End move just inside of visible area to make sure
- // we don't override the componet
+
+ // Get the current value based on the caret poss
+ //
+
+ final Callable<Point> mousePosition = new Callable<Point>() {
+ @Override
+ public Point call() throws BadLocationException {
+ Point rect = tc.getMousePosition();
+ return rect;
+ }
+ };
+
+// Remove temporarily as this code breaks a few other cases
+// will fix on next commit
+// Point mousePos = Robot.callAndWait(tc, mousePosition);
+// if (mousePos!=null)
+// {
+// // In some cases the text will scroll underneath the current component
+// // so the actual distance dragged is going to be very small if not zero
+// // so we are going to need to inject some minor moves, just enough
+// // to trigger the drag on the relavent platform.
+//
+// int distance = (int)Math.sqrt(
+// Math.pow((where.x - mousePos.x), 2) +
+// Math.pow((where.y - mousePos.y), 2));
+//
+// if (Math.abs(distance) < AWTConstants.DRAG_THRESHOLD) {
+// mouseMove(comp, where.x - AWTConstants.DRAG_THRESHOLD, where.y);
+// }
+// }
+
+ //
+
mouseMove(comp, where.x, where.y + nudge);
if (Platform.isOSX())
delay(75);
Modified: abbot/trunk/src/abbot/tester/JTreeTester.java
===================================================================
--- abbot/trunk/src/abbot/tester/JTreeTester.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/tester/JTreeTester.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -393,7 +393,16 @@
final TreePath realPath = getRealPath(path, timeout, tree);
if (expandWhenFound) {
- if (!tree.isExpanded(realPath)) {
+
+ Callable<Boolean> realPathExanded = new Callable<Boolean>()
+ {
+ @Override
+ public Boolean call() {
+ return tree.isExpanded(realPath);
+ }
+ };
+
+ if (!Robot.callAndWait(tree, realPathExanded)) {
// Use this method instead of a toggle action to avoid
// any component visibility requirements
invokeAndWait(new Runnable() {
@@ -529,6 +538,9 @@
throw new ActionFailedException(e.toString());
}
}
+
+ // Make sure all operations have finsished
+ waitForIdle();
}
/** Determine whether a given path exists, expanding ancestor nodes as
@@ -575,34 +587,40 @@
/** Convert the coordinate into a more meaningful location. Namely, use a
* path, row, or coordinate.
*/
- public ComponentLocation getLocation(Component c, Point p) {
- JTree tree = (JTree)c;
- if (tree.getRowCount() == 0)
- return new JTreeLocation(p);
- Rectangle rect = tree.getRowBounds(tree.getRowCount()-1);
- int maxY = rect.y + rect.height;
- if (p.y > maxY)
- return new JTreeLocation(p);
+ public ComponentLocation getLocation(final Component c, final Point p) {
+ return Robot.callAndWait(c, new Callable<JTreeLocation>()
+ {
+ @Override
+ public JTreeLocation call() {
+ JTree tree = (JTree)c;
+ if (tree.getRowCount() == 0)
+ return new JTreeLocation(p);
+ Rectangle rect = tree.getRowBounds(tree.getRowCount()-1);
+ int maxY = rect.y + rect.height;
+ if (p.y > maxY)
+ return new JTreeLocation(p);
- // TODO: ignore clicks to the left of the expansion control, or maybe
- // embed them in the location.
- TreePath path = tree.getClosestPathForLocation(p.x, p.y);
- TreePath stringPath = pathToStringPath(tree, path);
- if (stringPath != null) {
- // if the root is hidden, drop it from the path
- if (!tree.isRootVisible()) {
- Object[] objs = stringPath.getPath();
- Object[] subs = new Object[objs.length-1];
- System.arraycopy(objs, 1, subs, 0, subs.length);
- stringPath = new TreePath(subs);
+ // TODO: ignore clicks to the left of the expansion control, or maybe
+ // embed them in the location.
+ TreePath path = tree.getClosestPathForLocation(p.x, p.y);
+ TreePath stringPath = pathToStringPath(tree, path);
+ if (stringPath != null) {
+ // if the root is hidden, drop it from the path
+ if (!tree.isRootVisible()) {
+ Object[] objs = stringPath.getPath();
+ Object[] subs = new Object[objs.length-1];
+ System.arraycopy(objs, 1, subs, 0, subs.length);
+ stringPath = new TreePath(subs);
+ }
+ return new JTreeLocation(stringPath);
+ }
+ int row = tree.getClosestRowForLocation(p.x, p.y);
+ if (row != -1) {
+ return new JTreeLocation(row);
+ }
+ return new JTreeLocation(p);
}
- return new JTreeLocation(stringPath);
- }
- int row = tree.getClosestRowForLocation(p.x, p.y);
- if (row != -1) {
- return new JTreeLocation(row);
- }
- return new JTreeLocation(p);
+ });
}
}
Modified: abbot/trunk/src/abbot/tester/Robot.java
===================================================================
--- abbot/trunk/src/abbot/tester/Robot.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/tester/Robot.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -626,6 +626,11 @@
/** Sleep the given duration of ms. */
public static void delay(int ms) {
+
+ initializeRobot();
+
+ //
+
if (eventMode == EM_ROBOT) {
while (ms > MAX_DELAY) {
robot.delay(MAX_DELAY);
@@ -673,7 +678,7 @@
return false;
}
- private boolean waitForIdle(EventQueue eq) {
+ private boolean waitForIdle(EventQueue eq) {
if (EventQueue.isDispatchThread())
throw new IllegalThreadStateException("Cannot call method from the event dispatcher thread");
@@ -725,7 +730,7 @@
*
* @return Whether the waitForIdle timed out or not
*/
- public boolean waitForIdle() {
+ public boolean waitForIdle() {
if (eventPostDelay > autoDelay) {
delay(eventPostDelay - autoDelay);
}
@@ -2336,6 +2341,9 @@
* @throws WaitTimedOutError if the timeout is exceeded.
*/
public static void wait(Condition condition, long timeout, int interval) {
+ // Make sure the robot is running
+ initializeRobot();
+ //
long start = System.currentTimeMillis();
while (!condition.test()) {
if (System.currentTimeMillis() - start > timeout) {
Modified: abbot/trunk/src/abbot/util/WeakAWTEventListener.java
===================================================================
--- abbot/trunk/src/abbot/util/WeakAWTEventListener.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/src/abbot/util/WeakAWTEventListener.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -17,6 +17,14 @@
listener = new WeakReference(l);
Toolkit.getDefaultToolkit().addAWTEventListener(this, mask);
}
+
+ /**
+ * @return For testing purposes return whether the listener has been disposed
+ */
+ public boolean isDisposed() {
+ return listener.get()==null;
+ }
+
public void dispose() {
Toolkit.getDefaultToolkit().removeAWTEventListener(this);
}
Modified: abbot/trunk/test/abbot/editor/recorder/AbstractRecorderFixture.java
===================================================================
--- abbot/trunk/test/abbot/editor/recorder/AbstractRecorderFixture.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/test/abbot/editor/recorder/AbstractRecorderFixture.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -39,8 +39,8 @@
}
finally {
if (failure != null) {
- throw failure.getReason() != null
- ? failure.getReason() : failure;
+ throw failure.getCause() != null
+ ? failure.getCause() : failure;
}
}
}
Modified: abbot/trunk/test/abbot/editor/recorder/FileDialogRecorderTest.java
===================================================================
--- abbot/trunk/test/abbot/editor/recorder/FileDialogRecorderTest.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/test/abbot/editor/recorder/FileDialogRecorderTest.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -44,7 +44,10 @@
assertTrue("Expected a sequence", step instanceof Sequence);
Sequence seq = (Sequence)step;
assertStepCount(3, seq);
- assertStep("SetDirectory\\(.*," + dn.replace('\\', '.') + File.separator + "\\)",
+
+ // On JDK 7 the path returned doesn't have a file sep at the end so
+ // we add the "?" regex to match for both
+ assertStep("SetDirectory\\(.*," + dn.replace('\\', '.') + File.separator + "?" + "\\)",
seq.getStep(0));
assertStep("SetFile\\(.*," + fn + "\\)", seq.getStep(1));
assertStep("Accept\\(.*\\)", seq.getStep(2));
Modified: abbot/trunk/test/abbot/i18n/StringsTest.java
===================================================================
--- abbot/trunk/test/abbot/i18n/StringsTest.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/test/abbot/i18n/StringsTest.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -14,8 +14,8 @@
File dir = TestHelper.getClasspathDirectory(StringsTest.class);
Properties p = new Properties();
p.put("default.properties.loaded", "yes");
- p.store(new FileOutputStream(new File(dir, "test.properties")), "test");
- Strings.addBundle("test");
+ p.store(new FileOutputStream(new File(dir, "testMissingResource.properties")), "testMissingResource");
+ Strings.addBundle("testMissingResource");
Locale oldLocale = Locale.getDefault();
try {
Locale.setDefault(Locale.FRENCH);
@@ -44,8 +44,8 @@
File dir = TestHelper.getClasspathDirectory(StringsTest.class);
Properties p = new Properties();
p.put("test.property", "some value");
- p.store(new FileOutputStream(new File(dir, "test.properties")), "test");
- Strings.addBundle("test", getClass().getClassLoader());
+ p.store(new FileOutputStream(new File(dir, "testAlternateResource.properties")), "testAlternateResource");
+ Strings.addBundle("testAlternateResource", getClass().getClassLoader());
assertTrue("Should be able to load additional properties",
Strings.get("test.property") != null);
Modified: abbot/trunk/test/abbot/script/ActionTest.java
===================================================================
--- abbot/trunk/test/abbot/script/ActionTest.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/test/abbot/script/ActionTest.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -10,6 +10,8 @@
import abbot.finder.Hierarchy;
import abbot.tester.*;
+import javax.swing.text.JTextComponent;
+
public class ActionTest extends ResolverFixture {
public void testMethodFixing() throws Throwable {
@@ -40,6 +42,11 @@
public Object[] getParameters() throws Exception {
return evaluateParameters(getMethod(), getArguments());
}
+
+ @Override
+ protected Method[] getMethods() throws ClassNotFoundException, NoSuchMethodException {
+ return super.getMethods();
+ }
}
public void testVKPlusModifier() throws Exception {
@@ -55,6 +62,26 @@
new Integer(KeyEvent.SHIFT_MASK), params[2]);
}
+
+ /**
+ * Test for method ordering ala bug 3524725 in JDK 7
+ */
+ public void testSortedMethodsWithPrimitivesFirst() throws Exception {
+ ComponentReference ref = new FakeRef(getResolver());
+ MyAction action = new MyAction(getResolver(), "actionClick",
+ new String[] {
+ ref.getID(), "0",
+ }, JTextComponent.class);
+
+ Method[] methods = action.getMethods();
+
+ assertEquals("Second parameter of first method should be an int",
+ methods[0].getParameterTypes()[1], int.class);
+ assertEquals("Second parameter of second method should be an String",
+ methods[1].getParameterTypes()[1], String.class);
+ }
+
+
public void testComponentPlusVK() throws Exception {
ComponentReference ref = new ComponentReference(getResolver(),
Component.class,
Modified: abbot/trunk/test/abbot/script/AppClassLoaderTest.java
===================================================================
--- abbot/trunk/test/abbot/script/AppClassLoaderTest.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/test/abbot/script/AppClassLoaderTest.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -1,5 +1,9 @@
package abbot.script;
+import abbot.WaitTimedOutError;
+
+import abbot.tester.Robot;
+
import javax.swing.SwingUtilities;
import junit.extensions.abbot.TestHelper;
@@ -7,7 +11,11 @@
import abbot.util.NonDelegatingClassLoader;
import java.lang.ref.WeakReference;
-/**
+import java.util.concurrent.Callable;
+
+import junit.extensions.abbot.ComponentTestFixture;
+
+/**
* Verify AppClassLoader operation.
*/
@@ -23,7 +31,7 @@
/** Ensure the class loader is GC'd after uninstall. */
public void testGC() throws Exception {
acl = new AppClassLoader();
- WeakReference ref = new WeakReference(acl);
+ final WeakReference ref = new WeakReference(acl);
class Flag { volatile boolean flag; }
final Flag flag = new Flag();
@@ -40,7 +48,28 @@
acl.uninstall();
acl = null;
- System.gc();
+ // Might take more than one cc
+ try
+ {
+ Robot.wait(new abbot.util.Condition()
+ {
+ @Override
+ public boolean test() {
+ System.gc();
+ AppClassLoader test = (AppClassLoader)ref.get();
+ return test==null;
+ }
+
+ @Override
+ public String toString() {
+ return null;
+ }
+ }, 10000, 200);
+ }
+ catch (WaitTimedOutError wteo) {
+
+ }
+
acl = (AppClassLoader)ref.get();
assertTrue("Class loader reference should be GC'd", acl == null);
}
@@ -83,15 +112,20 @@
assertEquals("Context not installed on event thread",
dcl, eventClassLoader);
dcl.uninstall();
- eventClassLoader = null;
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- eventClassLoader =
- Thread.currentThread().getContextClassLoader();
- }
- });
- assertTrue("Context not uninstalled from event thread",
- eventClassLoader != dcl);
+
+
+ ComponentTestFixture.assertTrueEventually("Context not uninstalled from event thread",
+ new Callable<Boolean>()
+ {
+ @Override
+ public Boolean call() {
+ eventClassLoader =
+ Thread.currentThread().getContextClassLoader();
+ return eventClassLoader != dcl;
+ }
+ });
+
+
assertEquals("Original class loader not restored",
getClass().getClassLoader(), original);
assertEquals("Original context not restored",
Modified: abbot/trunk/test/abbot/script/CallTest.java
===================================================================
--- abbot/trunk/test/abbot/script/CallTest.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/test/abbot/script/CallTest.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -30,10 +30,13 @@
}
public void testResolveDuplicateMethods() throws Throwable {
+ // As per bug 3524725 we need to look to whether
+ // we match the correct versions of the method depending on
+ // the method type
TargetedCall call =
new TargetedCall(getResolver(), "Test Call",
CallTestClass.class.getName(),
- "someMethodDuplicated",
+ "someMethodDuplicatedSameReturn",
new String[] { "1" });
// Invoke the int version
call.run();
@@ -74,6 +77,14 @@
public void someMethod() {
derivedWasCalled = true;
}
+
+
+ public void someMethodDuplicatedSameReturn(int arg) {
+ }
+ public void someMethodDuplicatedSameReturn(String arg) {
+ }
+
+
public int someMethodDuplicated(int arg) {
return 0;
}
Modified: abbot/trunk/test/abbot/script/parsers/TreePathParserTest.java
===================================================================
--- abbot/trunk/test/abbot/script/parsers/TreePathParserTest.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/test/abbot/script/parsers/TreePathParserTest.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -1,5 +1,7 @@
package abbot.script.parsers;
+import abbot.Platform;
+
import javax.swing.tree.TreePath;
import junit.extensions.abbot.TestHelper;
@@ -23,8 +25,19 @@
public void testHiddenRoot() {
String arg = "[null, parent, child]";
- TreePath path = (TreePath)parser.parse(arg);
- assertEquals("Wrong path generated", arg, path.toString());
+ try
+ {
+ TreePath path = (TreePath)parser.parse(arg);
+ assertEquals("Wrong path generated", arg, path.toString());
+
+ assertTrue("You cannot have a null path element after JDK 6",Platform.is6OrAfter());
+ }
+ catch (IllegalArgumentException iae) {
+ // This is expected as path elements cannot be null
+ // as of JDK 7
+
+ assertTrue("Shouldn't hit this test before JDK 7",Platform.is7OrAfter());
+ }
}
protected void setUp() {
Modified: abbot/trunk/test/abbot/tester/JTableTesterTest.java
===================================================================
--- abbot/trunk/test/abbot/tester/JTableTesterTest.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/test/abbot/tester/JTableTesterTest.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -2,6 +2,7 @@
import java.awt.Component;
import java.awt.Dimension;
+import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -113,17 +114,23 @@
// Add an item two seconds later
//
- String longString = "this is a really long section of text that means that the middle co-ordinate just isn't ever going to be visible";
- dtm.removeRow(0);
- dtm.removeRow(0);
- dtm.removeRow(0);
- dtm.removeRow(0);
- dtm.addRow(new Object[] {"new value", "", "", longString });
+ final String longString = "this is a really long section of text that means that the middle co-ordinate just isn't ever going to be visible";
+
+ // Intermittent failure as being done after frame is shown so EDT violation
+ EventQueue.invokeAndWait(new Runnable() {
+ public void run() {
+ dtm.removeRow(0);
+ dtm.removeRow(0);
+ dtm.removeRow(0);
+ dtm.removeRow(0);
+ dtm.addRow(new Object[] {"new value", "", "", longString });
+
+ table.getTableHeader().getColumnModel().getColumn(3)
+ .setMinWidth(500);
+ table.invalidate();
+ }
+ });
- table.getTableHeader().getColumnModel().getColumn(3)
- .setMinWidth(500);
- table.invalidate();
-
// Now try to select
//
@@ -181,18 +188,23 @@
JScrollPane scrollPane = new JScrollPane(table);
showFrame(scrollPane);
tester.actionClick(table, new JTableLocation(0, 0));
+ tester.waitForIdle();
assertEquals("Wrong row selected", 0, table.getSelectedRow());
assertEquals("Wrong column selected", 0, table.getSelectedColumn());
tester.actionClick(table, new JTableLocation(ROWS-1, COLS-1));
+ tester.waitForIdle();
assertEquals("Wrong row selected", ROWS-1, table.getSelectedRow());
assertEquals("Wrong column selected", COLS-1, table.getSelectedColumn());
tester.actionClick(table, new JTableLocation(ROWS-1, 0));
+ tester.waitForIdle();
assertEquals("Wrong row selected", ROWS-1, table.getSelectedRow());
assertEquals("Wrong column selected", 0, table.getSelectedColumn());
tester.actionClick(table, new JTableLocation(0, COLS-1));
+ tester.waitForIdle();
assertEquals("Wrong row selected", 0, table.getSelectedRow());
assertEquals("Wrong column selected", COLS-1, table.getSelectedColumn());
tester.actionClick(table, new JTableLocation(0, 0));
+ tester.waitForIdle();
assertEquals("Wrong row selected", 0, table.getSelectedRow());
assertEquals("Wrong column selected", 0, table.getSelectedColumn());
}
Modified: abbot/trunk/test/abbot/tester/JTextComponentTesterTest.java
===================================================================
--- abbot/trunk/test/abbot/tester/JTextComponentTesterTest.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/test/abbot/tester/JTextComponentTesterTest.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -141,10 +141,10 @@
assertEquals("Wrong location",
23, tc.getCaretPosition());
- // TODO work out why this particular test is failing, seems to require a triple click
+ // A triple click required as the text is no intially visible?
tester.actionClick(tc, "size");
tester.actionClick(tc, "size");
- tester.delay(5000); // We are only testing single click
+ tester.actionClick(tc, "size");
assertEquals("Wrong location", 56, tc.getCaretPosition());
}
@@ -209,6 +209,15 @@
text.length()-1, tc.getSelectionEnd());
}
+ /**
+ * So this test appears to be failing because there is no drag operaion
+ * going on when the text is moved underneath the cursor, in the real
+ * screen the x,y co-ords are not changing so I suspect this is causing
+ * the code not to see this as a selection operation, I suspect we need to
+ * generate a mouse move event or some kind to have this work but
+ * we might need to provide a different implementation
+ * @exception
+ */
public void testSelectByText() {
showFrame(tc);
// Try a long selection and select a particular string
@@ -216,6 +225,8 @@
tc.setText(text);
tester.waitForIdle();
tester.actionSelectText(tc, "lazy");
+ tester.waitForIdle();
+
assertEquals("Wrong selection start",
36, tc.getSelectionStart());
assertEquals("Wrong selection end (hidden)",
Modified: abbot/trunk/test/abbot/tester/JTreeLocationTest.java
===================================================================
--- abbot/trunk/test/abbot/tester/JTreeLocationTest.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/test/abbot/tester/JTreeLocationTest.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -1,5 +1,7 @@
package abbot.tester;
+import abbot.Platform;
+
import java.awt.Point;
import java.awt.Rectangle;
@@ -97,10 +99,21 @@
public void testParsePathHiddenRoot() {
JTreeLocation loc = new JTreeLocation();
String parse = "[null, parent, child]";
- assertEquals("Badly parsed: " + parse,
- new JTreeLocation((TreePath)new TreePathParser().
- parse(parse)),
- loc.parse("\"" + parse + "\""));
+ try
+ {
+ assertEquals("Badly parsed: " + parse,
+ new JTreeLocation((TreePath)new TreePathParser().
+ parse(parse)),
+ loc.parse("\"" + parse + "\""));
+
+ assertTrue("You cannot have a null path element after JDK 6",Platform.is6OrAfter());
+ }
+ catch (IllegalArgumentException iae) {
+ // This is expected as path elements cannot be null
+ // as of JDK 7
+
+ assertTrue("Shouldn't hit this test before JDK 7",Platform.is7OrAfter());
+ }
}
public void testConvertHiddenRoot() {
@@ -111,19 +124,20 @@
Object parent = tree.getModel().getChild(root, 0);
Object child = tree.getModel().getChild(parent, 0);
TreePath p1 = (TreePath)
- new TreePathParser().parse("[null, parent, child]");
+ new TreePathParser().parse("[parent, child]"); // Cannot have null elements as of JDK 7 "[null, parent, child]");
TreePath p2 = JTreeLocation.findMatchingPath(tree, p1);
assertTrue("Got a null path", p2 != null);
assertEquals("Wrong root", root, p2.getPathComponent(0));
assertEquals("Wrong parent", parent, p2.getPathComponent(1));
assertEquals("Wrong child", child, p2.getPathComponent(2));
- p1 = (TreePath)new TreePathParser().parse("[parent, child]");
- p2 = JTreeLocation.findMatchingPath(tree, p1);
- assertTrue("Got a null path", p2 != null);
- assertEquals("Wrong root", root, p2.getPathComponent(0));
- assertEquals("Wrong parent", parent, p2.getPathComponent(1));
- assertEquals("Wrong child", child, p2.getPathComponent(2));
+ // Remove as we can no longer perform [null,... test in JDK 7
+// p1 = (TreePath)new TreePathParser().parse("[parent, child]");
+// p2 = JTreeLocation.findMatchingPath(tree, p1);
+// assertTrue("Got a null path", p2 != null);
+// assertEquals("Wrong root", root, p2.getPathComponent(0));
+// assertEquals("Wrong parent", parent, p2.getPathComponent(1));
+// assertEquals("Wrong child", child, p2.getPathComponent(2));
}
private static int count=0;
Modified: abbot/trunk/test/abbot/tester/JTreeTesterTest.java
===================================================================
--- abbot/trunk/test/abbot/tester/JTreeTesterTest.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/test/abbot/tester/JTreeTesterTest.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -174,6 +174,7 @@
// Avoid the next action being interpreted as the same click
tester.delay(500);
tester.actionToggleRow(tree, new JTreeLocation(row));
+ // Make sure events have fired
assertTrue("Node should not still be expanded", !tree.isExpanded(row));
}
Modified: abbot/trunk/test/abbot/util/WeakAWTEventListenerTest.java
===================================================================
--- abbot/trunk/test/abbot/util/WeakAWTEventListenerTest.java 2012-04-26 16:11:29 UTC (rev 2828)
+++ abbot/trunk/test/abbot/util/WeakAWTEventListenerTest.java 2012-05-09 16:02:38 UTC (rev 2829)
@@ -22,7 +22,9 @@
}
public void testAddAndRemove() {
- ArrayList list = new ArrayList();
+ ArrayList<AWTEventListener> list = new ArrayList<AWTEventListener>();
+ final ArrayList<WeakAWTEventListener> weakList = new ArrayList<WeakAWTEventListener>();
+
Toolkit toolkit = Toolkit.getDefaultToolkit();
int SIZE = 1000;
Listener l1 = new Listener();
@@ -31,13 +33,36 @@
for (int i=0;i < SIZE;i++) {
Listener listener = new Listener();
list.add(listener);
- new WeakAWTEventListener(listener, -1);
+ // Warning this constructor adds a listener
+ weakList.add(new WeakAWTEventListener(listener, -1));
}
Listener l2 = new Listener();
toolkit.addAWTEventListener(l2, -1);
list.clear();
- System.gc();
+
+ // We need to gc until such time as we are sure that the references are indeed tidied up
+ // System.gc() on it's own just won't cut it
+ abbot.tester.Robot.wait(new Condition()
+ {
+ @Override
+ public boolean test() {
+ System.gc();
+ for (WeakAWTEventListener next : weakList) {
+ if (!next.isDisposed()) {
+ return false;
+ }
+ }
+ return true;
+ }
+ @Override
+ public String toString() {
+ return "Need to let everything be disposed";
+ }
+ });
+
+
+
// All unreferenced listeners should be removed on the next posted
// event.
showFrame(new JLabel(getName()));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|