diff options
author | Andrew Overholt | 2011-01-13 17:33:57 +0000 |
---|---|---|
committer | Andrew Overholt | 2011-01-13 17:33:57 +0000 |
commit | fdd834118cec0f95e1a26a242ab5d7bc8c0b09bc (patch) | |
tree | 820623530babaec144474281915f8c0f3a35b077 /changelog/org.eclipse.linuxtools.changelog.ui.tests | |
parent | 937ee3a53a8f11710f4cce0408952e10e4e39325 (diff) | |
download | org.eclipse.linuxtools-fdd834118cec0f95e1a26a242ab5d7bc8c0b09bc.tar.gz org.eclipse.linuxtools-fdd834118cec0f95e1a26a242ab5d7bc8c0b09bc.tar.xz org.eclipse.linuxtools-fdd834118cec0f95e1a26a242ab5d7bc8c0b09bc.zip |
Re-name directory to match refactored bundle ID.
Diffstat (limited to 'changelog/org.eclipse.linuxtools.changelog.ui.tests')
22 files changed, 2255 insertions, 0 deletions
diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/.classpath b/changelog/org.eclipse.linuxtools.changelog.ui.tests/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/.project b/changelog/org.eclipse.linuxtools.changelog.ui.tests/.project new file mode 100644 index 0000000000..3838c2cb95 --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.linuxtools.changelog.ui.tests</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/changelog/org.eclipse.linuxtools.changelog.ui.tests/.settings/org.eclipse.jdt.core.prefs b/changelog/org.eclipse.linuxtools.changelog.ui.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..b7f61f2060 --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Tue Dec 14 15:44:56 EST 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/ChangeLog b/changelog/org.eclipse.linuxtools.changelog.ui.tests/ChangeLog new file mode 100644 index 0000000000..57a6aeee35 --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/ChangeLog @@ -0,0 +1,48 @@ +2011-01-13 Andrew Overholt <overholt@redhat.com> + + * src/: Re-naming directories to account for refactoring. + +2011-01-10 Severin Gehwolf <sgehwolf@redhat.com> + + * .project: Rename plug-in to org.eclipse.linuxtools.changelog.ui.tests. + +2010-12-20 Severin Gehwolf <sgehwolf@redhat.com> + + * META-INF/MANIFEST.MF: Add Java 5 to list of execution environments. + * javaCompiler...args: Removed. + +2010-12-20 Severin Gehwolf <sgehwolf@redhat.com> + + * build.xml: New file. Added for build support with upstream eclipse. + * javaCompiler...args: New file. + +2010-12-14 Severin Gehwolf <sgehwolf@redhat.com> + + * src/org/eclipse/linuxtools/changelog/tests/ui/swtbot/FormatChangeLogSWTBotTest.java: Refactored test to not use + SVN project. + +2010-12-14 Severin Gehwolf <sgehwolf@redhat.com> + + Added org.eclipse.linuxtools.changelog.tests.ui plug-in. + * .classpath: New file. + * .project: New file. + * .settings/org.eclipse.jdt.core.prefs: New file. + * build.properties: New file. + * META-INF/MANIFEST.MF: New file. + * screenshots/canFormatChangeLogFile\(org.eclipse.linuxtools.changelog.tests.ui.swtbot.FormatChangeLogSWTBotTest\).jpeg: New file. + * screenshots/canPrepareChangeLogFromSVNHistory\(org.eclipse.linuxtools.changelog.tests.ui.swtbot.FormatChangeLogSWTBotTest\).jpeg: New file. + * src/log4j.xml: New file. + * src/org/eclipse/linuxtools/changelog/tests/ui/utils/ContextMenuHelper.java: New file. + * src/org/eclipse/linuxtools/changelog/tests/ui/utils/ProjectExplorer.java: New file. + * src/org/eclipse/linuxtools/changelog/tests/ui/utils/ProjectExplorerTreeItemAppearsCondition.java: New file. + * src/org/eclipse/linuxtools/changelog/tests/ui/utils/SVNProject.java: New file. + * src/org/eclipse/linuxtools/changelog/tests/ui/utils/SVNProjectCreatedCondition.java: New file. + * src/org/eclipse/linuxtools/changelog/tests/ui/utils/SVNReporsitoriesView.java: New file. + * src/org/eclipse/linuxtools/changelog/tests/ui/utils/TableAppearsCondition.java: New file. + * src/org/eclipse/linuxtools/changelog/tests/ui/utils/TreeItemAppearsCondition.java: New file. + * src/org/eclipse/linuxtools/changelog/tests/ui/swtbot/AddChangelogEntrySWTBotTest.java: New file. + * src/org/eclipse/linuxtools/changelog/tests/ui/swtbot/AllSWTBotTests.java: New file. + * src/org/eclipse/linuxtools/changelog/tests/ui/swtbot/CreateChangeLogFromHistorySWTBotTest.java: New file. + * src/org/eclipse/linuxtools/changelog/tests/ui/swtbot/DisabledPrepareChangelogSWTBotTest.java: New file. + * src/org/eclipse/linuxtools/changelog/tests/ui/swtbot/FormatChangeLogSWTBotTest.java: New file. + * src/org/eclipse/linuxtools/changelog/tests/ui/swtbot/PrepareChangelogSWTBotTest.java: New file.
\ No newline at end of file diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/META-INF/MANIFEST.MF b/changelog/org.eclipse.linuxtools.changelog.ui.tests/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..9978372edc --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/META-INF/MANIFEST.MF @@ -0,0 +1,19 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Eclipse Linuxtools ChangeLog UI SWTBot tests +Bundle-SymbolicName: org.eclipse.linuxtools.changelog.ui.tests +Bundle-Version: 2.7.0.qualifier +Bundle-Vendor: Eclipse.org +Require-Bundle: org.eclipse.swtbot.eclipse.core, + org.eclipse.swtbot.eclipse.finder, + org.eclipse.swtbot.junit4_x, + org.hamcrest, + org.apache.log4j, + org.eclipse.swtbot.go, + org.eclipse.linuxtools.changelog.tests +Eclipse-RegisterBuddy: org.apache.log4j +Import-Package: org.eclipse.core.resources, + org.eclipse.linuxtools.changelog.tests.fixtures, + org.eclipse.jdt.core +Bundle-RequiredExecutionEnvironment: J2SE-1.5, + JavaSE-1.6 diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/build.properties b/changelog/org.eclipse.linuxtools.changelog.ui.tests/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/build.xml b/changelog/org.eclipse.linuxtools.changelog.ui.tests/build.xml new file mode 100644 index 0000000000..5b825d74ec --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/build.xml @@ -0,0 +1,377 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project name="org.eclipse.linuxtools.changelog.tests.ui" default="build.jars" basedir="."> + + <property name="p2.build.repo" value="file:${buildDirectory}/buildRepo"/> + <property name="basews" value="${ws}"/> + <property name="baseos" value="${os}"/> + <property name="basearch" value="${arch}"/> + <property name="basenl" value="${nl}"/> + <property name="bundleId" value="org.eclipse.linuxtools.changelog.tests.ui"/> + <property name="bundleVersion" value="2.7.0.201012201019"/> + <property name="p2.publishonerror" value="false"/> + + <!-- Compiler settings. --> + <property name="javacFailOnError" value="false"/> + <property name="javacDebugInfo" value="on"/> + <property name="javacVerbose" value="false"/> + <property name="logExtension" value=".log"/> + <property name="compilerArg" value=""/> + <property name="compilation.prereq.log" value="${buildDirectory}/prereqErrors.log"/> + <property name="javacSource" value="1.3"/> + <property name="javacTarget" value="1.2"/> + <condition property="dir_bootclasspath" value="${java.home}/../Classes"> + <os family="mac"/> + </condition> + <property name="dir_bootclasspath" value="${java.home}/lib"/> + <path id="path_bootclasspath"> + <fileset dir="${dir_bootclasspath}"> + <include name="*.jar"/> + </fileset> + </path> + <property name="bootclasspath" refid="path_bootclasspath"/> + <condition property="bundleBootClasspath" value="${JavaSE-1.6}" > + <isset property="JavaSE-1.6"/> + </condition> + <condition property="bundleJavacSource" value="1.6" > + <isset property="JavaSE-1.6"/> + </condition> + <condition property="bundleJavacTarget" value="1.6" > + <isset property="JavaSE-1.6"/> + </condition> + <property name="bundleJavacSource" value="${javacSource}"/> + <property name="bundleJavacTarget" value="${javacTarget}"/> + <property name="bundleBootClasspath" value="${bootclasspath}"/> + + <target name="init" depends="properties"> + <condition property="pluginTemp" value="${buildTempFolder}/plugins" > + <isset property="buildTempFolder"/> + </condition> + <property name="pluginTemp" value="${basedir}"/> + <condition property="build.result.folder" value="${pluginTemp}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019" > + <isset property="buildTempFolder"/> + </condition> + <property name="build.result.folder" value="${basedir}"/> + <property name="temp.folder" value="${basedir}/temp.folder"/> + <property name="plugin.destination" value="${basedir}"/> + <condition property="p2.publish.parts" value="true" > + <istrue value="${p2.gathering}"/> + </condition> + <property name="compilation.problem.marker" value="${build.result.folder}/compilation.problem"/> + <condition property="compilation.problem.marker.exists" value="true" > + <and> + <available file="${compilation.problem.marker}"/> + <isfalse value="${p2.publishonerror}"/> + </and> + </condition> + </target> + + <target name="properties" if="eclipse.running"> + <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> + + </target> + + <target name="build.update.jar" depends="init" description="Build the plug-in: org.eclipse.linuxtools.changelog.tests.ui for an update site."> + <delete dir="${temp.folder}"/> + <mkdir dir="${temp.folder}"/> + <antcall target="build.jars"/> + <antcall target="gather.bin.parts"> + <param name="destination.temp.folder" value="${temp.folder}/"/> + </antcall> + <jar destfile="${plugin.destination}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019.jar" basedir="${temp.folder}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019" filesetmanifest="merge"/> + <delete dir="${temp.folder}"/> + </target> + + <target name="@dot" depends="init" unless="@dot" description="Create jar: org.eclipse.linuxtools.changelog.tests.ui @dot."> + <delete dir="${build.result.folder}/@dot"/> + <mkdir dir="${build.result.folder}/@dot"/> + <path id="@dot.classpath"> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.resources_3.6.0.R36x_v20100825-0600.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ant.core_3.2.200.v20100427.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.variables_3.2.400.v20100505.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.runtime_3.6.0.v20100505.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.osgi_3.6.1.R36x_v20100806.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.equinox.common_3.6.0.v20100503.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.jobs_3.5.1.R36x_v20100824.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.runtime.compatibility.registry_3.3.0.v20100520/runtime_registry_compatibility.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.runtime.compatibility.registry_3.3.0.v20100520"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.equinox.registry_3.5.0.v20100503.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.equinox.preferences_3.3.0.v20100503.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.contenttype_3.4.100.v20100505-1235.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.runtime.compatibility.auth_3.2.200.v20100517.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.equinox.app_1.3.1.R36x_v20100803.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.osgi.services_3.2.100.v20100503.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/javax.servlet_2.5.0.v200806031605.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.expressions_3.4.200.v20100505.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.filesystem_1.3.1.R36x_v20100727-0745.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.filesystem.linux.x86_64_1.2.0.v20100505-1235.jar"/> + <pathelement path="../org.eclipse.linuxtools.changelog.tests/bin/"/> + <pathelement path="${build.result.folder}/../org.eclipse.linuxtools.changelog.tests_2.7.0.201012201019/bin/"/> + <pathelement path="${build.result.folder}/../org.eclipse.linuxtools.changelog.tests/@dot"/> + <pathelement path="${build.result.folder}/../org.eclipse.linuxtools.changelog.tests_2.7.0.201012201019/@dot"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/cdt/eclipse/plugins/org.eclipse.cdt.core_5.2.1.201009241320.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/cdt/eclipse/plugins/org.eclipse.cdt.core.linux_5.2.0.201009241320.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/cdt/eclipse/plugins/org.eclipse.cdt.core.linux.x86_64_5.2.0.201009241320.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/com.ibm.icu_4.2.1.v20100412.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.text_3.5.0.v20100601-1300.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.commands_3.6.0.I20100512-1500.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.filebuffers_3.5.100.v20100520-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ltk.core.refactoring_3.5.100.v20100526-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/cdt/eclipse/plugins/org.eclipse.cdt.managedbuilder.core_7.0.1.201009241320.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ui_3.6.1.M20100826-1330.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.swt_3.6.1.v3655c.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.swt.gtk.linux.x86_64_3.6.1.v3655c.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.jface_3.6.1.M20100825-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ui.workbench_3.6.1.M20100826-1330.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ui.workbench.compatibility_3.2.100.I20100511-0800/compatibility.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ui.workbench.compatibility_3.2.100.I20100511-0800/e4-workbench.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ui.workbench.compatibility_3.2.100.I20100511-0800"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.help_3.5.0.v20100524.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.jface.databinding_1.4.0.I20100601-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.databinding.observable_1.3.0.I20100601-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.databinding.property_1.3.0.I20100601-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.databinding_1.3.100.I20100601-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/cdt/eclipse/plugins/org.eclipse.cdt.make.core_7.0.0.201009241320.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.compare_3.5.100.I20100526-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.jface.text_3.6.1.r361_v20100825-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ui.ide_3.6.1.M20100825-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ui.views_3.5.0.I20100527-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ui.forms_3.5.2.r36_v20100702.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.equinox.p2.engine_2.0.0.v20100606.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.equinox.p2.core_2.0.2.R36x_v20100804.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.equinox.p2.metadata_2.0.0.v20100601.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.equinox.p2.repository_2.0.1.R36x_v20100823.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.equinox.security_1.0.200.v20100503.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ecf.filetransfer_4.0.0.201012132126.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ecf_3.1.0.201012132126.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ecf.ssl_1.0.100.201012132126.jar"/> + <pathelement path="../../../../home/sgehwolf/.eclipse/793567567/plugins/org.eclipse.equinox.concurrent_1.0.1.R35x_v20100209.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ecf.identity_3.1.0.201012132126.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ecf.provider.filetransfer_3.1.0.201012132126.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ecf.provider.filetransfer.ssl_1.0.0.201012132126.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.net_1.2.100.I20100511-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.core.net.linux.x86_64_1.1.0.I20100505-1245.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.equinox.p2.metadata.repository_1.1.0.v20100513.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ui.workbench.texteditor_3.6.1.r361_v20100714-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.compare.core_3.5.100.I20100526-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ui.editors_3.6.1.r361_v20100825-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/jdt/plugins/org.eclipse.jdt.core_3.6.1.v_A68_R36x.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/jdt/plugins/org.eclipse.jdt.compiler.apt_1.0.300.v20100513-0845.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/jdt/plugins/org.eclipse.jdt.compiler.tool_1.0.100.v_A68_R36x.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.team.core_3.5.100.R36x_v20100825-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/jdt/plugins/org.eclipse.jdt.launching_3.5.100.v20100526.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.debug.core_3.6.0.v20100519.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/jdt/plugins/org.eclipse.jdt.debug_3.6.1.v20100715_r361/jdi.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/jdt/plugins/org.eclipse.jdt.debug_3.6.1.v20100715_r361/jdimodel.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/jdt/plugins/org.eclipse.jdt.debug_3.6.1.v20100715_r361/tools.jar"/> + <pathelement path="../org.eclipse.linuxtools.changelog.core/bin/"/> + <pathelement path="../org.eclipse.linuxtools.changelog.core/@dot"/> + <pathelement path="../org.eclipse.linuxtools.changelog.javaparser/bin/"/> + <pathelement path="../org.eclipse.linuxtools.changelog.javaparser/@dot"/> + <pathelement path="../org.eclipse.linuxtools.changelog.cparser/bin"/> + <pathelement path="../org.eclipse.linuxtools.changelog.cparser/@dot"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.team.ui_3.5.101.R36x_v20100825-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ui.navigator_3.5.0.I20100601-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/cdt/eclipse/plugins/org.eclipse.cdt.ui_5.2.1.201009241320.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.search_3.6.0.v20100520-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ltk.ui.refactoring_3.5.0.v20100526-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ui.console_3.5.0.v20100526.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ui.navigator.resources_3.4.201.M20100707-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.ui.views.properties.tabbed_3.5.100.I20100509-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/jdt/plugins/org.eclipse.jdt.ui_3.6.1.r361_v20100825-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/plugins/org.eclipse.debug.ui_3.6.1.v20100901_r361.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/jdt/plugins/org.eclipse.jdt.core.manipulation_1.3.0.v20100520-0800.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/jdt/plugins/org.junit4_4.8.1.v20100525"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/jdt/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/jdt/plugins/org.junit_4.8.1.v4_8_1_v20100427-1100/junit.jar"/> + <pathelement path="../../../../home/sgehwolf/.eclipse/793567567/plugins/org.eclipse.swtbot.eclipse.core_2.0.1.20101106_1831-73ca7af-dev-e36.jar"/> + <pathelement path="../../../../usr/lib64/eclipse/dropins/jdt/plugins/org.eclipse.jdt.junit.runtime_3.4.200.v20100526-0800.jar"/> + <pathelement path="../../../../home/sgehwolf/.eclipse/793567567/plugins/org.eclipse.swtbot.eclipse.finder_2.0.1.20101106_1831-73ca7af-dev-e36.jar"/> + <pathelement path="../../../../home/sgehwolf/.eclipse/793567567/plugins/org.apache.log4j_1.2.13.v200903072027.jar"/> + <pathelement path="../../../../home/sgehwolf/.eclipse/793567567/plugins/org.hamcrest_1.1.0.v20090501071000.jar"/> + <pathelement path="../../../../home/sgehwolf/.eclipse/793567567/plugins/org.hamcrest.library_1.1.0.v20090501071000.jar"/> + <pathelement path="../../../../home/sgehwolf/.eclipse/793567567/plugins/org.hamcrest.integration_1.1.0.v20090501071000.jar"/> + <pathelement path="../../../../home/sgehwolf/.eclipse/793567567/plugins/org.easymock_2.4.0.v20090202-0900.jar"/> + <pathelement path="../../../../home/sgehwolf/.eclipse/793567567/plugins/org.hamcrest.text_1.1.0.v20090501071000.jar"/> + <pathelement path="../../../../home/sgehwolf/.eclipse/793567567/plugins/org.eclipse.swtbot.swt.finder_2.0.1.20101106_1831-73ca7af-dev-e36.jar"/> + <pathelement path="../../../../home/sgehwolf/.eclipse/793567567/plugins/org.eclipse.swtbot.junit4_x_2.0.1.20101106_1831-73ca7af-dev-e36.jar"/> + <pathelement path="../../../../home/sgehwolf/.eclipse/793567567/plugins/org.eclipse.swtbot.go_2.0.1.20101106_1831-73ca7af-dev-e36.jar"/> + </path> + <!-- compile the source code --> + <javac destdir="${build.result.folder}/@dot" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bundleBootClasspath}" source="${bundleJavacSource}" target="${bundleJavacTarget}" > + <compilerarg line="${compilerArg}" compiler="${build.compiler}"/> + <classpath refid="@dot.classpath" /> + <src path="src/" /> + <compilerarg value="@${basedir}/javaCompiler...args" compiler="org.eclipse.jdt.core.JDTCompilerAdapter" /> + <compilerarg line="-log '${build.result.folder}/@dot${logExtension}'" compiler="org.eclipse.jdt.core.JDTCompilerAdapter" /> + </javac> + <antcall target="checkCompilationResults"/> + <!-- Copy necessary resources --> + <copy todir="${build.result.folder}/@dot" failonerror="true" overwrite="false"> + <fileset dir="src/"> + <exclude name="**/*.java"/> + <exclude name="**/package.htm*"/> + </fileset> + </copy> + </target> + + <target name="src.zip" depends="init" unless="src.zip"> + <mkdir dir="${build.result.folder}"/> + <antcall target="zip.src.zip"/> + </target> + <target name="zip.src.zip"> + <zip destfile="${build.result.folder}/src.zip" filesonly="false" whenempty="skip" update="false"> + <fileset dir="src/"> + <include name="**/*.java"/> + </fileset> + </zip> + </target> + <target name="copy.src.zip"> + <copy todir="${source.destination.folder}/" failonerror="true" overwrite="true"> + <fileset dir="src/"> + <include name="**/*.java"/> + </fileset> + </copy> + </target> + + <target name="build.jars" depends="init" description="Compile classes and build nested jars for the plug-in: org.eclipse.linuxtools.changelog.tests.ui."> + <delete file="${compilation.problem.marker}" quiet="true"/> + <available property="@dot" file="${build.result.folder}/@dot"/> + <antcall target="@dot"/> + </target> + + <target name="checkCompilationResults" if="compilation.error.occured"> + <echo file="${compilation.problem.marker}" message="org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019${line.separator}compilation.error.occured=${compilation.error.occured}"/> + <eclipse.logCompileError bundle="org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019" log="${compilation.prereq.log}"> + <include name="/notnfs/workspaces/changelog_svnssh/org.eclipse.linuxtools.changelog.core/compilation.problem"/> + <include name="${pluginTemp}/org.eclipse.linuxtools.changelog.core_2.7.0.201012201019/compilation.problem"/> + <include name="/notnfs/workspaces/changelog_svnssh/org.eclipse.linuxtools.changelog.cparser/compilation.problem"/> + <include name="${pluginTemp}/org.eclipse.linuxtools.changelog.cparser_2.7.0.201012201019/compilation.problem"/> + <include name="/notnfs/workspaces/changelog_svnssh/org.eclipse.linuxtools.changelog.javaparser/compilation.problem"/> + <include name="${pluginTemp}/org.eclipse.linuxtools.changelog.parsers.java_2.7.0.201012201019/compilation.problem"/> + <include name="/notnfs/workspaces/changelog_svnssh/org.eclipse.linuxtools.changelog.tests/compilation.problem"/> + <include name="${pluginTemp}/org.eclipse.linuxtools.changelog.tests_2.7.0.201012201019/compilation.problem"/> + </eclipse.logCompileError> + </target> + + <target name="build.sources" depends="init"> + <available property="src.zip" file="${build.result.folder}/src.zip"/> + <antcall target="src.zip"/> + </target> + + <target name="publish.bin.parts" depends="init" if="p2.publish.parts" unless="compilation.problem.marker.exists"> + <mkdir dir="${build.result.folder}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019"/> + <copy todir="${build.result.folder}" failonerror="true" overwrite="true"> + <fileset dir="${basedir}"> + <include name="META-INF/MANIFEST.MF"/> + <include name="plugin.xml"/> + <include name="fragment.xml"/> + </fileset> + </copy> + <eclipse.versionReplacer path="${build.result.folder}" version="2.7.0.201012201019"/> + <antcall target="apitools.generation"> + <param name="target.folder" value="${build.result.folder}"/> + <param name="projectLocation" value="${basedir}"/> + <param name="binary.folders" value="${build.result.folder}/@dot"/> + <param name="projectName" value="${bundleId}_${bundleVersion}"/> + </antcall> + <eclipse.gatherBundle + metadataRepository="${p2.build.repo}" + artifactRepository="${p2.build.repo}" + buildResultFolder="${build.result.folder}" + unpack="false" + baseDirectory="${basedir}" + /> + </target> + + <target name="gather.bin.parts" depends="init" if="destination.temp.folder"> + <mkdir dir="${destination.temp.folder}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019"/> + <copy todir="${destination.temp.folder}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019" failonerror="true" overwrite="false"> + <fileset dir="${build.result.folder}/@dot"> + <include name="**"/> + </fileset> + </copy> + <copy todir="${destination.temp.folder}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019" failonerror="true" overwrite="true"> + <fileset dir="${basedir}"> + <include name="META-INF/"/> + </fileset> + </copy> + <eclipse.versionReplacer path="${destination.temp.folder}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019" version="2.7.0.201012201019"/> + <antcall target="apitools.generation"> + <param name="target.folder" value="${destination.temp.folder}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019"/> + <param name="projectLocation" value="${basedir}"/> + <param name="binary.folders" value="${build.result.folder}/@dot"/> + <param name="projectName" value="${bundleId}_${bundleVersion}"/> + </antcall> + </target> + + <target name="build.zips" depends="init"> + </target> + + <target name="gather.sources" depends="init" if="destination.temp.folder"> + <mkdir dir="${destination.temp.folder}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019"/> + <copy file="${build.result.folder}/src.zip" todir="${destination.temp.folder}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019" failonerror="false" overwrite="false"/> + <antcall target="copy.src.includes"> + <param name="source.destination.folder" value="${destination.temp.folder}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019"/> + </antcall> + </target> + + <target name="gather.individual.sources" depends="init"> + <antcall target="copy.src.zip"> + <param name="source.destination.folder" value="${destination.temp.folder}"/> + </antcall> + <antcall target="copy.src.includes"> + <param name="source.destination.folder" value="${destination.temp.folder}"/> + </antcall> + </target> + + <target name="copy.src.includes" depends="init"> + </target> + + <target name="gather.logs" depends="init" if="destination.temp.folder"> + <mkdir dir="${destination.temp.folder}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019"/> + <copy todir="${destination.temp.folder}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019" failonerror="false" overwrite="false"> + <fileset dir="${build.result.folder}"> + <include name="@dot${logExtension}"/> + </fileset> + </copy> + </target> + + <target name="clean" depends="init" description="Clean the plug-in: org.eclipse.linuxtools.changelog.tests.ui of all the zips, jars and logs created."> + <delete dir="${build.result.folder}/@dot"/> + <delete file="${build.result.folder}/src.zip"/> + <delete file="${plugin.destination}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019.jar"/> + <delete file="${plugin.destination}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019.zip"/> + <delete dir="${temp.folder}"/> + <delete file="${compilation.problem.marker}" quiet="true"/> + </target> + + <target name="refresh" depends="init" if="eclipse.running" description="Refresh this folder."> + <eclipse.convertPath fileSystemPath="/notnfs/workspaces/changelog_svnssh/org.eclipse.linuxtools.changelog.tests.ui" property="resourcePath"/> + <eclipse.refreshLocal resource="${resourcePath}" depth="infinite"/> + </target> + + <target name="zip.plugin" depends="init" description="Create a zip containing all the elements for the plug-in: org.eclipse.linuxtools.changelog.tests.ui."> + <delete dir="${temp.folder}"/> + <mkdir dir="${temp.folder}"/> + <antcall target="build.jars"/> + <antcall target="build.sources"/> + <antcall target="gather.bin.parts"> + <param name="destination.temp.folder" value="${temp.folder}/"/> + </antcall> + <antcall target="gather.sources"> + <param name="destination.temp.folder" value="${temp.folder}/"/> + </antcall> + <delete> + <fileset dir="${temp.folder}"> + <include name="**/*.bin${logExtension}"/> + </fileset> + </delete> + <zip destfile="${plugin.destination}/org.eclipse.linuxtools.changelog.tests.ui_2.7.0.201012201019.zip" basedir="${temp.folder}" filesonly="true" whenempty="skip" update="false"/> + <delete dir="${temp.folder}"/> + </target> + + <target name="apitools.generation" if="generateAPIDescription"> + <apitooling.apigeneration projectName="${projectName}" project="${projectLocation}" binary="${binary.folders}" target="${target.folder}" extramanifests="${extraManifests}" /> + </target> + +</project> diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/log4j.xml b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/log4j.xml new file mode 100644 index 0000000000..87414d37ef --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/log4j.xml @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> +<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" + debug="false"> + + <appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender"> + <param name="Target" value="System.out" /> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" + value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) - %m%n" /> + </layout> + </appender> + + <appender name="fileAppender" class="org.apache.log4j.FileAppender"> + <param name="File" value="swtbot_tests.log" /> + <param name="Append" value="false" /> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" + value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) - %m%n" /> + </layout> + </appender> + + <appender name="asyncAppender" class="org.apache.log4j.AsyncAppender"> + <!-- appender-ref ref="consoleAppender" / --> + <appender-ref ref="fileAppender" /> + </appender> + + <!-- don't log matchers, this is very high amount of chatter --> + <category name="org.eclipse.swtbot.swt.finder.matchers"> + <priority value="OFF" /> + </category> + + <!-- + don't log widget notification events, this is moderately high chatter + --> + <category name="org.eclipse.swtbot.swt.finder.widgets"> + <priority value="DEBUG" /> + </category> + + <!-- don't log finders, this is moderate chatter --> + <category name="org.eclipse.swtbot.swt.finder.finders"> + <priority value="DEBUG" /> + </category> + + <category name="org.eclipse.swtbot.swt.finder.keyboard"> + <!-- set to a value higher than debug to turn on. --> + <priority value="DEBUG" /> + </category> + + <category name="org.eclipse.swtbot"> + <priority value="ALL" /> + </category> + + <root> + <priority value="INFO" /> + <appender-ref ref="consoleAppender" /> + <appender-ref ref="fileAppender" /> + </root> + +</log4j:configuration>
\ No newline at end of file diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AddChangelogEntrySWTBotTest.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AddChangelogEntrySWTBotTest.java new file mode 100644 index 0000000000..ba82f0c838 --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AddChangelogEntrySWTBotTest.java @@ -0,0 +1,275 @@ +/******************************************************************************* + * Copyright (c) 2010 Red Hat Inc. 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 + *******************************************************************************/ +package org.eclipse.linuxtools.changelog.ui.tests.swtbot; + +import static org.junit.Assert.*; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.bindings.keys.KeyStroke; +import org.eclipse.linuxtools.changelog.tests.fixtures.ChangeLogTestProject; +import org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorer; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.eclipse.finder.waits.Conditions; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor; +import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; +import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.eclipse.ui.IEditorReference; +import org.hamcrest.Matcher; +import org.hamcrest.core.IsInstanceOf; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withPartName; +import static org.hamcrest.Matchers.allOf; + + +/** + * UI tests for "ChangeLog Entry" (CTRL+ALT+C). + * + */ +@RunWith(SWTBotJunit4ClassRunner.class) +public class AddChangelogEntrySWTBotTest { + + private static SWTWorkbenchBot bot; + private static SWTBotTree projectExplorerViewTree; + private ChangeLogTestProject project; + private static final String OFFSET_MARKER = "<-- SELECT -->"; + // The name of the test project, we create + private final String PROJECT_NAME = "changelog-java-project"; + + @BeforeClass + public static void beforeClass() throws Exception { + // delay click speed; with this turned on things get flaky + //System.setProperty("org.eclipse.swtbot.playback.delay", "200"); + bot = new SWTWorkbenchBot(); + try { + bot.viewByTitle("Welcome").close(); + } catch (WidgetNotFoundException e) { + // ignore + } + // Make sure project explorer is open and tree available + ProjectExplorer.openView(); + projectExplorerViewTree = ProjectExplorer.getTree(); + } + + @Before + public void setUp() throws Exception { + // Create an empty test project + project = new ChangeLogTestProject(PROJECT_NAME); + project.addJavaNature(); // make it a Java project + } + + @After + public void tearDown() throws Exception { + this.project.getTestProject().delete(true, null); + } + + /** + * ChangeLog editor should pop-up if inside an active editor + * and a ChangeLog file exists in the project. Tests the CTRL+ALT+c + * shortcut. + * + * @throws Exception + */ + @SuppressWarnings("unchecked") + @Test + public void canAddChangeLogEntryUsingShortCutIfSourceIsActive() throws Exception { + // Add a Java source file + String sourceCode = "package src;\n" + + "public class JavaTest {\n" + + "public static void main(String args[]) {\n" + + "//" + OFFSET_MARKER + "\n" + + "System.out.println(\"Hello World!\");\n" + + "}\n" + + "}\n"; + + assertNull(project.getTestProject().findMember( new Path( + "/src/JavaTest.java"))); + InputStream newFileInputStream = new ByteArrayInputStream( + sourceCode.getBytes()); + project.addFileToProject("/src", "JavaTest.java", newFileInputStream); + + // Add a changelog file + newFileInputStream = new ByteArrayInputStream( + "".getBytes()); + project.addFileToProject("/", "ChangeLog", newFileInputStream); + + assertNotNull(project.getTestProject().findMember( new Path( + "/src/JavaTest.java"))); + assertNotNull(project.getTestProject().findMember( new Path( + "/ChangeLog"))); + + // Open JavaTest.java in an editor + projectExplorerViewTree.expandNode(PROJECT_NAME).expandNode("src").expandNode("JavaTest.java").doubleClick(); + + Matcher<?> editorMatcher = allOf( + IsInstanceOf.instanceOf(IEditorReference.class), + withPartName("JavaTest.java") + ); + // Wait for Java editor to open + bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher)); + SWTBotEditor swtBoteditor = bot.editorByTitle("JavaTest.java"); + SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor(); + eclipseEditor.selectLine(getLineOfOffsetMarker(sourceCode)); + + // Press: CTRL + ALT + c + eclipseEditor.pressShortcut(Keystrokes.CTRL, Keystrokes.ALT, KeyStroke.getInstance("C")); + // Wait for ChangeLog editor to open + editorMatcher = allOf( + IsInstanceOf.instanceOf(IEditorReference.class), + withPartName("ChangeLog") + ); + bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher)); + swtBoteditor = bot.activeEditor(); + swtBoteditor.save(); // save to avoid "save changes"-pop-up + assertEquals("ChangeLog", swtBoteditor.getTitle()); + eclipseEditor = swtBoteditor.toTextEditor(); + // make sure expected entry has been added. + assertTrue(eclipseEditor.getText().contains("\t* src/JavaTest.java (main):")); + } + + /** + * ChangeLog editor should pop-up if inside an active editor + * and a ChangeLog file exists in the project. Tests the "Edit" => "ChangeLog Entry" + * menu item. + * + * @throws Exception + */ + @SuppressWarnings("unchecked") + @Test + public void canAddChangeLogEntryUsingEditMenuIfSourceIsActive() throws Exception { + // Add a Java source file + String sourceCode = "package src;\n" + + "public class JavaTest {\n" + + "public static void main(String args[]) {\n" + + "//" + OFFSET_MARKER + "\n" + + "System.out.println(\"Hello World!\");\n" + + "}\n" + + "}\n"; + + assertNull(project.getTestProject().findMember( new Path( + "/src/JavaTest.java"))); + InputStream newFileInputStream = new ByteArrayInputStream( + sourceCode.getBytes()); + project.addFileToProject("/src", "JavaTest.java", newFileInputStream); + + // Add a changelog file + newFileInputStream = new ByteArrayInputStream( + "".getBytes()); + project.addFileToProject("/", "ChangeLog", newFileInputStream); + + assertNotNull(project.getTestProject().findMember( new Path( + "/src/JavaTest.java"))); + assertNotNull(project.getTestProject().findMember( new Path( + "/ChangeLog"))); + + // Open JavaTest.java in an editor + SWTBotTreeItem projectItem = projectExplorerViewTree.expandNode(PROJECT_NAME); +// for (SWTBotTreeItem i: projectItem.getItems()) { +// System.out.println(i.getText()); +// } + projectItem.expandNode("src").expandNode("JavaTest.java").doubleClick(); + + Matcher<?> editorMatcher = allOf( + IsInstanceOf.instanceOf(IEditorReference.class), + withPartName("JavaTest.java") + ); + // Wait for editor to open + bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher)); + SWTBotEditor swtBoteditor = bot.editorByTitle("JavaTest.java"); + SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor(); + eclipseEditor.selectLine(getLineOfOffsetMarker(sourceCode)); + + // Click menu item. + bot.menu("Edit").menu("ChangeLog Entry").click(); + // Wait for ChangeLog editor to open + editorMatcher = allOf( + IsInstanceOf.instanceOf(IEditorReference.class), + withPartName("ChangeLog") + ); + bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher)); + swtBoteditor = bot.activeEditor(); + swtBoteditor.save(); // save to avoid "save changes"-pop-up + assertEquals("ChangeLog", swtBoteditor.getTitle()); + eclipseEditor = swtBoteditor.toTextEditor(); + // make sure expected entry has been added. + assertTrue(eclipseEditor.getText().contains("\t* src/JavaTest.java (main):")); + } + + /** + * FIXME: Disable menu item instead of showing it and doing nothing. + * + * This test throws WidgetNotFountException (i.e. shouldn't open any editor). + */ + @Test(expected=WidgetNotFoundException.class) + public void shouldDoNothingIfNoEditorIsActive() { + assertNull(project.getTestProject().findMember( new Path("/src/dummy"))); + try { + project.addFileToProject("src", "dummy", new ByteArrayInputStream("".getBytes())); + } catch (CoreException e) { + fail("Could not add /src/dummy file to project"); + } + assertNotNull(project.getTestProject().findMember( new Path("/src/dummy"))); + // Make sure we are in the project explorer view and no editors are open + closeAllEditors(); + projectExplorerViewTree.expandNode(PROJECT_NAME).expandNode("src"); + // Try to create ChangeLog + bot.menu("Edit").menu("ChangeLog Entry").click(); + // Don't wait 5 secs + long oldTimeout = SWTBotPreferences.TIMEOUT; + SWTBotPreferences.TIMEOUT = 1000; // give it a full second :) + bot.activeEditor(); + SWTBotPreferences.TIMEOUT = oldTimeout; + } + + /** + * @param The source text. + * @return The index of the first line containing the OFFSET_MARKER string in sourceCode. + * -1 if not found. + */ + private int getLineOfOffsetMarker(String sourceCode) { + // select line containing the println() statement. + int offset = -1, i = 0; + for (String line: sourceCode.split("\n")) { + if (line.indexOf(OFFSET_MARKER) >= 0) { + offset = i; + break; + } + i++; + } + return offset; + } + + /** + * Close all active editors. + */ + private void closeAllEditors() { + SWTBotEditor currEditor; + try { + do { + currEditor = bot.activeEditor(); + currEditor.close(); + } while (currEditor != null); + } catch (WidgetNotFoundException e) { + // all closed + } + } + +} diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AllSWTBotTests.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AllSWTBotTests.java new file mode 100644 index 0000000000..49e60230ae --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/AllSWTBotTests.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2010 Red Hat Inc. 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 + *******************************************************************************/ +package org.eclipse.linuxtools.changelog.ui.tests.swtbot; + +import org.junit.runners.Suite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Run as SWTBot test. + * + */ +@RunWith(Suite.class) +@SuiteClasses({ + AddChangelogEntrySWTBotTest.class, + PrepareChangelogSWTBotTest.class, + DisabledPrepareChangelogSWTBotTest.class, + CreateChangeLogFromHistorySWTBotTest.class, + FormatChangeLogSWTBotTest.class + } +) + +public class AllSWTBotTests { + // empty +} diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/CreateChangeLogFromHistorySWTBotTest.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/CreateChangeLogFromHistorySWTBotTest.java new file mode 100644 index 0000000000..9c84e9a9c1 --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/CreateChangeLogFromHistorySWTBotTest.java @@ -0,0 +1,198 @@ +/******************************************************************************* + * Copyright (c) 2010 Red Hat Inc. 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 + *******************************************************************************/ +package org.eclipse.linuxtools.changelog.ui.tests.swtbot; + +import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withPartName; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.ByteArrayInputStream; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.bindings.keys.KeyStroke; +import org.eclipse.linuxtools.changelog.ui.tests.utils.ContextMenuHelper; +import org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorer; +import org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorerTreeItemAppearsCondition; +import org.eclipse.linuxtools.changelog.ui.tests.utils.SVNProject; +import org.eclipse.linuxtools.changelog.ui.tests.utils.SVNProjectCreatedCondition; +import org.eclipse.linuxtools.changelog.ui.tests.utils.TableAppearsCondition; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.eclipse.finder.waits.Conditions; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor; +import org.eclipse.swtbot.swt.finder.SWTBot; +import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; +import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.eclipse.ui.IEditorReference; +import org.hamcrest.Matcher; +import org.hamcrest.Matchers; +import org.hamcrest.core.IsInstanceOf; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * UI tests for creating changelogs from SVN history (commit messages). + * + */ +@RunWith(SWTBotJunit4ClassRunner.class) +public class CreateChangeLogFromHistorySWTBotTest { + + private static SWTWorkbenchBot bot; + private static SWTBotTree projectExplorerViewTree; + private IProject project; + private SVNProject subversionProject; + // The name of the test project, we create + private final String PROJECT_NAME = "org.eclipse.linuxtools.changelog.tests"; + // An available SVN repo + private final String SVN_PROJECT_URL = "svn://dev.eclipse.org/svnroot/technology/" + + "org.eclipse.linuxtools/changelog/trunk"; + + @BeforeClass + public static void beforeClass() throws Exception { + // delay click speed + //System.setProperty("org.eclipse.swtbot.playback.delay", "200"); + bot = new SWTWorkbenchBot(); + try { + bot.viewByTitle("Welcome").close(); + } catch (WidgetNotFoundException e) { + // ignore + } + // Make sure project explorer is open and tree available + ProjectExplorer.openView(); + projectExplorerViewTree = ProjectExplorer.getTree(); + } + + @Before + public void setUp() throws Exception { + // Do an SVN checkout of the changelog.tests plugin + subversionProject = new SVNProject(bot); + project = subversionProject.setProjectName(PROJECT_NAME).setRepoURL(SVN_PROJECT_URL).checkoutProject(); + bot.waitUntil(new SVNProjectCreatedCondition(PROJECT_NAME)); + ProjectExplorer.openView(); + } + + @After + public void tearDown() throws Exception { + this.project.delete(true, null); + // discard existing repo from previous test runs + try { + subversionProject.discardRepositoryLocation(); + } catch (WidgetNotFoundException e) { + // Ignore case if repository not existing + } + } + + /** + * Create changelog from SVN history (commit messages). + * + * @throws Exception + */ + @SuppressWarnings({ "unchecked" }) + @Test + public void canPrepareChangeLogFromSVNHistory() throws Exception { + // select ChangeLog file + String teamProviderString = "[changelog/trunk/" + PROJECT_NAME + "]"; + SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString); + long oldTimeout = SWTBotPreferences.TIMEOUT; + SWTBotPreferences.TIMEOUT = 5000; + bot.waitUntil(new ProjectExplorerTreeItemAppearsCondition(projectExplorerViewTree, PROJECT_NAME, teamProviderString, "ChangeLog")); + SWTBotPreferences.TIMEOUT = oldTimeout; + SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog"); + changeLogItem.select(); + + // open history for ChangeLog file + clickOnShowHistory(projectExplorerViewTree); + SWTBot historyViewBot = bot.viewByTitle("History").bot(); + // wait for SVN revision table to appear + oldTimeout = SWTBotPreferences.TIMEOUT; + SWTBotPreferences.TIMEOUT = 3 * 5000; + historyViewBot.waitUntil(new TableAppearsCondition()); + SWTBotPreferences.TIMEOUT = oldTimeout; + SWTBotTable historyTable = historyViewBot.table(); + historyTable.select(0); // select the first row + + // right-click => Generate Changelog... + clickOnGenerateChangeLog(historyTable); + bot.waitUntil(Conditions.shellIsActive("Generate ChangeLog")); + SWTBotShell shell = bot.shell("Generate ChangeLog"); + + SWTBot generateChangelogBot = shell.bot(); + generateChangelogBot.radio("Clipboard").click(); + generateChangelogBot.button("OK").click(); + + // create and open a new file for pasting + String pasteFile = "newFile"; + IFile newFile = project.getFile(new Path(pasteFile)); + newFile.create(new ByteArrayInputStream("".getBytes()) /* empty content */, false, null); + project.refreshLocal(IResource.DEPTH_INFINITE, null); + + assertNotNull(project.findMember(new Path(pasteFile))); + + ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, + teamProviderString).expandNode(pasteFile).select().doubleClick(); + Matcher<?> editorMatcher = Matchers.allOf( + IsInstanceOf.instanceOf(IEditorReference.class), + withPartName(pasteFile) + ); + bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher)); + oldTimeout = SWTBotPreferences.TIMEOUT; + SWTBotPreferences.TIMEOUT = oldTimeout; + SWTBotEditor swtBoteditor = bot.activeEditor(); + assertEquals(pasteFile, swtBoteditor.getTitle()); + SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor(); + + // go to beginning of editor + eclipseEditor.selectRange(0, 0, 0); + // paste + eclipseEditor.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance("V")); + swtBoteditor.save(); + // make sure some changelog like text was pasted + String text = eclipseEditor.getText(); + assertTrue(!text.equals("")); + // FIXME: Add a better assertion. Not sure what would be a good one. +// eclipseEditor.selectLine(2); // select third line +// final String actualThirdLineContent = eclipseEditor.getSelection(); +// System.out.println(actualThirdLineContent); +// System.out.println(text); +// assertTrue(actualThirdLineContent.contains("\t* ")); + } + + /** + * Helper method for right-clicking => Generate ChangeLog in History + * view table. + * + * Pre: History view table row selected. + */ + private void clickOnGenerateChangeLog(SWTBotTable table) { + String menuItem = "Generate ChangeLog..."; + ContextMenuHelper.clickContextMenu(table, menuItem); + } + + /** + * Helper method for right-click => Team => Show History. + */ + private void clickOnShowHistory(SWTBotTree tree) { + String menuItem = "Team"; + String subMenuItem = "Show History"; + ContextMenuHelper.clickContextMenu(tree, menuItem, subMenuItem); + } + +} diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/DisabledPrepareChangelogSWTBotTest.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/DisabledPrepareChangelogSWTBotTest.java new file mode 100644 index 0000000000..972f050396 --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/DisabledPrepareChangelogSWTBotTest.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2010 Red Hat Inc. 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 + *******************************************************************************/ +package org.eclipse.linuxtools.changelog.ui.tests.swtbot; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.io.ByteArrayInputStream; + +import org.eclipse.core.runtime.Path; +import org.eclipse.linuxtools.changelog.tests.fixtures.ChangeLogTestProject; +import org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorer; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.eclipse.swtbot.swt.finder.widgets.TimeoutException; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + + +/** + * + * UI test for "Prepare ChangeLog" when project not shared. + * + */ +@RunWith(SWTBotJunit4ClassRunner.class) +public class DisabledPrepareChangelogSWTBotTest { + + private static SWTWorkbenchBot bot; + private static SWTBotTree projectExplorerViewTree; + private final String projectName = "not-shared"; + private ChangeLogTestProject project; + + @BeforeClass + public static void beforeClass() throws Exception { + // delay click speed + //System.setProperty("org.eclipse.swtbot.playback.delay", "200"); + bot = new SWTWorkbenchBot(); + try { + bot.viewByTitle("Welcome").close(); + } catch (WidgetNotFoundException e) { + // ignore + } + // Make sure project explorer is open and tree available + ProjectExplorer.openView(); + projectExplorerViewTree = ProjectExplorer.getTree(); + } + + @Before + public void setUp() throws Exception { + project = new ChangeLogTestProject(projectName); + } + + @After + public void tearDown() throws Exception { + this.project.getTestProject().delete(true, null); + } + + /** + * If the project is not shared by any CVS or SVN team provider, "Prepare ChangeLog" + * should be disabled. + * + * @throws Exception + */ + @Test + public void cannotPrepareChangeLogOnNonCVSOrSVNProject() throws Exception { + assertNull(project.getTestProject().findMember(new Path("/ChangeLog"))); + + final String changeLogContent = "2010-12-08 Will Probe <will@example.com>\n\n" + + "\t* path/to/some/non-existing/file.c: New file.\n"; + project.addFileToProject("/", "ChangeLog", new ByteArrayInputStream(changeLogContent.getBytes())); + + assertNotNull(project.getTestProject().findMember(new Path("/ChangeLog"))); + + // select ChangeLog file + String teamProviderString = "n/a"; + SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, projectName, teamProviderString); + SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog"); + changeLogItem.select(); + long oldTimeout = SWTBotPreferences.TIMEOUT; + SWTBotPreferences.TIMEOUT = 100; + try { + bot.menu("Prepare ChangeLog").click(); // Should be disabled (throws exception) + fail("'Prepare ChangeLog' should be disabled"); + } catch (TimeoutException e) { + assertTrue(e.getMessage().contains("The widget with mnemonic 'Prepare ChangeLog' was not enabled.")); + } + SWTBotPreferences.TIMEOUT = oldTimeout; + } + +} diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/FormatChangeLogSWTBotTest.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/FormatChangeLogSWTBotTest.java new file mode 100644 index 0000000000..54b44fc8dd --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/FormatChangeLogSWTBotTest.java @@ -0,0 +1,144 @@ +/******************************************************************************* + * Copyright (c) 2010 Red Hat Inc. 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 + *******************************************************************************/ +package org.eclipse.linuxtools.changelog.ui.tests.swtbot; + +import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withPartName; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.io.ByteArrayInputStream; + +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.bindings.keys.KeyStroke; +import org.eclipse.linuxtools.changelog.tests.fixtures.ChangeLogTestProject; +import org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorer; +import org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorerTreeItemAppearsCondition; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.eclipse.finder.waits.Conditions; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor; +import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; +import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.eclipse.ui.IEditorReference; +import org.hamcrest.Matcher; +import org.hamcrest.Matchers; +import org.hamcrest.core.IsInstanceOf; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * UI tests for formatting ChangeLog files. + * + */ +@RunWith(SWTBotJunit4ClassRunner.class) +public class FormatChangeLogSWTBotTest { + + private static SWTWorkbenchBot bot; + private static SWTBotTree projectExplorerViewTree; + private ChangeLogTestProject project; + // The name of the test project, we create + private final String PROJECT_NAME = "org.eclipse.linuxtools.changelog.ui.formattestproject"; + + @BeforeClass + public static void beforeClass() throws Exception { + // delay click speed + //System.setProperty("org.eclipse.swtbot.playback.delay", "200"); + bot = new SWTWorkbenchBot(); + try { + bot.viewByTitle("Welcome").close(); + } catch (WidgetNotFoundException e) { + // ignore + } + // Make sure project explorer is open and tree available + ProjectExplorer.openView(); + projectExplorerViewTree = ProjectExplorer.getTree(); + } + + @Before + public void setUp() throws Exception { + project = new ChangeLogTestProject(PROJECT_NAME); + ProjectExplorer.openView(); + } + + @After + public void tearDown() throws Exception { + this.project.getTestProject().delete(true, null); + } + + /** + * Simple test for ChangeLog formatting. + * + * @throws Exception + */ + @SuppressWarnings({ "unchecked" }) + @Test + public void canFormatChangeLogFile() throws Exception { + // add a ChangeLog file + assertNull(project.getTestProject().findMember(new Path("/ChangeLog"))); + final String changelogContent = "2010-12-14 Severin Gehwolf <sgehwolf@redhat.com>\n\n" + + "\tAdded org.eclipse.linuxtools.changelog.tests.ui plug-in.\n" + + "\t* .classpath: New file.\n" + + "\t* .project: New file.\n" + + "\t* .settings/org.eclipse.jdt.core.prefs: New file.\n" + + "\t* build.properties: New file.\n" + + "\t* src/log4j.xml: New file.\n" + + "\t* src/org/eclipse/linuxtools/changelog/tests/ui/utils/ContextMenuHelper.java: New file.\n" + + "\t* src/org/eclipse/linuxtools/changelog/tests/ui/utils/ProjectExplorer.java: New file.\n" + + "\t* src/org/eclipse/linuxtools/changelog/tests/ui/utils/ProjectExplorerTreeItemAppearsCondition.java: New file.\n"; + project.addFileToProject("/", "ChangeLog", new ByteArrayInputStream(changelogContent.getBytes())); + assertNotNull(project.getTestProject().findMember(new Path("/ChangeLog"))); + + // select ChangeLog file + String teamProviderString = "n/a"; + SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString); + long oldTimeout = SWTBotPreferences.TIMEOUT; + SWTBotPreferences.TIMEOUT = 5000; + bot.waitUntil(new ProjectExplorerTreeItemAppearsCondition(projectExplorerViewTree, PROJECT_NAME, teamProviderString, "ChangeLog")); + SWTBotPreferences.TIMEOUT = oldTimeout; + SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog"); + changeLogItem.doubleClick(); // should open ChangeLog file + + oldTimeout = SWTBotPreferences.TIMEOUT; + SWTBotPreferences.TIMEOUT = 3 * 5000; + // Wait for ChangeLog editor to open + Matcher<?> editorMatcher = Matchers.allOf( + IsInstanceOf.instanceOf(IEditorReference.class), + withPartName("ChangeLog") + ); + bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher)); + SWTBotEditor swtBoteditor = bot.activeEditor(); + assertEquals("ChangeLog", swtBoteditor.getTitle()); + + SWTBotEclipseEditor swtBotEclipseEditor = swtBoteditor.toTextEditor(); + + // Add two extra lines after the first date line + swtBotEclipseEditor.insertText(1, 0, "\n\n"); + // Should have 3 empty lines between date-line and first file entry + swtBotEclipseEditor.selectRange(1, 0, 3); + + // format: ESC CTRL+F + swtBotEclipseEditor.pressShortcut(Keystrokes.ESC); + swtBotEclipseEditor.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance("F")); + swtBoteditor.save(); + String secondLine = swtBotEclipseEditor.getTextOnLine(1); + String thirdLine = swtBotEclipseEditor.getTextOnLine(2); + // FIXME: These assertions are lame. + assertEquals("", secondLine); + assertTrue(!"".equals(thirdLine)); + } + +} diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/PrepareChangelogSWTBotTest.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/PrepareChangelogSWTBotTest.java new file mode 100644 index 0000000000..8d252d093f --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/swtbot/PrepareChangelogSWTBotTest.java @@ -0,0 +1,250 @@ +/******************************************************************************* + * Copyright (c) 2010 Red Hat Inc. 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 + *******************************************************************************/ +package org.eclipse.linuxtools.changelog.ui.tests.swtbot; + +import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withPartName; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.ByteArrayInputStream; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.bindings.keys.KeyStroke; +import org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorer; +import org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorerTreeItemAppearsCondition; +import org.eclipse.linuxtools.changelog.ui.tests.utils.SVNProject; +import org.eclipse.linuxtools.changelog.ui.tests.utils.SVNProjectCreatedCondition; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.eclipse.finder.waits.Conditions; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor; +import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; +import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.eclipse.ui.IEditorReference; +import org.hamcrest.Matcher; +import org.hamcrest.Matchers; +import org.hamcrest.core.IsInstanceOf; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + + +/** + * + * UI tests for "Prepare ChangeLog" (CTRL+ALT+P) and the clipboard magic + * (CTRL+ALT+V). + * + */ +@RunWith(SWTBotJunit4ClassRunner.class) +public class PrepareChangelogSWTBotTest { + + private static SWTWorkbenchBot bot; + private static SWTBotTree projectExplorerViewTree; + private SVNProject subversionProject; + private IProject project; + // The name of the test project, we create + private final String PROJECT_NAME = "org.eclipse.linuxtools.changelog.tests"; + // An available SVN repo + private final String SVN_PROJECT_URL = "svn://dev.eclipse.org/svnroot/technology/" + + "org.eclipse.linuxtools/changelog/trunk"; + + @BeforeClass + public static void beforeClass() throws Exception { + // delay click speed + //System.setProperty("org.eclipse.swtbot.playback.delay", "200"); + bot = new SWTWorkbenchBot(); + try { + bot.viewByTitle("Welcome").close(); + } catch (WidgetNotFoundException e) { + // ignore + } + // Make sure project explorer is open and tree available + ProjectExplorer.openView(); + projectExplorerViewTree = ProjectExplorer.getTree(); + } + + @Before + public void setUp() throws Exception { + // Do an SVN checkout of the changelog.tests plugin + subversionProject = new SVNProject(bot); + project = subversionProject.setProjectName(PROJECT_NAME).setRepoURL(SVN_PROJECT_URL).checkoutProject(); + bot.waitUntil(new SVNProjectCreatedCondition(PROJECT_NAME)); + ProjectExplorer.openView(); + } + + @After + public void tearDown() throws Exception { + this.project.delete(true, null); + // discard existing repo from previous test runs + try { + subversionProject.discardRepositoryLocation(); + } catch (WidgetNotFoundException e) { + // Ignore case if repository not existing + } + } + + /** + * Basic prepare changelog test. + * + * @throws Exception + */ + @SuppressWarnings("unchecked") + @Test + public void canPrepareChangeLog() throws Exception { + // Find manifest file + IResource manifest = project.findMember(new Path("/META-INF/MANIFEST.MF")); + assertNotNull(manifest); + // delete it + manifest.delete(true, null); + project.refreshLocal(IResource.DEPTH_INFINITE, null); + + // select ChangeLog file + String teamProviderString = "[changelog/trunk/" + PROJECT_NAME + "]"; + SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString); + SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog"); + changeLogItem.select(); + bot.menu("Prepare ChangeLog").click(); // Should be unique + + long oldTimeout = SWTBotPreferences.TIMEOUT; + SWTBotPreferences.TIMEOUT = 3 * 5000; + // Wait for ChangeLog editor to open + Matcher<?> editorMatcher = Matchers.allOf( + IsInstanceOf.instanceOf(IEditorReference.class), + withPartName("ChangeLog") + ); + bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher)); + SWTBotPreferences.TIMEOUT = oldTimeout; + + SWTBotEditor swtBoteditor = bot.activeEditor(); + swtBoteditor.save(); // save to avoid "save changes"-pop-up + assertEquals("ChangeLog", swtBoteditor.getTitle()); + SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor(); + // make sure expected entry has been added. + assertTrue(matchHead(eclipseEditor.getText(), "\t* META-INF/MANIFEST.MF:", 3)); + } + + /** + * Should be able to save changes to ChangeLog file in clipboard. + * Tests CTRL + ALT + V functionality. + * + * @throws Exception + */ + @SuppressWarnings("unchecked") + @Test + public void canPrepareChangeLogAndSaveChangesInChangeLogFileToClipboard() throws Exception { + // Find manifest file + IResource manifest = project.findMember(new Path("/META-INF/MANIFEST.MF")); + assertNotNull(manifest); + // delete it + manifest.delete(true, null); + project.refreshLocal(IResource.DEPTH_INFINITE, null); + + // select ChangeLog file + String teamProviderString = "[changelog/trunk/" + PROJECT_NAME + "]"; + SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString); + long oldTimeout = SWTBotPreferences.TIMEOUT; + SWTBotPreferences.TIMEOUT = 5000; + bot.waitUntil(new ProjectExplorerTreeItemAppearsCondition(projectExplorerViewTree, PROJECT_NAME, teamProviderString, "ChangeLog")); + SWTBotPreferences.TIMEOUT = oldTimeout; + SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog"); + changeLogItem.select(); + // CTRL + ALT + P + bot.activeShell().pressShortcut(Keystrokes.CTRL, Keystrokes.ALT, KeyStroke.getInstance("P")); + + oldTimeout = SWTBotPreferences.TIMEOUT; + SWTBotPreferences.TIMEOUT = 3 * 5000; + // Wait for ChangeLog editor to open + Matcher<?> editorMatcher = Matchers.allOf( + IsInstanceOf.instanceOf(IEditorReference.class), + withPartName("ChangeLog") + ); + bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher)); + SWTBotEditor swtBoteditor = bot.activeEditor(); + swtBoteditor.save(); // save to avoid "save changes"-pop-up + assertEquals("ChangeLog", swtBoteditor.getTitle()); + SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor(); + // make sure expected entry has been added. + assertTrue(matchHead(eclipseEditor.getText(), "\t* META-INF/MANIFEST.MF:", 3)); + eclipseEditor.selectLine(0); // select first line + final String expectedFirstLineContent = eclipseEditor.getSelection(); + + // save changes to clipboard: CTRL + ALT + V + eclipseEditor.pressShortcut(Keystrokes.CTRL, Keystrokes.ALT, KeyStroke.getInstance("V")); + + // create and open a new file for pasting + String pasteFile = "newFile"; + IFile newFile = project.getFile(new Path(pasteFile)); + newFile.create(new ByteArrayInputStream("".getBytes()) /* empty content */, false, null); + project.refreshLocal(IResource.DEPTH_INFINITE, null); + + assertNotNull(project.findMember(new Path(pasteFile))); + + ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, + teamProviderString).expandNode(pasteFile).select().doubleClick(); + //bot.activeShell().pressShortcut(Keystrokes.F3); // open file + editorMatcher = Matchers.allOf( + IsInstanceOf.instanceOf(IEditorReference.class), + withPartName(pasteFile) + ); + bot.waitUntil(Conditions.waitForEditor((Matcher<IEditorReference>) editorMatcher)); + SWTBotPreferences.TIMEOUT = oldTimeout; + swtBoteditor = bot.activeEditor(); + assertEquals(pasteFile, swtBoteditor.getTitle()); + eclipseEditor = swtBoteditor.toTextEditor(); + + // go to beginning of editor + eclipseEditor.selectRange(0, 0, 0); + // paste + eclipseEditor.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance("V")); + swtBoteditor.save(); + // make sure proper content was pasted + assertTrue(matchHead(eclipseEditor.getText(), "\t* META-INF/MANIFEST.MF:", 3)); + eclipseEditor.selectLine(0); // select first line + final String actualFirstLineContent = eclipseEditor.getSelection(); + assertEquals(expectedFirstLineContent, actualFirstLineContent); + } + + /** + * Determine if first <code>i</code> lines in <code>text</code> contain + * the string <code>matchText</code>. + * + * @param text The text to compare to. + * @param matchText The match string to look for. + * @param i The number of lines in text to consider. + * @return + * + * @throws IllegalArgumentException if <code>i</code> is invalid. + */ + private boolean matchHead(String text, String matchText, int i) throws IllegalArgumentException { + if ( i < 0 ) { + throw new IllegalArgumentException(); + } + String[] lines = text.split("\n"); + if ( lines.length < i ) { + throw new IllegalArgumentException(); + } + // arguments appear to be good + for (int j = 0; j < i; j++) { + if (lines[j].contains(matchText)) { + return true; + } + } + return false; // no match + } + +} diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ContextMenuHelper.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ContextMenuHelper.java new file mode 100644 index 0000000000..659eca05e6 --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ContextMenuHelper.java @@ -0,0 +1,179 @@ +/******************************************************************************* + * Copyright (c) 2010, SAP AG + * + * 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: + * Stefan Seelmann - initial implementation posted to + * http://www.eclipse.org/forums/index.php?t=msg&th=11863&start=2 + *******************************************************************************/ +package org.eclipse.linuxtools.changelog.ui.tests.utils; + +import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.instanceOf; + +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.SWTException; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; +import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; +import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; +import org.eclipse.swtbot.swt.finder.results.VoidResult; +import org.eclipse.swtbot.swt.finder.results.WidgetResult; +import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot; +import org.hamcrest.Matcher; + +public class ContextMenuHelper { + + /** + * Clicks the context menu matching the text. + * + * @param bot + * + * @param texts + * the text on the context menu. + * @throws WidgetNotFoundException + * if the widget is not found. + * @throws SWTException + * if the menu item is disabled (the root cause being an + * {@link IllegalStateException}) + */ + public static void clickContextMenu(final AbstractSWTBot<?> bot, + final String... texts) { + + // show + final MenuItem menuItem = UIThreadRunnable + .syncExec(new WidgetResult<MenuItem>() { + public MenuItem run() { + MenuItem theItem = getMenuItem(bot, texts); + if (theItem != null && !theItem.isEnabled()) + throw new IllegalStateException( + "Menu item is diabled"); + + return theItem; + } + }); + if (menuItem == null) { + throw new WidgetNotFoundException("Could not find menu: " + + Arrays.asList(texts)); + } + + // click + click(menuItem); + + // hide + UIThreadRunnable.syncExec(new VoidResult() { + public void run() { + if (menuItem.isDisposed()) + return; // menu already gone + hide(menuItem.getParent()); + } + }); + } + + @SuppressWarnings("unchecked") + private static MenuItem getMenuItem(final AbstractSWTBot<?> bot, + final String... texts) { + MenuItem theItem = null; + Control control = (Control) bot.widget; + // for dynamic menus, we need to issue this event + control.notifyListeners(SWT.MenuDetect, new Event()); + Menu menu = control.getMenu(); + for (String text : texts) { + Matcher<?> matcher = allOf(instanceOf(MenuItem.class), + withMnemonic(text)); + theItem = show(menu, matcher); + if (theItem != null) { + menu = theItem.getMenu(); + } else { + hide(menu); + break; + } + } + return theItem; + } + + /** + * Checks if the context menu matching the text is enabled + * + * @param bot + * + * @param texts + * the text on the context menu. + * @return true if the context menu is enabled + * @throws WidgetNotFoundException + * if the widget is not found. + */ + public static boolean isContextMenuItemEnabled(final AbstractSWTBot<?> bot, + final String... texts) { + + final AtomicBoolean enabled = new AtomicBoolean(false); + // show + final MenuItem menuItem = UIThreadRunnable + .syncExec(new WidgetResult<MenuItem>() { + public MenuItem run() { + MenuItem theItem = getMenuItem(bot, texts); + if (theItem != null && theItem.isEnabled()) + enabled.set(true); + return theItem; + } + }); + if (menuItem == null) { + throw new WidgetNotFoundException("Could not find menu: " + + Arrays.asList(texts)); + } + // hide + UIThreadRunnable.syncExec(new VoidResult() { + public void run() { + if (menuItem.isDisposed()) + return; // menu already gone + hide(menuItem.getParent()); + } + }); + return enabled.get(); + } + + private static MenuItem show(final Menu menu, final Matcher<?> matcher) { + if (menu != null) { + menu.notifyListeners(SWT.Show, new Event()); + MenuItem[] items = menu.getItems(); + for (final MenuItem menuItem : items) { + if (matcher.matches(menuItem)) { + return menuItem; + } + } + menu.notifyListeners(SWT.Hide, new Event()); + } + return null; + } + + private static void click(final MenuItem menuItem) { + final Event event = new Event(); + event.time = (int) System.currentTimeMillis(); + event.widget = menuItem; + event.display = menuItem.getDisplay(); + event.type = SWT.Selection; + + UIThreadRunnable.asyncExec(menuItem.getDisplay(), new VoidResult() { + public void run() { + menuItem.notifyListeners(SWT.Selection, event); + } + }); + } + + private static void hide(final Menu menu) { + menu.notifyListeners(SWT.Hide, new Event()); + if (menu.getParentMenu() != null) { + hide(menu.getParentMenu()); + } + } +} diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorer.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorer.java new file mode 100644 index 0000000000..94cf2fbc10 --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorer.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2010 Red Hat Inc. 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 + *******************************************************************************/ +package org.eclipse.linuxtools.changelog.ui.tests.utils; + +import java.util.StringTokenizer; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; + +/** + * Project Explorer abstraction for SWTBot tests. + * + */ +public class ProjectExplorer { + + private static SWTWorkbenchBot bot = new SWTWorkbenchBot(); + + /** + * Opens the Project Explorer view. + */ + public static void openView() throws Exception { + bot.menu("Window").menu("Show View").menu("Project Explorer").click(); + } + + /** + * Assumes Project Explorer view is shown. + * + * @return The tree of the Project Explorer view + */ + public static SWTBotTree getTree() { + SWTBotView projectExplorer = bot.viewByTitle("Project Explorer"); + projectExplorer.show(); + Composite projectExplorerComposite = (Composite) projectExplorer.getWidget(); + Tree swtTree = (Tree) bot.widget(WidgetMatcherFactory.widgetOfType(Tree.class), projectExplorerComposite); + return new SWTBotTree(swtTree); + } + + /** + * @param projectItem The tree item corresponding to the project. + * @param name + * name of an item + * @return the project item pertaining to the project + */ + public static SWTBotTreeItem getProjectItem(SWTBotTreeItem projectItem, + String file) { + for (SWTBotTreeItem item : projectItem.getItems()) { + String itemText = item.getText(); + if (itemText.contains(file)) { + if (itemText.contains(" ")) { + StringTokenizer tok = new StringTokenizer(itemText, " "); + String name = tok.nextToken(); + if (file.equals(name)) + return item; + } else if (itemText.equals(file)) { + return item; + } + } + } + return null; + } + + /** + * Expand the given project (optionally stripping off the team provider bits) + * + * @param projectName + * @param teamProviderString + * @return + */ + public static SWTBotTreeItem expandProject(SWTBotTree projectExplorerTree, String projectName, String teamProviderString) { + String itemName; + for (SWTBotTreeItem item: projectExplorerTree.getAllItems()) { + itemName = item.getText(); + if (itemName.contains(projectName)) { // may also contain repo info + if (itemName.contains(teamProviderString)) { + return projectExplorerTree.expandNode(projectName + " " + + teamProviderString); + } else { + return projectExplorerTree.expandNode(projectName); + } + } + } + // nothing appropriate found + return null; + } +} diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorerTreeItemAppearsCondition.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorerTreeItemAppearsCondition.java new file mode 100644 index 0000000000..2833ece1e6 --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/ProjectExplorerTreeItemAppearsCondition.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2010 Red Hat Inc. 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 + *******************************************************************************/ +package org.eclipse.linuxtools.changelog.ui.tests.utils; + +import org.eclipse.swtbot.swt.finder.SWTBot; +import org.eclipse.swtbot.swt.finder.waits.ICondition; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; + +/** + * Condition to wait until a certain item appears in the + * Project Explorer tree. + * + */ +public class ProjectExplorerTreeItemAppearsCondition implements ICondition { + + private SWTBotTreeItem treeItem; + private String itemName; + private String parent; + private String teamDirt; + private SWTBotTree projectExplorerTree; + + public ProjectExplorerTreeItemAppearsCondition(SWTBotTree projectExplorerTree, String parent, String teamDirt, String treeItemName) { + this.itemName = treeItemName; + this.parent = parent; + this.teamDirt = teamDirt; + this.projectExplorerTree = projectExplorerTree; + } + + @Override + public boolean test() throws Exception { + treeItem = ProjectExplorer.expandProject(projectExplorerTree, parent, teamDirt); + for (SWTBotTreeItem i : treeItem.getItems()) { + if (i.getText().contains(itemName)) { + return true; + } + } + return false; + } + + @Override + public void init(SWTBot bot) { + // no initialization + } + + @Override + public String getFailureMessage() { + return null; + } + +} diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProject.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProject.java new file mode 100644 index 0000000000..5276b9e5cf --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProject.java @@ -0,0 +1,161 @@ +/******************************************************************************* + * Copyright (c) 2010 Red Hat Inc. 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 + *******************************************************************************/ +package org.eclipse.linuxtools.changelog.ui.tests.utils; + +import static org.junit.Assert.assertNotNull; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; +import org.eclipse.linuxtools.changelog.ui.tests.swtbot.PrepareChangelogSWTBotTest; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.eclipse.finder.waits.Conditions; +import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; + +/** + * Subversion project abstraction for SWTBot tests. See + * {@link PrepareChangelogSWTBotTest#setUp()} for a usage example. + * + */ +public class SVNProject { + + private SWTWorkbenchBot bot; + private String repoURL; + private String projectName; + private IProject project; // available after checkout + + public SVNProject(SWTWorkbenchBot bot) { + this.bot = bot; + } + + /** + * @return the repoURL + */ + public String getRepoURL() { + return repoURL; + } + + /** + * @param repoURL the repoURL to set + */ + public SVNProject setRepoURL(String repoURL) { + this.repoURL = repoURL; + return this; + } + + /** + * @return the projectName + */ + public String getProjectName() { + return projectName; + } + + /** + * @param projectName the projectName to set + */ + public SVNProject setProjectName(String projectName) { + this.projectName = projectName; + return this; + } + + /** + * @return the project + */ + public IProject getProject() { + return project; + } + + /** + * @param project the project to set + */ + public SVNProject setProject(IProject project) { + this.project = project; + return this; + } + + /** + * Use File => Import => SVN to create a svn-backed project. + */ + public IProject checkoutProject() throws IllegalStateException { + if (repoURL == null || projectName == null) { + // need to have url and project set + throw new IllegalStateException(); + } + bot.menu("File").menu("Import...").click(); + + SWTBotShell shell = bot.shell("Import"); + shell.activate(); + bot.tree().expandNode("SVN").select("Checkout Projects from SVN"); + bot.button("Next >").click(); + + // create new repo + shell = bot.shell("Checkout from SVN"); + shell.activate(); + bot.button("Next >").click(); + + shell = bot.shell("Checkout from SVN"); + shell.activate(); + // Enter url + bot.comboBoxWithLabelInGroup("Url:", "Location").setText(repoURL); + bot.button("Next >").click(); + + // the next few operation can take quite a while, adjust + // timout accordingly. + long oldTimeout = SWTBotPreferences.TIMEOUT; + SWTBotPreferences.TIMEOUT = 3 * 5000; + + bot.waitUntil(Conditions.shellIsActive("Progress Information")); + shell = bot.shell("Progress Information"); + bot.waitUntil(Conditions.shellCloses(shell)); + bot.waitUntil(Conditions.shellIsActive("Checkout from SVN")); + shell = bot.shell("Checkout from SVN"); + bot.waitUntil(new TreeItemAppearsCondition(repoURL, projectName)); + SWTBotTreeItem projectTree = bot.tree().expandNode(repoURL); + projectTree.expandNode(projectName).select(); + bot.button("Finish").click(); + // Wait for import operation to finish + bot.waitUntil(Conditions.shellCloses(shell)); + bot.waitUntil(Conditions.shellIsActive("SVN Checkout")); + SWTBotShell svnCheckoutPopup = bot.shell("SVN Checkout"); + bot.waitUntil(Conditions.shellCloses(svnCheckoutPopup)); + // need a little delay + bot.waitUntil(new SVNProjectCreatedCondition(projectName)); + + // Set timout back what it was. + SWTBotPreferences.TIMEOUT = oldTimeout; + + // A quick sanity check + IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot(); + IProject changelogTestsProject = (IProject)wsRoot.findMember(new Path(projectName)); + assertNotNull(changelogTestsProject); + try { + changelogTestsProject.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + IResource manifest = changelogTestsProject.findMember(new Path("/META-INF/MANIFEST.MF")); + assertNotNull(manifest); + return changelogTestsProject; + } + + /** + * Discard the automatically created SVN repo URL from the list. + */ + public void discardRepositoryLocation() throws Exception { + if (repoURL == null) { // need to have repoURL set + throw new IllegalStateException(); + } + new SVNReporsitoriesView(bot).open().discardRepository(repoURL); + } +} diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProjectCreatedCondition.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProjectCreatedCondition.java new file mode 100644 index 0000000000..4267a60fd0 --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNProjectCreatedCondition.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2010 Red Hat Inc. 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 + *******************************************************************************/ +package org.eclipse.linuxtools.changelog.ui.tests.utils; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Path; +import org.eclipse.swtbot.swt.finder.SWTBot; +import org.eclipse.swtbot.swt.finder.waits.ICondition; + +/** + * Condition returns true if and only if a project with + * name <code>projectName</code> exists in the current + * workspace. + * + */ +public class SVNProjectCreatedCondition implements ICondition { + + private String projectName; + + public SVNProjectCreatedCondition(String projectName) { + this.projectName = projectName; + } + + @Override + public boolean test() throws Exception { + IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot(); + IProject project = (IProject)wsRoot.findMember(new Path(projectName)); + if (project == null) + return false; + else + return true; + } + + @Override + public void init(SWTBot bot) { + // no initialization; don't need bot + } + + @Override + public String getFailureMessage() { + return null; + } + +} diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNReporsitoriesView.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNReporsitoriesView.java new file mode 100644 index 0000000000..78d97ad73e --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/SVNReporsitoriesView.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2010 Red Hat Inc. 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 + *******************************************************************************/ +package org.eclipse.linuxtools.changelog.ui.tests.utils; + +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; + +/** + * SWTBot abstraction for the SVNRepositoriesView. + */ +public class SVNReporsitoriesView { + + private SWTWorkbenchBot bot; + + public SVNReporsitoriesView(SWTWorkbenchBot bot) { + this.bot = bot; + } + + /** + * Open the SVNRepositoriesView + */ + public SVNReporsitoriesView open() { + bot.menu("Window").menu("Show View").menu("Other...").click(); + SWTBotShell shell = bot.shell("Show View"); + shell.activate(); + bot.tree().expandNode("SVN").select("SVN Repositories"); + bot.button("OK").click(); + return this; + } + + /** + * Select repository + */ + public void discardRepository(String repo) throws Exception { + SWTBotView svnRepoView = bot.viewByTitle("SVN Repositories"); + svnRepoView.show(); + svnRepoView.setFocus(); + SWTBotTree tree = svnRepoView.bot().tree(); + tree.select(repo); + clickOnDiscardRepo(tree); // discard + } + + /** + * Context menu click helper. Click on "Add to existing sources". + * + * @param Tree of Package Explorer view. + * @throws Exception + */ + private void clickOnDiscardRepo(SWTBotTree svnReposTree) throws Exception { + String menuItem = "Discard location"; + ContextMenuHelper.clickContextMenu(svnReposTree, menuItem); + } +} diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TableAppearsCondition.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TableAppearsCondition.java new file mode 100644 index 0000000000..cf21995133 --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TableAppearsCondition.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2010 Red Hat Inc. 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 + *******************************************************************************/ +package org.eclipse.linuxtools.changelog.ui.tests.utils; + +import org.eclipse.swtbot.swt.finder.SWTBot; +import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; +import org.eclipse.swtbot.swt.finder.waits.ICondition; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; + +/** + * Condition for an appearing table (SWTBot tests). + * + */ +public class TableAppearsCondition implements ICondition { + + private SWTBot bot; + + @Override + public boolean test() throws Exception { + try { + SWTBotTable table = bot.table(); + // table available + // make sure rowcount > 0 + if (table.rowCount() > 0) { + return true; + } + } catch (WidgetNotFoundException e) { + // ignore + } + return false; + } + + @Override + public void init(SWTBot bot) { + this.bot = bot; + } + + @Override + public String getFailureMessage() { + return null; + } + +} diff --git a/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TreeItemAppearsCondition.java b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TreeItemAppearsCondition.java new file mode 100644 index 0000000000..0b67a3b593 --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.ui.tests/src/org/eclipse/linuxtools/changelog/ui/tests/utils/TreeItemAppearsCondition.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2010 Red Hat Inc. 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 + *******************************************************************************/ +package org.eclipse.linuxtools.changelog.ui.tests.utils; + +import org.eclipse.swtbot.swt.finder.SWTBot; +import org.eclipse.swtbot.swt.finder.waits.ICondition; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; + +/** + * Expands the <code>parent</code> node, and returns true if + * and only if tree items of the expanded parent node contains + * the item given by <code>treeItemName</code>. + * + */ +public class TreeItemAppearsCondition implements ICondition { + + private SWTBot bot; + private SWTBotTreeItem treeItem; + private String itemName; + private String parent; + + public TreeItemAppearsCondition(String parent, String treeItemName) { + this.itemName = treeItemName; + this.parent = parent; + } + + @Override + public boolean test() throws Exception { + for (SWTBotTreeItem i : treeItem.getItems()) { + if (i.getText().contains(itemName)) { + return true; + } + } + return false; + } + + @Override + public void init(SWTBot bot) { + this.bot = bot; + treeItem = this.bot.tree().expandNode(parent); + } + + @Override + public String getFailureMessage() { + return null; + } + +} |