Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Appel2008-03-28 14:56:55 +0000
committerFrank Appel2008-03-28 14:56:55 +0000
commit62ab78e995affb44daaed2557c276a5a7215367b (patch)
treeff639d788efd2ef249877750cbbabd65dc251c29 /tests/org.eclipse.rap.ui.tests.harness
parent18ac76b069348251f1c064e99adc2b92ebe0d1ca (diff)
downloadorg.eclipse.rap-62ab78e995affb44daaed2557c276a5a7215367b.tar.gz
org.eclipse.rap-62ab78e995affb44daaed2557c276a5a7215367b.tar.xz
org.eclipse.rap-62ab78e995affb44daaed2557c276a5a7215367b.zip
initial import
Diffstat (limited to 'tests/org.eclipse.rap.ui.tests.harness')
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/.classpath7
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/.cvsignore1
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/.project28
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/.settings/org.eclipse.jdt.core.prefs72
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/.settings/org.eclipse.jdt.ui.prefs5
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/.settings/org.eclipse.pde.prefs14
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/META-INF/MANIFEST.MF17
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/about.html28
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/build.properties15
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/icons/anything.gifbin0 -> 96 bytes
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/plugin.xml17
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/AllTests.java37
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/UITestHarnessPlugin.java66
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/tests/MocksTest.java202
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/ActionUtil.java156
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/ArrayUtil.java89
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/AutomationUtil.java57
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/CallHistory.java150
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/DialogCheck.java212
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/EmptyPerspective.java77
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/FileTool.java218
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/FileUtil.java73
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/ImageTests.java38
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/Mocks.java332
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/PlatformUtil.java29
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/TweakletCheckTest.java73
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/UITestCase.java333
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/AccessibilityTestPass.java81
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/FailureDialog.java121
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/FocusTestPass.java76
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/IDialogTestPass.java61
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/SizingTestPass.java85
-rw-r--r--tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/VerifyDialog.java329
33 files changed, 3099 insertions, 0 deletions
diff --git a/tests/org.eclipse.rap.ui.tests.harness/.classpath b/tests/org.eclipse.rap.ui.tests.harness/.classpath
new file mode 100644
index 0000000000..751c8f2e50
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/org.eclipse.rap.ui.tests.harness/.cvsignore b/tests/org.eclipse.rap.ui.tests.harness/.cvsignore
new file mode 100644
index 0000000000..ba077a4031
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/tests/org.eclipse.rap.ui.tests.harness/.project b/tests/org.eclipse.rap.ui.tests.harness/.project
new file mode 100644
index 0000000000..cbc8e28414
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.rap.ui.tests.harness</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/org.eclipse.rap.ui.tests.harness/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.rap.ui.tests.harness/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..d3ae5dee2d
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,72 @@
+#Mon Nov 19 11:44:19 CET 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.cleanOutputFolder=clean
+org.eclipse.jdt.core.builder.duplicateResourceTask=warning
+org.eclipse.jdt.core.builder.invalidClasspath=abort
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
+org.eclipse.jdt.core.circularClasspath=error
+org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
+org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.deprecation=ignore
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=no_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=error
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=enabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=error
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.incompatibleJDKLevel=ignore
+org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/tests/org.eclipse.rap.ui.tests.harness/.settings/org.eclipse.jdt.ui.prefs b/tests/org.eclipse.rap.ui.tests.harness/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000000..18b09f6e47
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,5 @@
+#Mon Feb 06 11:19:46 EST 2006
+eclipse.preferences.version=1
+internal.default.compliance=user
+org.eclipse.jdt.ui.javadoc=true
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return Returns the ${bare_field_name}.\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} The ${bare_field_name} to set.\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*******************************************************************************\n * Copyright (c) ${year} IBM Corporation and others.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors\:\n * IBM Corporation - initial API and implementation\n ******************************************************************************/\n</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @since 3.3\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template></templates>
diff --git a/tests/org.eclipse.rap.ui.tests.harness/.settings/org.eclipse.pde.prefs b/tests/org.eclipse.rap.ui.tests.harness/.settings/org.eclipse.pde.prefs
new file mode 100644
index 0000000000..883666b4d6
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/.settings/org.eclipse.pde.prefs
@@ -0,0 +1,14 @@
+#Mon Feb 21 14:17:36 EST 2005
+compilers.p.deprecated=2
+compilers.p.illegal-att-value=0
+compilers.p.no-required-att=1
+compilers.p.not-externalized-att=2
+compilers.p.unknown-attribute=0
+compilers.p.unknown-class=1
+compilers.p.unknown-element=1
+compilers.p.unknown-resource=1
+compilers.p.unresolved-ex-points=0
+compilers.p.unresolved-import=0
+compilers.p.unused-element-or-attribute=1
+compilers.use-project=true
+eclipse.preferences.version=1
diff --git a/tests/org.eclipse.rap.ui.tests.harness/META-INF/MANIFEST.MF b/tests/org.eclipse.rap.ui.tests.harness/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..620811a269
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Harness Plug-in
+Bundle-SymbolicName: org.eclipse.rap.ui.tests.harness;singleton:=true
+Bundle-Version: 1.1.0.qualifier
+Bundle-Activator: org.eclipse.ui.tests.harness.UITestHarnessPlugin
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.tests.harness,
+ org.junit,
+ org.eclipse.core.resources,
+ org.eclipse.rap.ui
+Eclipse-LazyStart: true
+Export-Package: org.eclipse.ui.tests.harness,
+ org.eclipse.ui.tests.harness.tests,
+ org.eclipse.ui.tests.harness.util,
+ org.eclipse.ui.tests.internal.util;x-internal:=true
diff --git a/tests/org.eclipse.rap.ui.tests.harness/about.html b/tests/org.eclipse.rap.ui.tests.harness/about.html
new file mode 100644
index 0000000000..460233046e
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 2, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/tests/org.eclipse.rap.ui.tests.harness/build.properties b/tests/org.eclipse.rap.ui.tests.harness/build.properties
new file mode 100644
index 0000000000..44806c6dbb
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/build.properties
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2005, 2006 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/tests/org.eclipse.rap.ui.tests.harness/icons/anything.gif b/tests/org.eclipse.rap.ui.tests.harness/icons/anything.gif
new file mode 100644
index 0000000000..efc77a7f75
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/icons/anything.gif
Binary files differ
diff --git a/tests/org.eclipse.rap.ui.tests.harness/plugin.xml b/tests/org.eclipse.rap.ui.tests.harness/plugin.xml
new file mode 100644
index 0000000000..482a837be5
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/plugin.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.perspectives">
+ <perspective
+ name="Performance Empty Perspective"
+ class="org.eclipse.ui.tests.harness.util.EmptyPerspective"
+ id="org.eclipse.ui.tests.harness.util.EmptyPerspective">
+ </perspective>
+ <perspective
+ name="Performance Empty Perspective 2"
+ class="org.eclipse.ui.tests.harness.util.EmptyPerspective"
+ id="org.eclipse.ui.tests.harness.util.EmptyPerspective2">
+ </perspective>
+ </extension>
+</plugin>
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/AllTests.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/AllTests.java
new file mode 100644
index 0000000000..42eeb6702f
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/AllTests.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.harness;
+
+import org.eclipse.ui.tests.harness.tests.MocksTest;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test the test harness :)
+ *
+ * @since 3.3
+ *
+ */
+public class AllTests extends TestSuite {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static Test suite() {
+ return new AllTests();
+ }
+
+ public AllTests() {
+ addTestSuite(MocksTest.class);
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/UITestHarnessPlugin.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/UITestHarnessPlugin.java
new file mode 100644
index 0000000000..e0d7b262b8
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/UITestHarnessPlugin.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.harness;
+
+import org.eclipse.ui.plugin.*;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class UITestHarnessPlugin extends AbstractUIPlugin {
+
+ //The shared instance.
+ private static UITestHarnessPlugin plugin;
+
+ /**
+ * The constructor.
+ */
+ public UITestHarnessPlugin() {
+ plugin = this;
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /**
+ * This method is called when the plug-in is stopped
+ */
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance.
+ *
+ * @return the shared instance.
+ */
+ public static UITestHarnessPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path.
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.ui.tests.harness", path);
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/tests/MocksTest.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/tests/MocksTest.java
new file mode 100644
index 0000000000..b7a9f5cd09
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/tests/MocksTest.java
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Brad Reynolds.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Brad Reynolds - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ui.tests.harness.tests;
+
+import java.lang.reflect.UndeclaredThrowableException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ui.tests.harness.util.Mocks;
+
+/**
+ * Tests for the Mocks class.
+ *
+ * @since 1.1
+ */
+public class MocksTest extends TestCase {
+ private IPrimitive primitiveMock;
+
+ private static boolean uninitializedBoolean;
+ private static byte unitializedByte;
+ private static char unitializedChar;
+ private static short unitializedShort;
+ private static int unitializedInt;
+ private static long unitializedLong;
+ private static float unitializedFloat;
+ private static double unitializedDouble;
+
+ protected void setUp() throws Exception {
+ primitiveMock = (IPrimitive) Mocks.createRelaxedMock(IPrimitive.class);
+ }
+
+ public void testPrimitiveBooleanReturnType() throws Exception {
+ try {
+ boolean value = primitiveMock.getBoolean();
+ assertEquals(uninitializedBoolean, value);
+ } catch (UndeclaredThrowableException e) {
+ fail("exception should not have been thrown");
+ }
+ }
+
+ public void testPrimitiveBooleanSetLastReturnValue() throws Exception {
+ Boolean value = Boolean.TRUE;
+ primitiveMock.getBoolean();
+ Mocks.setLastReturnValue(primitiveMock, value);
+ Mocks.startChecking(primitiveMock);
+
+ assertEquals(value.booleanValue(), primitiveMock.getBoolean());
+ }
+
+ public void testPrimitiveByteReturnType() throws Exception {
+ try {
+ byte value = primitiveMock.getByte();
+ assertEquals(unitializedByte, value);
+ } catch (UndeclaredThrowableException e) {
+ fail("exception should not have been thrown");
+ }
+ }
+
+ public void testPrimitiveByteSetLastReturnValue() throws Exception {
+ Byte value = new Byte((byte) 1);
+ primitiveMock.getByte();
+ Mocks.setLastReturnValue(primitiveMock, value);
+ Mocks.startChecking(primitiveMock);
+
+ assertEquals(value.byteValue(), primitiveMock.getByte());
+ }
+
+ public void testPrimitiveCharReturnType() throws Exception {
+ try {
+ char value = primitiveMock.getChar();
+ assertEquals(unitializedChar, value);
+ } catch (UndeclaredThrowableException e) {
+ fail("exception should not have been thrown");
+ }
+ }
+
+ public void testPrimitiveCharSetLastReturnValue() throws Exception {
+ Character value = new Character('a');
+ primitiveMock.getChar();
+ Mocks.setLastReturnValue(primitiveMock, value);
+ Mocks.startChecking(primitiveMock);
+
+ assertEquals(value.charValue(), primitiveMock.getChar());
+ }
+
+ public void testPrimitiveShortReturnType() throws Exception {
+ try {
+ short value = primitiveMock.getShort();
+ assertEquals(unitializedShort, value);
+ } catch (UndeclaredThrowableException e) {
+ fail("exception should not have been thrown");
+ }
+ }
+
+ public void testPrimitiveShortSetLastReturnValue() throws Exception {
+ Short value = new Short((short) 1);
+ primitiveMock.getShort();
+ Mocks.setLastReturnValue(primitiveMock, value);
+ Mocks.startChecking(primitiveMock);
+
+ assertEquals(value.shortValue(), primitiveMock.getShort());
+ }
+
+ public void testPrimitiveIntReturnType() throws Exception {
+ try {
+ int value = primitiveMock.getInt();
+ assertEquals(unitializedInt, value);
+ } catch (UndeclaredThrowableException e) {
+ fail("exception should not have been thrown");
+ }
+ }
+
+ public void testPrimitiveIntSetLastReturnValue() throws Exception {
+ Integer value = new Integer(1);
+ primitiveMock.getInt();
+ Mocks.setLastReturnValue(primitiveMock, value);
+ Mocks.startChecking(primitiveMock);
+
+ assertEquals(value.intValue(), primitiveMock.getInt());
+ }
+
+ public void testPrimitiveLongReturnType() throws Exception {
+ try {
+ long value = primitiveMock.getLong();
+ assertEquals(unitializedLong, value);
+ } catch (UndeclaredThrowableException e) {
+ fail("exception should not have been thrown");
+ }
+ }
+
+ public void testPrimitiveLongSetLastReturnValue() throws Exception {
+ Long value = new Long(1);
+ primitiveMock.getLong();
+ Mocks.setLastReturnValue(primitiveMock, value);
+ Mocks.startChecking(primitiveMock);
+
+ assertEquals(value.longValue(), primitiveMock.getLong());
+ }
+
+ public void testPrimitiveFloatReturnType() throws Exception {
+ try {
+ float value = primitiveMock.getFloat();
+ assertEquals(unitializedFloat, value, 0);
+ } catch (UndeclaredThrowableException e) {
+ fail("exception should not have been thrown");
+ }
+ }
+
+ public void testPrimitiveFloatSetLastReturnValue() throws Exception {
+ Float value = new Float(1);
+ primitiveMock.getFloat();
+ Mocks.setLastReturnValue(primitiveMock, value);
+ Mocks.startChecking(primitiveMock);
+
+ assertEquals(value.floatValue(), primitiveMock.getFloat(), 0);
+ }
+
+ public void testPrimitiveDoubleReturnType() throws Exception {
+ try {
+ double value = primitiveMock.getDouble();
+ assertEquals(unitializedDouble, value, 0);
+ } catch (UndeclaredThrowableException e) {
+ fail("exception should not have been thrown");
+ }
+ }
+
+ public void testPrimitiveDoubleSetLastReturnValue() throws Exception {
+ Double value = new Double(1);
+ primitiveMock.getDouble();
+ Mocks.setLastReturnValue(primitiveMock, value);
+ Mocks.startChecking(primitiveMock);
+
+ assertEquals(value.doubleValue(), primitiveMock.getDouble(), 0);
+ }
+
+ public interface IPrimitive {
+ public boolean getBoolean();
+
+ public byte getByte();
+
+ public char getChar();
+
+ public short getShort();
+
+ public int getInt();
+
+ public long getLong();
+
+ public float getFloat();
+
+ public double getDouble();
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/ActionUtil.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/ActionUtil.java
new file mode 100644
index 0000000000..35e5393782
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/ActionUtil.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.harness.util;
+
+import java.lang.reflect.Method;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.SubContributionItem;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.internal.WorkbenchWindow;
+
+/**
+ * <code>ActionUtil</code> contains methods to run actions
+ * in the workbench.
+ */
+public class ActionUtil {
+
+ /**
+ * Runs an action contribution.
+ *
+ * @param test the current test case
+ * @param item an action contribution item
+ */
+ public static void runAction(TestCase test, IContributionItem item) {
+ Assert.assertTrue(item instanceof ActionContributionItem);
+ ((ActionContributionItem) item).getAction().run();
+ }
+
+ /**
+ * Runs the first action found in a menu manager with a
+ * particular label.
+ *
+ * @param test the current test case
+ * @param mgr the containing menu manager
+ * @param label the action label
+ */
+ public static void runActionWithLabel(TestCase test, IMenuManager mgr,
+ String label) {
+ IContributionItem[] items = mgr.getItems();
+ for (int nX = 0; nX < items.length; nX++) {
+ IContributionItem item = items[nX];
+ if (item instanceof SubContributionItem)
+ item = ((SubContributionItem) item).getInnerItem();
+ if (item instanceof ActionContributionItem) {
+ IAction action = ((ActionContributionItem) item).getAction();
+ if (label.equals(action.getText())) {
+ action.run();
+ return;
+ }
+ }
+ }
+ Assert.fail("Unable to find action: " + label);
+ }
+
+ /**
+ * Runs the first action found in a window with a
+ * particular label.
+ *
+ * @param test the current test case
+ * @param win the containing window
+ * @param label the action label
+ */
+ public static void runActionWithLabel(TestCase test, IWorkbenchWindow win,
+ String label) {
+ WorkbenchWindow realWin = (WorkbenchWindow) win;
+ IMenuManager mgr = realWin.getMenuManager();
+ runActionWithLabel(test, mgr, label);
+ }
+
+ /**
+ * Runs an action identified by an id path in a
+ * menu manager.
+ *
+ * @param test the current test case
+ * @param mgr the containing menu manager
+ * @param label the action label
+ */
+ public static void runActionUsingPath(TestCase test, IMenuManager mgr,
+ String idPath) {
+ IContributionItem item = mgr.findUsingPath(idPath);
+ Assert.assertNotNull(item);
+ runAction(test, item);
+ }
+
+ /**
+ * Runs an action identified by an id path in a
+ * window.
+ *
+ * @param test the current test case
+ * @param win the containing window
+ * @param label the action label
+ */
+ public static void runActionUsingPath(TestCase test, IWorkbenchWindow win,
+ String idPath) {
+ WorkbenchWindow realWin = (WorkbenchWindow) win;
+ IMenuManager mgr = realWin.getMenuManager();
+ runActionUsingPath(test, mgr, idPath);
+ }
+
+ /**
+ * Returns the first action found in a menu manager with a
+ * particular label.
+ *
+ * @param mgr the containing menu manager
+ * @param label the action label
+ * @return the first action with the label, or <code>null</code>
+ * if it is not found.
+ */
+ public static IAction getActionWithLabel(IMenuManager mgr, String label) {
+ IContributionItem[] items = mgr.getItems();
+ for (int nX = 0; nX < items.length; nX++) {
+ IContributionItem item = items[nX];
+ if (item instanceof SubContributionItem)
+ item = ((SubContributionItem) item).getInnerItem();
+ if (item instanceof ActionContributionItem) {
+ IAction action = ((ActionContributionItem) item).getAction();
+ if (label.equals(action.getText())) {
+ return action;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Fire the "handleAboutToShow" method in a menu manager.
+ * This triggers the same behavior as when a user opens a menu.
+ * The menu to be populated with actions and those
+ * actions to be enacted in SWT widgets.
+ *
+ * @param mgr the menu manager to open
+ */
+ public static void fireAboutToShow(MenuManager mgr) throws Throwable {
+ Class clazz = mgr.getClass();
+ Method method = clazz.getDeclaredMethod("handleAboutToShow",
+ new Class[0]);
+ method.setAccessible(true);
+ method.invoke(mgr, new Object[0]);
+ }
+}
+
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/ArrayUtil.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/ArrayUtil.java
new file mode 100644
index 0000000000..9afabce193
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/ArrayUtil.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.harness.util;
+
+import java.util.Random;
+
+/**
+ * <code>ArrayUtil</code> contains methods for array
+ * examination.
+ */
+public class ArrayUtil {
+ private static Random randomBox = new Random();
+
+ /**
+ * Returns a random object chosen from an array.
+ *
+ * @param array the input array
+ * @return a random object in the array
+ */
+ public static Object pickRandom(Object[] array) {
+ int num = randomBox.nextInt(array.length);
+ return array[num];
+ }
+
+ /**
+ * Returns whether an array is not null and
+ * each object in the array is not null.
+ *
+ * @param array the input array
+ * @return <code>true or false</code>
+ */
+ public static boolean checkNotNull(Object[] array) {
+ if (array == null)
+ return false;
+ else {
+ for (int i = 0; i < array.length; i++)
+ if (array[i] == null)
+ return false;
+ return true;
+ }
+ }
+
+ /**
+ * Returns whether an array contains a given object.
+ *
+ * @param array the input array
+ * @param element the test object
+ * @return <code>true</code> if the array contains the object,
+ * <code>false</code> otherwise.
+ */
+ public static boolean contains(Object[] array, Object element) {
+ if (array == null || element == null)
+ return false;
+ else {
+ for (int i = 0; i < array.length; i++)
+ if (array[i] == element)
+ return true;
+ return false;
+ }
+ }
+
+ /**
+ * Returns whether two arrays are equal. They must
+ * have the same size and the same contents.
+ *
+ * @param one the first array
+ * @param two the second array
+ * @return <code>true</code> if the array are equal,
+ * <code>false</code> otherwise.
+ */
+ public static boolean equals(Object[] one, Object[] two) {
+ if (one.length != two.length)
+ return false;
+ else {
+ for (int i = 0; i < one.length; i++)
+ if (one[i] != two[i])
+ return false;
+ return true;
+ }
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/AutomationUtil.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/AutomationUtil.java
new file mode 100644
index 0000000000..f9ac005015
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/AutomationUtil.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.harness.util;
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * <code>AutomationUtil</code> contains utility methods to mimic key events.
+ * Mouse event methods can be added if needed to complete this class.
+ */
+public class AutomationUtil {
+
+ /**
+ * Method to mimic a key code event on a display.
+ *
+ * @param display
+ * The display.
+ * @param eventType
+ * The event type.
+ * @param keyCode
+ * The key code.
+ */
+ public static void performKeyCodeEvent(Display display, int eventType,
+ int keyCode) {
+ Event event = new Event();
+ event.type = eventType;
+ event.keyCode = keyCode;
+// display.post(event);
+ }
+
+ /**
+ * Method to mimic a character event on a display.
+ *
+ * @param display
+ * The display.
+ * @param eventType
+ * The event type.
+ * @param character
+ * The character to mimic.
+ */
+ public static void performCharacterEvent(Display display, int eventType,
+ char character) {
+ Event event = new Event();
+ event.type = eventType;
+ event.character = character;
+// display.post(event);
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/CallHistory.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/CallHistory.java
new file mode 100644
index 0000000000..4ec7030962
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/CallHistory.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.harness.util;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+
+/**
+ * <code>CallHistory</code> is used to record the invocation
+ * of methods within a target object. This is useful during
+ * lifecycle testing for an object.
+ * <p>
+ * To use <code>CallHistory</code> ..
+ * <ol>
+ * <li>Create a CallHistory in the target or pass one in.</li>
+ * <li>Invoke some test scenario. </li>
+ * <li>If a method is called on the target record the invocation
+ * in the call history</li>
+ * <li>Verify the call history after the test scenario is
+ * complete.</li>
+ * </ol>
+ * </p><p>
+ * Each <code>CallHistory</code> has a target which is used to
+ * verify the method names passed to the history. If an invalid
+ * name is passed an <code>IllegalArgumentException</code> will
+ * be thrown.
+ * </p>
+ */
+public class CallHistory {
+ private ArrayList methodList;
+
+ private Class classType;
+
+ /**
+ * Creates a new call history for an object.
+ *
+ * @param target the call history target.
+ */
+ public CallHistory(Object target) {
+ methodList = new ArrayList();
+ classType = target.getClass();
+ }
+
+ /**
+ * Throws an exception if the method name is invalid
+ * for the given target class.
+ */
+ private void testMethodName(String methodName) {
+ Method[] methods = classType.getMethods();
+ for (int i = 0; i < methods.length; i++)
+ if (methods[i].getName().equals(methodName))
+ return;
+ throw new IllegalArgumentException("Target class ("
+ + classType.getName() + ") does not contain method: "
+ + methodName);
+ }
+
+ /**
+ * Adds a method name to the call history.
+ *
+ * @param methodName the name of a method
+ */
+ public void add(String methodName) {
+ testMethodName(methodName);
+ methodList.add(methodName);
+ }
+
+ /**
+ * Clears the call history.
+ */
+ public void clear() {
+ methodList.clear();
+ }
+
+ /**
+ * Returns whether a list of methods have been called in
+ * order.
+ *
+ * @param testNames an array of the method names in the order they are expected
+ * @return <code>true</code> if the methods were called in order
+ */
+ public boolean verifyOrder(String[] testNames)
+ throws IllegalArgumentException {
+ int testIndex = 0;
+ int testLength = testNames.length;
+ if (testLength == 0)
+ return true;
+ for (int nX = 0; nX < methodList.size(); nX++) {
+ String methodName = (String) methodList.get(nX);
+ String testName = testNames[testIndex];
+ testMethodName(testName);
+ if (testName.equals(methodName))
+ ++testIndex;
+ if (testIndex >= testLength)
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns whether a method has been called.
+ *
+ * @param methodName a method name
+ * @return <code>true</code> if the method was called
+ */
+ public boolean contains(String methodName) {
+ testMethodName(methodName);
+ return methodList.contains(methodName);
+ }
+
+ /**
+ * Returns whether a list of methods were called.
+ *
+ * @param methodNames a list of methods
+ * @return <code>true</code> if the methods were called
+ */
+ public boolean contains(String[] methodNames) {
+ for (int i = 0; i < methodNames.length; i++) {
+ testMethodName(methodNames[i]);
+ if (!methodList.contains(methodNames[i]))
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Returns whether the list of methods called is empty.
+ *
+ * @return <code>true</code> iff the list of methods is empty
+ */
+ public boolean isEmpty() {
+ return methodList.isEmpty();
+ }
+
+ /**
+ * Prints the call history to the console.
+ */
+ public void printToConsole() {
+ for (int i = 0; i < methodList.size(); i++)
+ System.out.println(methodList.get(i));
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/DialogCheck.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/DialogCheck.java
new file mode 100644
index 0000000000..f7f0c37571
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/DialogCheck.java
@@ -0,0 +1,212 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.harness.util;
+
+import junit.framework.Assert;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.ui.internal.WorkbenchPlugin;
+import org.eclipse.ui.tests.internal.util.VerifyDialog;
+
+/**
+ * A <code>DialogCheck</code> is used test a dialog in
+ * various ways.
+ * <p>
+ * For interactive tests use <code>assertDialog</code>.
+ * For automated tests use <code>assert DialogTexts</code>.
+ * </p>
+ */
+public class DialogCheck {
+ private DialogCheck() {
+ }
+
+ private static VerifyDialog _verifyDialog;
+
+ /**
+ * Asserts that a given dialog is not null and that it passes
+ * certain visual tests. These tests will be verified manually
+ * by the tester using an input dialog. Use this assert method
+ * to verify a dialog's sizing, initial focus, or accessiblity.
+ * To ensure that both the input dialog and the test dialog are
+ * accessible by the tester, the getShell() method should be used
+ * when creating the test dialog.
+ *
+ * Example usage:
+ * <code>Dialog dialog = new AboutDialog( DialogCheck.getShell() );
+ * DialogCheck.assertDialog(dialog, this);</code>
+ *
+ * @param dialog the test dialog to be verified.
+ * @param assert this is the test case object, assertions will be
+ * executed on this object.
+ */
+ public static void assertDialog(Dialog dialog, Assert assertion) {
+ Assert.assertNotNull(dialog);
+ if (_verifyDialog.getShell() == null) {
+ //force the creation of the verify dialog
+ getShell();
+ }
+ if (_verifyDialog.open(dialog) == IDialogConstants.NO_ID) {
+ Assert.assertTrue(_verifyDialog.getFailureText(), false);
+ }
+ }
+
+ /**
+ * Automated test that checks all the labels and buttons of a dialog
+ * to make sure there is enough room to display all the text. Any
+ * text that wraps is only approximated and is currently not accurate.
+ *
+ * @param dialog the test dialog to be verified.
+ * @param assert this is the test case object, assertions will be
+ * executed on this object.
+ */
+ public static void assertDialogTexts(Dialog dialog, Assert assertion) {
+ Assert.assertNotNull(dialog);
+ dialog.setBlockOnOpen(false);
+ dialog.open();
+ Shell shell = dialog.getShell();
+ verifyCompositeText(shell, assertion);
+ dialog.close();
+ }
+
+ /**
+ * This method should be called when creating dialogs to test. This
+ * ensures that the dialog's parent shell will be that of the
+ * verification dialog.
+ *
+ * @return Shell The shell of the verification dialog to be used as
+ * the parent shell of the test dialog.
+ */
+ public static Shell getShell() {
+ Shell shell = WorkbenchPlugin.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow().getShell();
+ _verifyDialog = new VerifyDialog(shell);
+ _verifyDialog.create();
+ return _verifyDialog.getShell();
+ }
+
+ /*
+ * Looks at all the child widgets of a given composite and
+ * verifies the text on all labels and widgets.
+ * @param composite The composite to look through
+ * @param assert The object to invoke assertions on.
+ */
+ private static void verifyCompositeText(Composite composite,
+ Assert assertion) {
+ Control children[] = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ Control child = children[i];
+ if (child instanceof TabFolder) {
+ TabFolder folder = (TabFolder) child;
+ int numPages = folder.getItemCount();
+ for (int j = 0; j < numPages; j++) {
+ folder.setSelection(j);
+ }
+ }
+ else if (child instanceof Button) {
+ //verify the text if the child is a button
+ verifyButtonText((Button) child, assertion);
+ }
+ else if (child instanceof Label) {
+ //child is not a button, maybe a label
+ verifyLabelText((Label) child, assertion);
+ }
+ else if (child instanceof Composite) {
+ //child is not a label, make a recursive call if it is a composite
+ verifyCompositeText((Composite) child, assertion);
+ }
+ }
+ }
+
+ /*
+ * Verifies that a given button is large enough to display its text.
+ * @param button The button to verify,
+ * @param assert The object to invoke assertions on.
+ */
+ private static void verifyButtonText(Button button, Assert assertion) {
+ String widget = button.toString();
+ Point size = button.getSize();
+
+ //compute the size with no line wrapping
+ Point preferred = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ //if (size.y/preferred.y) == X, then label spans X lines, so divide
+ //the calculated value of preferred.x by X
+ if (preferred.y * size.y > 0) {
+ preferred.y /= countLines(button.getText()); //check for '\n\'
+ if (size.y / preferred.y > 1) {
+ preferred.x /= (size.y / preferred.y);
+ }
+ }
+
+ String message = new StringBuffer("Warning: ").append(widget).append(
+ "\n\tActual Width -> ").append(size.x).append(
+ "\n\tRecommended Width -> ").append(preferred.x).toString();
+ if (preferred.x > size.x) {
+ //close the dialog
+ button.getShell().dispose();
+ Assert.assertTrue(message.toString(), false);
+ }
+ }
+
+ /*
+ * Verifies that a given label is large enough to display its text.
+ * @param label The label to verify,
+ * @param assert The object to invoke assertions on.
+ */
+ private static void verifyLabelText(Label label, Assert assertion) {
+ String widget = label.toString();
+ Point size = label.getSize();
+
+ //compute the size with no line wrapping
+ Point preferred = label.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ //if (size.y/preferred.y) == X, then label spans X lines, so divide
+ //the calculated value of preferred.x by X
+ if (preferred.y * size.y > 0) {
+ preferred.y /= countLines(label.getText());
+ if (size.y / preferred.y > 1) {
+ preferred.x /= (size.y / preferred.y);
+ }
+ }
+ String message = new StringBuffer("Warning: ").append(widget).append(
+ "\n\tActual Width -> ").append(size.x).append(
+ "\n\tRecommended Width -> ").append(preferred.x).toString();
+ if (preferred.x > size.x) {
+ //close the dialog
+ label.getShell().dispose();
+ Assert.assertTrue(message.toString(), false);
+ }
+ }
+
+ /*
+ * Counts the number of lines in a given String.
+ * For example, if a string contains one (1) newline character,
+ * a value of two (2) would be returned.
+ * @param text The string to look through.
+ * @return int the number of lines in text.
+ */
+ private static int countLines(String text) {
+ int newLines = 1;
+ for (int i = 0; i < text.length(); i++) {
+ if (text.charAt(i) == '\n') {
+ newLines++;
+ }
+ }
+ return newLines;
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/EmptyPerspective.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/EmptyPerspective.java
new file mode 100644
index 0000000000..3baed17e45
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/EmptyPerspective.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.harness.util;
+
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+/**
+ * This perspective is used for testing api. It defines an initial
+ * layout with no parts, just an editor area.
+ */
+public class EmptyPerspective implements IPerspectiveFactory {
+
+ /**
+ * The perspective id for the empty perspective.
+ */
+ public static final String PERSP_ID = "org.eclipse.ui.tests.harness.util.EmptyPerspective";
+
+ /**
+ * The perspective id for the second empty perspective.
+ */
+ public static final String PERSP_ID2 = "org.eclipse.ui.tests.harness.util.EmptyPerspective2";
+
+ private static String LastPerspective;
+
+ /**
+ * Returns the descriptor for the perspective last opened using this factory.
+ *
+ * @return the descriptor for the perspective last opened using this factory, or <code>null</code>
+ */
+ public static String getLastPerspective() {
+ return LastPerspective;
+ }
+
+ /**
+ * Sets the descriptor for the perspective last opened using this factory.
+ *
+ * @param persp the descriptor for the perspective last opened using this factory, or <code>null</code>
+ */
+ public static void setLastPerspective(String perspId) {
+ LastPerspective = perspId;
+ }
+
+ /**
+ * Constructs a new Default layout engine.
+ */
+ public EmptyPerspective() {
+ super();
+ }
+
+ /**
+ * Defines the initial layout for a perspective.
+ *
+ * Implementors of this method may add additional views to a
+ * perspective. The perspective already contains an editor folder
+ * with <code>ID = ILayoutFactory.ID_EDITORS</code>. Add additional views
+ * to the perspective in reference to the editor folder.
+ *
+ * This method is only called when a new perspective is created. If
+ * an old perspective is restored from a persistence file then
+ * this method is not called.
+ *
+ * @param factory the factory used to add views to the perspective
+ */
+ public void createInitialLayout(IPageLayout layout) {
+ setLastPerspective(layout.getDescriptor().getId());
+ // do no layout, this is the empty perspective
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/FileTool.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/FileTool.java
new file mode 100644
index 0000000000..47e6b2adda
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/FileTool.java
@@ -0,0 +1,218 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ui.tests.harness.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+
+
+public class FileTool {
+
+ /**
+ * A buffer.
+ */
+ private static byte[] buffer = new byte[8192];
+ /**
+ * Unzips the given zip file to the given destination directory
+ * extracting only those entries the pass through the given
+ * filter.
+ *
+ * @param filter filters out unwanted zip entries
+ * @param zipFile the zip file to unzip
+ * @param dstDir the destination directory
+ */
+ public static void unzip(ZipFile zipFile, File dstDir) throws IOException {
+ unzip(zipFile, dstDir, dstDir, 0);
+ }
+
+ private static void unzip(ZipFile zipFile, File rootDstDir, File dstDir, int depth) throws IOException {
+
+ Enumeration entries = zipFile.entries();
+
+ try {
+ while(entries.hasMoreElements()){
+ ZipEntry entry = (ZipEntry)entries.nextElement();
+ if(entry.isDirectory()){
+ continue;
+ }
+ String entryName = entry.getName();
+ File file = new File(dstDir, changeSeparator(entryName, '/', File.separatorChar));
+ file.getParentFile().mkdirs();
+ InputStream src = null;
+ OutputStream dst = null;
+ try {
+ src = zipFile.getInputStream(entry);
+ dst = new FileOutputStream(file);
+ transferData(src, dst);
+ } finally {
+ if(dst != null){
+ try {
+ dst.close();
+ } catch(IOException e){
+ }
+ }
+ if(src != null){
+ try {
+ src.close();
+ } catch(IOException e){
+ }
+ }
+ }
+ }
+ } finally {
+ try {
+ zipFile.close();
+ } catch(IOException e){
+ }
+ }
+ }
+ /**
+ * Returns the given file path with its separator
+ * character changed from the given old separator to the
+ * given new separator.
+ *
+ * @param path a file path
+ * @param oldSeparator a path separator character
+ * @param newSeparator a path separator character
+ * @return the file path with its separator character
+ * changed from the given old separator to the given new
+ * separator
+ */
+ public static String changeSeparator(String path, char oldSeparator, char newSeparator){
+ return path.replace(oldSeparator, newSeparator);
+ }
+ /**
+ * Copies all bytes in the given source file to
+ * the given destination file.
+ *
+ * @param source the given source file
+ * @param destination the given destination file
+ */
+ public static void transferData(File source, File destination) throws IOException {
+ destination.getParentFile().mkdirs();
+ InputStream is = null;
+ OutputStream os = null;
+ try {
+ is = new FileInputStream(source);
+ os = new FileOutputStream(destination);
+ transferData(is, os);
+ } finally {
+ if(os != null){
+ try {
+ os.close();
+ } catch(IOException e){
+ }
+ }
+ if(is != null){
+ try {
+ is.close();
+ } catch(IOException e){
+ }
+ }
+ }
+ }
+ /**
+ * Copies all bytes in the given source stream to
+ * the given destination stream. Neither streams
+ * are closed.
+ *
+ * @param source the given source stream
+ * @param destination the given destination stream
+ */
+ public static void transferData(InputStream source, OutputStream destination) throws IOException {
+ int bytesRead = 0;
+ while(bytesRead != -1){
+ bytesRead = source.read(buffer, 0, buffer.length);
+ if(bytesRead != -1){
+ destination.write(buffer, 0, bytesRead);
+ }
+ }
+ }
+
+ /**
+ * Copies the given source file to the given destination file.
+ *
+ * @param src the given source file
+ * @param dst the given destination file
+ */
+ public static void copy(File src, File dst) throws IOException {
+ if(src.isDirectory()){
+ String[] srcChildren = src.list();
+ for(int i = 0; i < srcChildren.length; ++i){
+ File srcChild= new File(src, srcChildren[i]);
+ File dstChild= new File(dst, srcChildren[i]);
+ copy(srcChild, dstChild);
+ }
+ } else
+ transferData(src, dst);
+ }
+
+ public static File getFileInPlugin(Plugin plugin, IPath path) {
+ try {
+ URL installURL= plugin.getBundle().getEntry(path.toString());
+ URL localURL= Platform.asLocalURL(installURL);
+ return new File(localURL.getFile());
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ public static StringBuffer read(String fileName) throws IOException {
+ return read(new FileReader(fileName));
+ }
+
+ public static StringBuffer read(Reader reader) throws IOException {
+ StringBuffer s= new StringBuffer();
+ try {
+ char[] buffer= new char[8196];
+ int chars= reader.read(buffer);
+ while (chars != -1) {
+ s.append(buffer, 0, chars);
+ chars= reader.read(buffer);
+ }
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ }
+ }
+ return s;
+ }
+
+ public static void write(String fileName, StringBuffer content) throws IOException {
+ Writer writer= new FileWriter(fileName);
+ try {
+ writer.write(content.toString());
+ } finally {
+ try {
+ writer.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/FileUtil.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/FileUtil.java
new file mode 100644
index 0000000000..ae6685fcec
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/FileUtil.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.harness.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * <code>FileUtil</code> contains methods to create and
+ * delete files and projects.
+ */
+public class FileUtil {
+
+ /**
+ * Creates a new project.
+ *
+ * @param name the project name
+ */
+ public static IProject createProject(String name) throws CoreException {
+ IWorkspace ws = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot root = ws.getRoot();
+ IProject proj = root.getProject(name);
+ if (!proj.exists())
+ proj.create(null);
+ if (!proj.isOpen())
+ proj.open(null);
+ return proj;
+ }
+
+ /**
+ * Deletes a project.
+ *
+ * @param proj the project
+ */
+ public static void deleteProject(IProject proj) throws CoreException {
+ proj.delete(true, null);
+ }
+
+ /**
+ * Creates a new file in a project.
+ *
+ * @param name the new file name
+ * @param proj the existing project
+ * @return the new file
+ */
+ public static IFile createFile(String name, IProject proj)
+ throws CoreException {
+ IFile file = proj.getFile(name);
+ if (!file.exists()) {
+ String str = " ";
+ InputStream in = new ByteArrayInputStream(str.getBytes());
+ file.create(in, true, null);
+ }
+ return file;
+ }
+
+}
+
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/ImageTests.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/ImageTests.java
new file mode 100644
index 0000000000..2c32fe5d66
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/ImageTests.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.harness.util;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @since 3.1
+ */
+public final class ImageTests {
+
+ /**
+ *
+ */
+ private ImageTests() {
+ super();
+ }
+
+ public static void assertEquals(Image i1, Image i2) {
+// ImageData data1 = i1.getImageData();
+// ImageData data2 = i2.getImageData();
+// Assert.assertTrue(Arrays.equals(data1.data, data2.data));
+ }
+
+ public static void assertNotEquals(Image i1, Image i2) {
+// ImageData data1 = i1.getImageData();
+// ImageData data2 = i2.getImageData();
+// Assert.assertFalse(Arrays.equals(data1.data, data2.data));
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/Mocks.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/Mocks.java
new file mode 100644
index 0000000000..59e7701fc6
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/Mocks.java
@@ -0,0 +1,332 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Brad Reynolds (bug 146435)
+ *******************************************************************************/
+package org.eclipse.ui.tests.harness.util;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.AssertionFailedError;
+
+/**
+ * Utility class for creating mock objects for public interfaces.
+ *
+ * @since 3.3
+ *
+ */
+public class Mocks {
+
+ public static interface EqualityComparator {
+ public boolean equals(Object o1, Object o2);
+ }
+
+ private static EqualityComparator defaultEqualityComparator = new EqualityComparator() {
+ public boolean equals(Object o1, Object o2) {
+ return o1 == null ? o2 == null : o1.equals(o2);
+ }
+ };
+
+ private static EqualityComparator indifferentEqualityComparator = new EqualityComparator() {
+ public boolean equals(Object o1, Object o2) {
+ return true;
+ }
+ };
+
+ private static interface Mock {
+ public MockInvocationHandler getMockInvocationHandler();
+ }
+
+ private static Method getMockInvocationHandlerMethod;
+
+ private static Method equalsMethod;
+
+ static {
+ try {
+ getMockInvocationHandlerMethod = Mock.class.getMethod(
+ "getMockInvocationHandler", new Class[0]);
+ equalsMethod = Object.class.getMethod("equals",
+ new Class[] { Object.class });
+ } catch (Exception e) {
+ // ignore, will lead to NullPointerExceptions later on
+ }
+ }
+
+ private static final class MockInvocationHandler implements
+ InvocationHandler {
+
+ private class MethodCall {
+ private final Method method;
+
+ private final Object[] args;
+
+ private Object returnValue = null;
+
+ public MethodCall(Method method, Object[] args) {
+ this.method = method;
+ this.args = args;
+ }
+
+ public boolean equals(Object obj) {
+ if (!(obj instanceof MethodCall)) {
+ return false;
+ }
+ MethodCall other = (MethodCall) obj;
+ if (other.method != method
+ || (other.args == null && args != null)
+ || (other.args != null && args == null)
+ || (args != null && other.args.length != args.length)) {
+ return false;
+ }
+ if (args != null) {
+ for (int i = 0; i < args.length; i++) {
+ if (!equalityComparator.equals(args[i], other.args[i])) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ public void setReturnValue(Object object) {
+ returnValue = object;
+ }
+
+ public Object getReturnValue() {
+ return returnValue;
+ }
+
+ public String toString() {
+ return method.toString();
+ }
+ }
+
+ List previousCallHistory = null;
+
+ List currentCallHistory = new ArrayList();
+
+ private final boolean ordered;
+
+ private final EqualityComparator equalityComparator;
+
+ public MockInvocationHandler(boolean ordered,
+ EqualityComparator equalityComparator) {
+ this.ordered = ordered;
+ this.equalityComparator = equalityComparator;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+ if (getMockInvocationHandlerMethod.equals(method)) {
+ return this;
+ }
+ if (equalsMethod.equals(method)) {
+ return new Boolean(proxy == args[0]);
+ }
+ MethodCall methodCall = new MethodCall(method, args);
+ if (previousCallHistory != null) {
+ // we are in replay mode
+ int indexOfMethodCall = previousCallHistory.indexOf(methodCall);
+ if (indexOfMethodCall != -1) {
+ // copy return value over to this method call
+ methodCall.setReturnValue(((MethodCall) previousCallHistory
+ .get(indexOfMethodCall)).getReturnValue());
+ } else {
+ throw new AssertionFailedError("unexpected method call: "
+ + method.getName());
+ }
+ if (ordered) {
+ if (previousCallHistory.size() <= currentCallHistory.size()) {
+ throw new AssertionFailedError("extra method call: "
+ + method.getName());
+ }
+ MethodCall previousCall = (MethodCall) previousCallHistory
+ .get(currentCallHistory.size());
+ if (!methodCall.equals(previousCall)) {
+ throw new AssertionFailedError(
+ "different method call (expected:"
+ + previousCall.method.getName()
+ + ", actual:" + method.getName() + ")");
+ }
+ }
+ }
+ currentCallHistory.add(methodCall);
+ Class returnType = method.getReturnType();
+ if (returnType.isPrimitive() && void.class != returnType) {
+ Object result = null;
+ Object returnValue = methodCall.getReturnValue();
+
+ if (returnType == boolean.class) {
+ result = (returnValue != null) ? (Boolean) returnValue
+ : Boolean.FALSE;
+ } else if (returnType == byte.class) {
+ result = (returnValue != null) ? (Byte) returnValue
+ : new Byte((byte) 0);
+ } else if (returnType == char.class) {
+ result = (returnValue != null) ? (Character) returnValue
+ : new Character((char) 0);
+ } else if (returnType == short.class) {
+ result = (returnValue != null) ? (Short) returnValue
+ : new Short((short) 0);
+ } else if (returnType == int.class) {
+ result = (returnValue != null) ? (Integer) returnValue
+ : new Integer(0);
+ } else if (returnType == long.class) {
+ result = (returnValue != null) ? (Long) returnValue
+ : new Long(0);
+ } else if (returnType == float.class) {
+ result = (returnValue != null) ? (Float) returnValue
+ : new Float(0);
+ } else if (returnType == double.class) {
+ result = (returnValue != null) ? (Double) returnValue
+ : new Double(0);
+ }
+
+ return result;
+ }
+ return methodCall.getReturnValue();
+ }
+
+ public void replay() {
+ previousCallHistory = currentCallHistory;
+ currentCallHistory = new ArrayList();
+ }
+
+ public void verify() {
+ if (previousCallHistory == null) {
+ if (currentCallHistory.size() == 0) {
+ // mock object was not used at all
+ return;
+ }
+ throw new AssertionFailedError("unexpected");
+ }
+ if (ordered) {
+ int numMissingCalls = previousCallHistory.size()
+ - currentCallHistory.size();
+ if (numMissingCalls > 0) {
+ throw new AssertionFailedError("missing method calls ("
+ + numMissingCalls + ", first is: " + previousCallHistory.get(currentCallHistory.size()) + ")");
+ }
+ for (int i = 0; i < previousCallHistory.size(); i++) {
+ if (!previousCallHistory.get(i).equals(
+ currentCallHistory.get(i))) {
+ throw new AssertionFailedError(
+ "method call did not match (" + i + " of "
+ + currentCallHistory.size() + ")");
+ }
+ }
+ } else {
+ for (Iterator it = previousCallHistory.iterator(); it.hasNext();) {
+ MethodCall methodCall = (MethodCall) it.next();
+ if (!currentCallHistory.contains(methodCall)) {
+ throw new AssertionFailedError("missing method call:"
+ + methodCall.method.getName());
+ }
+ }
+ }
+ reset();
+ }
+
+ public void reset() {
+ previousCallHistory = null;
+ currentCallHistory = new ArrayList();
+ }
+
+ public void setLastReturnValue(Object object) {
+ MethodCall methodCall = (MethodCall) currentCallHistory
+ .get(currentCallHistory.size() - 1);
+ methodCall.setReturnValue(object);
+ }
+ }
+
+ /**
+ * Creates a mock object that neither looks at the order of method calls nor
+ * at the arguments.
+ *
+ * @param interfaceType
+ * @return a mock object that checks for the order of method invocations but
+ * not for equality of method arguments
+ */
+ public static Object createRelaxedMock(Class interfaceType) {
+ return createMock(interfaceType, false, indifferentEqualityComparator);
+ }
+
+ /**
+ * Creates a mock object that does not look at the arguments, but checks
+ * that the order of calls is as expected.
+ *
+ * @param interfaceType
+ * @return a mock object that checks for the order of method invocations but
+ * not for equality of method arguments
+ */
+ public static Object createOrderedMock(Class interfaceType) {
+ return createMock(interfaceType, true, indifferentEqualityComparator);
+ }
+
+ /**
+ * creates a fussy mock object
+ *
+ * @param interfaceType
+ * @return a mock object that checks for the order of method invocations and
+ * for equality of method arguments
+ */
+ public static Object createMock(Class interfaceType) {
+ return createMock(interfaceType, true, defaultEqualityComparator);
+ }
+
+ /**
+ * creates a fussy mock object with a comparator
+ *
+ * @param interfaceType
+ * @return a mock object that checks for the order of method invocations and
+ * uses the given comparator to compare method arguments
+ */
+ public static Object createMock(Class interfaceType,
+ EqualityComparator equalityComparator) {
+ return createMock(interfaceType, true, equalityComparator);
+ }
+
+ private static Object createMock(Class interfaceType, boolean ordered,
+ EqualityComparator equalityComparator) {
+ if (!interfaceType.isInterface()) {
+ throw new IllegalArgumentException();
+ }
+ MockInvocationHandler mockInvocationHandler = new MockInvocationHandler(
+ ordered, equalityComparator);
+ Object newProxyInstance = Proxy.newProxyInstance(Mocks.class
+ .getClassLoader(), new Class[] { interfaceType, Mock.class },
+ mockInvocationHandler);
+ return newProxyInstance;
+ }
+
+ public static void startChecking(Object mock) {
+ getMockInvocationHandler(mock).replay();
+ }
+
+ public static void verify(Object mock) {
+ getMockInvocationHandler(mock).verify();
+ }
+
+ public static void reset(Object mock) {
+ getMockInvocationHandler(mock).reset();
+ }
+
+ private static MockInvocationHandler getMockInvocationHandler(Object mock) {
+ return ((Mock) mock).getMockInvocationHandler();
+ }
+
+ public static void setLastReturnValue(Object mock, Object object) {
+ getMockInvocationHandler(mock).setLastReturnValue(object);
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/PlatformUtil.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/PlatformUtil.java
new file mode 100644
index 0000000000..15309628b4
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/PlatformUtil.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.harness.util;
+
+
+/**
+ * The Platform Util class is used to test for which platform we are in
+ */
+public class PlatformUtil {
+
+ /**
+ * Determine if we are running on the Mac platform.
+ *
+ * @return true if we are runnig on the Mac platform.
+ */
+ public static boolean onMac() {
+// String platform = SWT.getPlatform();
+// return platform.equals("carbon");
+ return false;
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/TweakletCheckTest.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/TweakletCheckTest.java
new file mode 100644
index 0000000000..edb895f6f6
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/TweakletCheckTest.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.tests.harness.util;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * Tests to see if we're running with Tweaklets. If so, fail early so we don't
+ * waste an entire morning trying to figure out why all of the part tests are
+ * failing.
+ *
+ * @since 3.4
+ *
+ */
+public class TweakletCheckTest extends TestCase {
+
+ /**
+ *
+ */
+ public TweakletCheckTest() {
+ setName("test for tweaklets");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#run(junit.framework.TestResult)
+ */
+ public void run(TestResult result) {
+
+ result.startTest(this);
+ try {
+ IExtensionPoint point = Platform.getExtensionRegistry()
+
+ .getExtensionPoint("org.eclipse.ui.internalTweaklets");
+ boolean abort = point.getExtensions().length > 0;
+
+ if (abort) {
+ Error error = new Error(
+ "Tweaklets present in test setup - all test results are now suspect. Please restart the tests with the tweaklet extensions removed.");
+ result.addError(this, error);
+ result.stop();
+ }
+ } finally {
+ result.endTest(this);
+ }
+
+ }
+
+ public static Test suite() {
+ TestSuite test = new TestSuite();
+ test.addTest(new TweakletCheckTest());
+ test.addTest(new TweakletCheckTest());
+ // should not run if there are tweaklets present - the first run should
+ // aggressively take down the framework.
+ return test;
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/UITestCase.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/UITestCase.java
new file mode 100644
index 0000000000..9bcdc26718
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/harness/util/UITestCase.java
@@ -0,0 +1,333 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.harness.util;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWindowListener;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.WorkbenchException;
+
+/**
+ * <code>UITestCase</code> is a useful super class for most
+ * UI tests cases. It contains methods to create new windows
+ * and pages. It will also automatically close the test
+ * windows when the tearDown method is called.
+ */
+public abstract class UITestCase extends TestCase {
+
+ /**
+ * Returns the workbench page input to use for newly created windows.
+ *
+ * @return the page input to use for newly created windows
+ * @since 3.1
+ */
+ public static IAdaptable getPageInput() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+ class TestWindowListener implements IWindowListener {
+ private boolean enabled = true;
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public void windowActivated(IWorkbenchWindow window) {
+ // do nothing
+ }
+
+ public void windowDeactivated(IWorkbenchWindow window) {
+ // do nothing
+ }
+
+ public void windowClosed(IWorkbenchWindow window) {
+ if (enabled)
+ testWindows.remove(window);
+ }
+
+ public void windowOpened(IWorkbenchWindow window) {
+ if (enabled)
+ testWindows.add(window);
+ }
+ }
+
+ protected IWorkbench fWorkbench;
+
+ private List testWindows;
+
+ private TestWindowListener windowListener;
+
+ public UITestCase(String testName) {
+ super(testName);
+ // ErrorDialog.NO_UI = true;
+ fWorkbench = PlatformUI.getWorkbench();
+ testWindows = new ArrayList(3);
+ }
+
+ /**
+ * Fails the test due to the given throwable.
+ */
+ public static void fail(String message, Throwable e) {
+ // If the exception is a CoreException with a multistatus
+ // then print out the multistatus so we can see all the info.
+ if (e instanceof CoreException) {
+ IStatus status = ((CoreException) e).getStatus();
+ write(status, 0);
+ } else
+ e.printStackTrace();
+ fail(message + ": " + e);
+ }
+
+ private static void indent(OutputStream output, int indent) {
+ for (int i = 0; i < indent; i++)
+ try {
+ output.write("\t".getBytes());
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+
+ private static void write(IStatus status, int indent) {
+ PrintStream output = System.out;
+ indent(output, indent);
+ output.println("Severity: " + status.getSeverity());
+
+ indent(output, indent);
+ output.println("Plugin ID: " + status.getPlugin());
+
+ indent(output, indent);
+ output.println("Code: " + status.getCode());
+
+ indent(output, indent);
+ output.println("Message: " + status.getMessage());
+
+ if (status.getException() != null) {
+ indent(output, indent);
+ output.print("Exception: ");
+ status.getException().printStackTrace(output);
+ }
+
+ if (status.isMultiStatus()) {
+ IStatus[] children = status.getChildren();
+ for (int i = 0; i < children.length; i++)
+ write(children[i], indent + 1);
+ }
+ }
+
+ /**
+ * Adds a window listener to the workbench to keep track of
+ * opened test windows.
+ */
+ private void addWindowListener() {
+ windowListener = new TestWindowListener();
+ fWorkbench.addWindowListener(windowListener);
+ }
+
+ /**
+ * Removes the listener added by <code>addWindowListener</code>.
+ */
+ private void removeWindowListener() {
+ if (windowListener != null) {
+ fWorkbench.removeWindowListener(windowListener);
+ }
+ }
+
+ /**
+ * Outputs a trace message to the trace output device, if enabled.
+ * By default, trace messages are sent to <code>System.out</code>.
+ *
+ * @param msg the trace message
+ */
+ protected void trace(String msg) {
+ System.err.println(msg);
+ }
+
+ /**
+ * Simple implementation of setUp. Subclasses are prevented
+ * from overriding this method to maintain logging consistency.
+ * doSetUp() should be overriden instead.
+ */
+ protected final void setUp() throws Exception {
+ super.setUp();
+ trace("----- " + this.getName()); //$NON-NLS-1$
+ trace(this.getName() + ": setUp..."); //$NON-NLS-1$
+ addWindowListener();
+ doSetUp();
+
+ }
+
+ /**
+ * Sets up the fixture, for example, open a network connection.
+ * This method is called before a test is executed.
+ * The default implementation does nothing.
+ * Subclasses may extend.
+ */
+ protected void doSetUp() throws Exception {
+ // do nothing.
+ }
+
+ /**
+ * Simple implementation of tearDown. Subclasses are prevented
+ * from overriding this method to maintain logging consistency.
+ * doTearDown() should be overriden instead.
+ */
+ protected final void tearDown() throws Exception {
+ super.tearDown();
+ trace(this.getName() + ": tearDown...\n"); //$NON-NLS-1$
+ removeWindowListener();
+ doTearDown();
+ }
+
+ /**
+ * Tears down the fixture, for example, close a network connection.
+ * This method is called after a test is executed.
+ * The default implementation closes all test windows, processing events both before
+ * and after doing so.
+ * Subclasses may extend.
+ */
+ protected void doTearDown() throws Exception {
+ processEvents();
+ closeAllTestWindows();
+ processEvents();
+ }
+
+ protected static void processEvents() {
+ Display display = PlatformUI.getWorkbench().getDisplay();
+ if (display != null)
+ while (display.readAndDispatch())
+ ;
+ }
+
+ /**
+ * Open a test window with the empty perspective.
+ */
+ public IWorkbenchWindow openTestWindow() {
+ return openTestWindow(EmptyPerspective.PERSP_ID);
+ }
+
+ /**
+ * Open a test window with the provided perspective.
+ */
+ public IWorkbenchWindow openTestWindow(String perspectiveId) {
+ try {
+ IWorkbenchWindow window = fWorkbench.openWorkbenchWindow(
+ perspectiveId, getPageInput());
+ waitOnShell(window.getShell());
+ return window;
+ } catch (WorkbenchException e) {
+ fail();
+ return null;
+ }
+ }
+
+ /**
+ * Try and process events until the new shell is the active shell. This may
+ * never happen, so time out after a suitable period.
+ *
+ * @param shell
+ * the shell to wait on
+ * @since 3.2
+ */
+ private void waitOnShell(Shell shell) {
+
+ processEvents();
+// long endTime = System.currentTimeMillis() + 5000;
+//
+// while (shell.getDisplay().getActiveShell() != shell
+// && System.currentTimeMillis() < endTime) {
+// processEvents();
+// }
+ }
+
+ /**
+ * Close all test windows.
+ */
+ public void closeAllTestWindows() {
+ Iterator iter = new ArrayList(testWindows).iterator();
+ while (iter.hasNext()) {
+ IWorkbenchWindow win = (IWorkbenchWindow) iter.next();
+ win.close();
+ }
+ testWindows.clear();
+ }
+
+ /**
+ * Open a test page with the empty perspective in a window.
+ */
+ public IWorkbenchPage openTestPage(IWorkbenchWindow win) {
+ IWorkbenchPage[] pages = openTestPage(win, 1);
+ if (pages != null)
+ return pages[0];
+ else
+ return null;
+ }
+
+ /**
+ * Open "n" test pages with the empty perspective in a window.
+ */
+ public IWorkbenchPage[] openTestPage(IWorkbenchWindow win, int pageTotal) {
+ try {
+ IWorkbenchPage[] pages = new IWorkbenchPage[pageTotal];
+ IAdaptable input = getPageInput();
+
+ for (int i = 0; i < pageTotal; i++) {
+ pages[i] = win.openPage(EmptyPerspective.PERSP_ID, input);
+ }
+ return pages;
+ } catch (WorkbenchException e) {
+ fail();
+ return null;
+ }
+ }
+
+ /**
+ * Close all pages within a window.
+ */
+ public void closeAllPages(IWorkbenchWindow window) {
+ IWorkbenchPage[] pages = window.getPages();
+ for (int i = 0; i < pages.length; i++)
+ pages[i].close();
+ }
+
+ /**
+ * Set whether the window listener will manage opening and closing of created windows.
+ */
+ protected void manageWindows(boolean manage) {
+ windowListener.setEnabled(manage);
+ }
+
+ /**
+ * Returns the workbench.
+ *
+ * @return the workbench
+ * @since 3.1
+ */
+ protected IWorkbench getWorkbench() {
+ return fWorkbench;
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/AccessibilityTestPass.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/AccessibilityTestPass.java
new file mode 100644
index 0000000000..ef9e0309db
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/AccessibilityTestPass.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.internal.util;
+
+import java.util.ArrayList;
+
+public class AccessibilityTestPass implements IDialogTestPass {
+ private static final int CHECKLIST_SIZE = 5;
+
+ /**
+ * @see IDialogTestPass#title()
+ */
+ public String title() {
+ return "Test Pass: Accessibility";
+ }
+
+ /**
+ * @see IDialogTestPass#description()
+ */
+ public String description() {
+ return "Verify the accessibility of the dialogs.";
+ }
+
+ /**
+ * @see IDialogTestPass#label()
+ */
+ public String label() {
+ return "&Accessibility";
+ }
+
+ /**
+ * @see IDialogTestPass#checkListTexts()
+ */
+ public ArrayList checkListTexts() {
+ ArrayList list = new ArrayList(CHECKLIST_SIZE);
+ list.add("&1) all widgets are accessible by tabbing.");
+ list.add("&2) forwards and backwards tabbing is in a logical order");
+ list
+ .add("&3) all the widgets with labels have an appropriate mnemonic.");
+ list.add("&4) there are no duplicate mnemonics.");
+ list.add("&5) selectable widgets can be selected using the spacebar.");
+ return list;
+ }
+
+ /**
+ * @see IDialogTestPass#failureTexts()
+ * Size of the return array must be the same size as the checkListTexts'
+ * ArrayList.
+ */
+ public String[] failureTexts() {
+ String[] failureText = new String[CHECKLIST_SIZE];
+ failureText[0] = "Some widgets aren't accessible by tabbing.";
+ failureText[1] = "Tabbing order is illogical.";
+ failureText[2] = "Missing or inappropriate mnemonics.";
+ failureText[3] = "Duplicate mnemonics.";
+ failureText[4] = "Some widgets cannot be selected using the spacebar.";
+ return failureText;
+ }
+
+ /**
+ * @see IDialogTestPass#queryText()
+ */
+ public String queryText() {
+ return "Is the accessibility of the dialog acceptable?";
+ }
+
+ /**
+ * @see IDialogTestPass#getID()
+ */
+ public int getID() {
+ return VerifyDialog.TEST_ACCESS;
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/FailureDialog.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/FailureDialog.java
new file mode 100644
index 0000000000..d9672b8cb3
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/FailureDialog.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.internal.util;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/*
+ * A dialog for collecting notes from the tester regarding
+ * the failure of a test.
+ */
+public class FailureDialog extends Dialog {
+ private Text _text;
+
+ private String _log;
+
+ private int SIZING_TEXT_WIDTH = 400;
+
+ private int SIZING_TEXT_HEIGHT = 200;
+
+ /**
+ * Constructor for FailureDialog
+ */
+ public FailureDialog(Shell parentShell) {
+ super(parentShell);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Window.
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Dialog Test Failed");
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, "&OK", true);
+ createButton(parent, IDialogConstants.CANCEL_ID,
+ IDialogConstants.get().CANCEL_LABEL, false);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected Control createDialogArea(Composite parent) {
+ // page group
+ Composite composite = (Composite) super.createDialogArea(parent);
+ composite.setSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+ Label label = new Label(composite, SWT.WRAP);
+ label.setText("&Enter a note regarding the failure:");
+
+ _text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL
+ | SWT.V_SCROLL);
+ _text.setFont(JFaceResources.getFontRegistry().get(
+ JFaceResources.TEXT_FONT));
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.widthHint = SIZING_TEXT_WIDTH;
+ data.heightHint = SIZING_TEXT_HEIGHT;
+ _text.setLayoutData(data);
+
+ return composite;
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void okPressed() {
+ _log = _text.getText();
+ super.okPressed();
+ }
+
+ /*
+ * @return String the text contained in the input area of
+ * the dialog.
+ */
+ String getText() {
+ if (_log == null) {
+ return "Empty entry.";
+ } else {
+ return _log;
+ }
+ }
+
+ /*
+ * Sets the text of the input area. This should only be
+ * called to set the initial text so only call before invoking
+ * open().
+ */
+ void setText(String text) {
+ _text.setText(text);
+ }
+
+ /*
+ * Returns a string representation of this class which
+ * the text contained in the input area of the dialog.
+ */
+ public String toString() {
+ return getText();
+ }
+}
+
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/FocusTestPass.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/FocusTestPass.java
new file mode 100644
index 0000000000..d0808e4bc4
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/FocusTestPass.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.internal.util;
+
+import java.util.ArrayList;
+
+/*
+ * This test pass verifies the initial focus of a dialog
+ * when it is given focus.
+ */
+public class FocusTestPass implements IDialogTestPass {
+ private static final int CHECKLIST_SIZE = 1;
+
+ /**
+ * @see IDialogTestPass#title()
+ */
+ public String title() {
+ return "Test Pass: Initial Focus";
+ }
+
+ /**
+ * @see IDialogTestPass#description()
+ */
+ public String description() {
+ return "Verify the initial focus of the dialogs.";
+ }
+
+ /**
+ * @see IDialogTestPass#label()
+ */
+ public String label() {
+ return "&Initial Focus";
+ }
+
+ /**
+ * @see IDialogTestPass#checkListTexts()
+ */
+ public ArrayList checkListTexts() {
+ ArrayList list = new ArrayList(CHECKLIST_SIZE);
+ list.add("&1) the initial focus is appropriate.");
+ return list;
+ }
+
+ /**
+ * @see IDialogTestPass#failureTexts()
+ * Size of the return array must be the same size as the checkListTexts'
+ * ArrayList.
+ */
+ public String[] failureTexts() {
+ String[] failureText = new String[CHECKLIST_SIZE];
+ failureText[0] = "The initial focus is inappropriate.";
+ return failureText;
+ }
+
+ /**
+ * @see IDialogTestPass#queryText()
+ */
+ public String queryText() {
+ return "Is the initial focus of the dialog correct?";
+ }
+
+ /**
+ * @see IDialogTestPass#getID()
+ */
+ public int getID() {
+ return VerifyDialog.TEST_FOCUS;
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/IDialogTestPass.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/IDialogTestPass.java
new file mode 100644
index 0000000000..a8c6bef6b5
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/IDialogTestPass.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.internal.util;
+
+import java.util.ArrayList;
+
+/*
+ * Interface to describe a visual test pass for a dialog test.
+ */
+public interface IDialogTestPass {
+ /*
+ * @return String The title of the test pass.
+ */
+ public String title();
+
+ /*
+ * @return String The description of the test pass.
+ */
+ public String description();
+
+ /*
+ * @return String The label of the test pass to be used
+ * in a selection list. The return includes an '&'
+ * if a mnemonic is desired.
+ */
+ public String label();
+
+ /*
+ * @return ArrayList A list of items to appear in a checklist.
+ * The items in the list must be Strings and should include an
+ * '&' if a mnemonic is desired.
+ */
+ public ArrayList checkListTexts();
+
+ /*
+ * @return String[] Associated failure messages that correspond
+ * to the checklist items. The size of this array should be the
+ * same size as the checklist.
+ */
+ public String[] failureTexts();
+
+ /*
+ * @return String The test that corresponds to the test pass to
+ * which the tester will respond with a 'yes' or 'no'.
+ */
+ public String queryText();
+
+ /*
+ * @return int A unique number that identifies the test pass.
+ */
+ public int getID();
+}
+
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/SizingTestPass.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/SizingTestPass.java
new file mode 100644
index 0000000000..79d866b8cc
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/SizingTestPass.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.internal.util;
+
+import java.util.ArrayList;
+
+/*
+ * This test pass verifies visually the sizing of the dialog and its
+ * widgets.
+ */
+class SizingTestPass implements IDialogTestPass {
+ private static final int CHECKLIST_SIZE = 5;
+
+ /**
+ * @see IDialogTestPass#title()
+ */
+ public String title() {
+ return "Test Pass: Sizing and Display";
+ }
+
+ /**
+ * @see IDialogTestPass#description()
+ */
+ public String description() {
+ return "Verify the sizing and display of the dialogs and widgets.";
+ }
+
+ /**
+ * @see IDialogTestPass#label()
+ */
+ public String label() {
+ return "&Sizing and Display";
+ }
+
+ /**
+ * @see IDialogTestPass#checkListTexts()
+ */
+ public ArrayList checkListTexts() {
+ ArrayList list = new ArrayList(CHECKLIST_SIZE);
+ list.add("&1) the correct dialog displays.");
+ list
+ .add("&2) the dialog is an appropriate size for the required resolution (1024x768).");
+ list.add("&3) the texts are correct and not cut off.");
+ list.add("&4) all strings have been externalized properly.");
+ list.add("&5) all the widgets are viewable and not cut off.");
+ return list;
+ }
+
+ /**
+ * @see IDialogTestPass#failureTexts()
+ * Size of the return array must be the same size as the checkListTexts'
+ * ArrayList.
+ */
+ public String[] failureTexts() {
+ String[] failureText = new String[CHECKLIST_SIZE];
+ failureText[0] = "The wrong dialog displayed.";
+ failureText[1] = "The dialog is too large for the required resolution.";
+ failureText[2] = "Text labels are wrong or cut off.";
+ failureText[3] = "Some strings have not been externalized properly.";
+ failureText[4] = "Some widgets are cut off.";
+ return failureText;
+ }
+
+ /**
+ * @see IDialogTestPass#queryText()
+ */
+ public String queryText() {
+ return "Is the sizing and display of the dialog correct?";
+ }
+
+ /**
+ * @see IDialogTestPass#getID()
+ */
+ public int getID() {
+ return VerifyDialog.TEST_SIZING;
+ }
+}
diff --git a/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/VerifyDialog.java b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/VerifyDialog.java
new file mode 100644
index 0000000000..00110e7978
--- /dev/null
+++ b/tests/org.eclipse.rap.ui.tests.harness/src/org/eclipse/ui/tests/internal/util/VerifyDialog.java
@@ -0,0 +1,329 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.tests.internal.util;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.ShellAdapter;
+import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * This dialog is intended to verify a dialogs in a testing
+ * environment. The tester can test for sizing, initial focus,
+ * or accessibility.
+ */
+public class VerifyDialog extends TitleAreaDialog {
+ private int SIZING_WIDTH = 400;
+
+ private static int TEST_TYPE;
+
+ public static final int TEST_SIZING = 0;
+
+ public static final int TEST_FOCUS = 1;
+
+ public static final int TEST_ACCESS = 2;
+
+ private IDialogTestPass _dialogTests[] = new IDialogTestPass[3];
+
+ private Dialog _testDialog; //the dialog to test
+
+ private Point _testDialogSize;
+
+ private Label _queryLabel;
+
+ private Button _yesButton;
+
+ private Button _checkList[];
+
+ private String _failureText;
+
+ /*
+ * Create an instance of the verification dialog.
+ */
+ public VerifyDialog(Shell parent) {
+ super(parent);
+ if (!(TEST_TYPE <= 2) && !(TEST_TYPE >= 0)) {
+ TEST_TYPE = TEST_SIZING;
+ }
+ _failureText = "";
+ _dialogTests[0] = new SizingTestPass();
+ _dialogTests[1] = new FocusTestPass();
+ _dialogTests[2] = new AccessibilityTestPass();
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Window.
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Dialog Verification");
+ setShellStyle(SWT.NONE);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ _yesButton = createButton(parent, IDialogConstants.YES_ID,
+ IDialogConstants.get().YES_LABEL, true);
+ createButton(parent, IDialogConstants.NO_ID,
+ IDialogConstants.get().NO_LABEL, false);
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected void buttonPressed(int buttonId) {
+ if (IDialogConstants.YES_ID == buttonId) {
+ setReturnCode(IDialogConstants.YES_ID);
+ if (_testDialog.getShell() != null) {
+ _testDialog.close();
+ }
+ close();
+ } else if (IDialogConstants.NO_ID == buttonId) {
+ handleFailure();
+ }
+ }
+
+ /* (non-Javadoc)
+ * Method declared on Dialog.
+ */
+ protected Control createDialogArea(Composite parent) {
+ // top level composite
+ Composite parentComposite = (Composite) super.createDialogArea(parent);
+
+ // create a composite with standard margins and spacing
+ Composite composite = new Composite(parentComposite, SWT.NONE);
+ composite.setSize(SIZING_WIDTH, SWT.DEFAULT);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ createTestSelectionGroup(composite);
+ createCheckListGroup(composite);
+
+ _queryLabel = new Label(composite, SWT.NONE);
+ _queryLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ initializeTest();
+ return composite;
+ }
+
+ /*
+ * Group for selecting type of test.
+ */
+ private void createTestSelectionGroup(Composite parent) {
+ Group group = new Group(parent, SWT.SHADOW_NONE);
+ group.setText("Testing:");
+ group.setLayout(new GridLayout());
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ group.setLayoutData(data);
+
+ for (int i = 0; i < _dialogTests.length; i++) {
+ Button radio = new Button(group, SWT.RADIO);
+ radio.setText(_dialogTests[i].label());
+ final int testID = _dialogTests[i].getID();
+ radio.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ TEST_TYPE = testID;
+ initializeTest();
+ _yesButton.setEnabled(true);
+ }
+ });
+ if (TEST_TYPE == _dialogTests[i].getID()) {
+ radio.setSelection(true);
+ }
+ }
+ }
+
+ /*
+ * Initializes the checklist with empty checks.
+ */
+ private void createCheckListGroup(Composite parent) {
+ Group group = new Group(parent, SWT.SHADOW_NONE);
+ group.setText("Verify that:");
+ group.setLayout(new GridLayout());
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ group.setLayoutData(data);
+
+ int checkListSize = 0;
+ for (int i = 0; i < _dialogTests.length; i++) {
+ int size = _dialogTests[i].checkListTexts().size();
+ if (size > checkListSize) {
+ checkListSize = size;
+ }
+ }
+ _checkList = new Button[checkListSize];
+ SelectionAdapter selectionAdapter = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ checkYesEnable();
+ }
+ };
+ for (int i = 0; i < checkListSize; i++) {
+ _checkList[i] = new Button(group, SWT.CHECK);
+ _checkList[i].addSelectionListener(selectionAdapter);
+ data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ data.grabExcessHorizontalSpace = true;
+ _checkList[i].setLayoutData(data);
+ }
+ }
+
+ /*
+ * Disables the yes button if any of the items in the checklist
+ * are unchecked. Enables the yes button otherwise.
+ */
+ private void checkYesEnable() {
+ boolean enable = true;
+ for (int i = 0; i < _checkList.length; i++) {
+ if (!_checkList[i].getSelection()) {
+ enable = false;
+ }
+ }
+ _yesButton.setEnabled(enable);
+ }
+
+ /*
+ * Initializes the checklist, banner texts, and query label
+ */
+ private void initializeTest() {
+ IDialogTestPass test = _dialogTests[TEST_TYPE];
+ setTitle(test.title());
+ setMessage(test.description());
+ Iterator iterator = test.checkListTexts().iterator();
+ for (int i = 0; i < _checkList.length; i++) {
+ if (iterator.hasNext()) {
+ _checkList[i].setText(iterator.next().toString());
+ _checkList[i].setVisible(true);
+// _checkList[i].update();
+ } else {
+ _checkList[i].setVisible(false);
+// _checkList[i].update();
+ }
+ _checkList[i].setSelection(true);
+ }
+ _queryLabel.setText(test.queryText());
+ }
+
+ public String getFailureText() {
+ return _failureText;
+ }
+
+ /*
+ * Can't open the verification dialog without a specified
+ * test dialog, this simply returns a failure and prevents
+ * opening. Should use open(Dialog) instead.
+ *
+ */
+ public int open() {
+ _failureText = "Testing dialog is required, use VerifyDialog::open(Dialog)";
+ return IDialogConstants.NO_ID;
+ }
+
+ /*
+ * Opens the verification dialog to test the specified dialog.
+ */
+ public int open(Dialog testDialog) {
+ if (getShell() == null) {
+ create();
+ }
+ getShell().setLocation(0, 0);
+ getShell().setSize(Math.max(SIZING_WIDTH, getShell().getSize().x),
+ getShell().getSize().y);
+ _testDialog = testDialog;
+ if (_testDialog.getShell() == null) {
+ _testDialog.create();
+ }
+ _testDialogSize = _testDialog.getShell().getSize();
+ openNewTestDialog();
+
+ return super.open();
+ }
+
+ /*
+ * Opens the dialog to be verified.
+ */
+ private void openNewTestDialog() {
+ if (_testDialog.getShell() == null) {
+ _testDialog.create();
+ }
+ _testDialog.setBlockOnOpen(false);
+ _testDialog.getShell().setLocation(getShell().getSize().x + 1, 0);
+ _testDialog.getShell().setSize(_testDialogSize);
+ _testDialog.getShell().addShellListener(new ShellAdapter() {
+ public void shellClosed(ShellEvent e) {
+ e.doit = false;
+ }
+
+ });
+ _testDialog.open();
+ }
+
+ /*
+ * The test dialog failed, open the failure dialog.
+ */
+ private void handleFailure() {
+ IDialogTestPass test = _dialogTests[TEST_TYPE];
+ StringBuffer text = new StringBuffer();
+ String label = test.label();
+ label = label.substring(0, label.indexOf("&"))
+ + label.substring(label.indexOf("&") + 1);
+// text.append(label).append(" failed on the ").append(SWT.getPlatform())
+// .append(" platform:\n");
+ text.append(label).append(" failed on the ").append( "RAP" )
+ .append(" platform:\n");
+
+ String failureMessages[] = test.failureTexts();
+ for (int i = 0; i < test.checkListTexts().size(); i++) {
+ if (!_checkList[i].getSelection()) {
+ text.append("- ").append(failureMessages[i]).append("\n");
+ }
+ }
+ FailureDialog dialog = new FailureDialog(getShell());
+ dialog.create();
+ dialog.setText(text.toString());
+ if (dialog.open() == IDialogConstants.OK_ID) {
+ _failureText = dialog.toString();
+ setReturnCode(IDialogConstants.NO_ID);
+ if (_testDialog.getShell() != null) {
+ _testDialog.close();
+ }
+ close();
+ }
+ }
+
+ /*
+ * In case the shell was closed by a means other than
+ * the NO button.
+ */
+ protected void handleShellCloseEvent() {
+ handleFailure();
+ }
+}
+

Back to the top