diff options
11 files changed, 671 insertions, 0 deletions
diff --git a/plugins/org.yocto.sdk.ide.ui.tests/.classpath b/plugins/org.yocto.sdk.ide.ui.tests/.classpath new file mode 100644 index 00000000000..eca7bdba8f0 --- /dev/null +++ b/plugins/org.yocto.sdk.ide.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.8"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.yocto.sdk.ide.ui.tests/.project b/plugins/org.yocto.sdk.ide.ui.tests/.project new file mode 100644 index 00000000000..638f277f47f --- /dev/null +++ b/plugins/org.yocto.sdk.ide.ui.tests/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.yocto.sdk.ide.tests.ui</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/plugins/org.yocto.sdk.ide.ui.tests/.settings/org.eclipse.jdt.core.prefs b/plugins/org.yocto.sdk.ide.ui.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0c68a61dca8 --- /dev/null +++ b/plugins/org.yocto.sdk.ide.ui.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/plugins/org.yocto.sdk.ide.ui.tests/META-INF/MANIFEST.MF b/plugins/org.yocto.sdk.ide.ui.tests/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..1c19f7f88b4 --- /dev/null +++ b/plugins/org.yocto.sdk.ide.ui.tests/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %Plugin.name +Bundle-SymbolicName: org.yocto.crops.poky.tests.ui;singleton:=true +Bundle-Version: 0.1.0.qualifier +Bundle-ActivationPolicy: lazy +Bundle-Vendor: %Plugin.vendor +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.swtbot.go diff --git a/plugins/org.yocto.sdk.ide.ui.tests/OSGI-INF/l10n/bundle.properties b/plugins/org.yocto.sdk.ide.ui.tests/OSGI-INF/l10n/bundle.properties new file mode 100644 index 00000000000..06ab8f9847b --- /dev/null +++ b/plugins/org.yocto.sdk.ide.ui.tests/OSGI-INF/l10n/bundle.properties @@ -0,0 +1,12 @@ +############################################################################### +# Copyright (c) 2016 Intel Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Intel Corporation - initial API and implementation +############################################################################### +Plugin.name=Crops Poky Toolchain UI Tests +Plugin.vendor=Yocto Project
\ No newline at end of file diff --git a/plugins/org.yocto.sdk.ide.ui.tests/build.properties b/plugins/org.yocto.sdk.ide.ui.tests/build.properties new file mode 100644 index 00000000000..c58ea2178c3 --- /dev/null +++ b/plugins/org.yocto.sdk.ide.ui.tests/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/ diff --git a/plugins/org.yocto.sdk.ide.ui.tests/customTargets.xml b/plugins/org.yocto.sdk.ide.ui.tests/customTargets.xml new file mode 100644 index 00000000000..c250f9b180e --- /dev/null +++ b/plugins/org.yocto.sdk.ide.ui.tests/customTargets.xml @@ -0,0 +1,255 @@ +<project name="Build specific targets and properties" default="noDefault"> + + <!-- ===================================================================== --> + <!-- Run a given ${target} on all elements being built --> + <!-- Add on <ant> task for each top level element being built. --> + <!-- ===================================================================== --> + <available property="allElementsFile" file="${builder}/allElements.xml" value="${builder}/allElements.xml"/> + <property name="allElementsFile" location="${eclipse.pdebuild.templates}/headless-build/allElements.xml"/> + + <import file="${allElementsFile}" /> + <target name="allElements"> + <antcall target="allElementsDelegator" /> + </target> + + <!-- ===================================================================== --> + <!-- ===================================================================== --> + <target name="getBaseComponents" depends="checkLocalBase" unless="skipBase"> + <get src="${eclipseBaseURL}" dest="${buildDirectory}/../temp-base.zip" /> + <unzip dest="${base}" overwrite="true" src="${buildDirectory}/../temp-base.zip" /> + </target> + + <target name="checkLocalBase"> + <available file="${base}" property="skipBase" /> + </target> + + <!-- ===================================================================== --> + <!-- Check out map files from correct repository --> + <!-- Replace values for mapsCheckoutTag as desired. --> + <!-- ===================================================================== --> + <target name="getMapFiles" depends="checkLocalMaps" unless="skipMaps"> + <property name="mapsCheckoutTag" value="HEAD" /> + <cvs cvsRoot="${mapsRepo}" package="${mapsRoot}" dest="${buildDirectory}/maps" tag="${mapsCheckoutTag}" /> + </target> + + <target name="checkLocalMaps"> + <available property="skipMaps" file="${buildDirectory}/maps" /> + </target> + + <target name="tagMapFiles" if="tagMaps"> + <cvs dest="${buildDirectory}/maps/${mapsRoot}" command="tag ${mapsTagTag}" /> + </target> + + <!-- ===================================================================== --> + + <target name="clean" unless="noclean"> + <antcall target="allElements"> + <param name="target" value="cleanElement" /> + </antcall> + </target> + + <target name="gatherLogs"> + <mkdir dir="${buildDirectory}/${buildLabel}/compilelogs" /> + <antcall target="allElements"> + <param name="target" value="gatherLogs" /> + </antcall> + <unzip dest="${buildDirectory}/${buildLabel}/compilelogs" overwrite="true"> + <fileset dir="${buildDirectory}/features"> + <include name="**/*.log.zip" /> + </fileset> + </unzip> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do before setup --> + <!-- ===================================================================== --> + <target name="preSetup"> + <delete dir="${buildDirectory}/plugins"/> + <mkdir dir="${buildDirectory}/plugins"/> + <copy todir="${buildDirectory}/plugins" failonerror="true"> + <fileset dir="${otherSrcDirectory}/plugins"/> + </copy> + <delete dir="${buildDirectory}/features"/> + <copy todir="${buildDirectory}/features" failonerror="true" > + <fileset dir="${otherSrcDirectory}/features"/> + </copy> + <antcall target="prepareForP2" /> + </target> + + <target name="prepareForP2" if="p2.gathering"> + <copy file="${otherSrcDirectory}/features/org.yocto.sdk.site/site.xml" todir="${buildDirectory}" /> + <copy file="${otherSrcDirectory}/features/org.yocto.sdk.site/category.xml" todir="${buildDirectory}" /> + <xmlproperty file="${otherSrcDirectory}/features/org.yocto.sdk/feature.xml" /> + <replace file="${buildDirectory}/category.xml"> + <replacefilter token="@featureVersion@" value="${feature(version)}"/> + </replace> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do after setup but before starting the build proper --> + <!-- ===================================================================== --> + <target name="postSetup"> + <antcall target="getBaseComponents" /> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do before fetching the build elements --> + <!-- ===================================================================== --> + <target name="preFetch"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do after fetching the build elements --> + <!-- ===================================================================== --> + <target name="postFetch"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do before the repositories are being processed --> + <!-- ===================================================================== --> + <target name="preProcessRepos"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do after the repositories have been processed --> + <!-- ===================================================================== --> + <target name="postProcessRepos"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do before generating the build scripts. --> + <!-- ===================================================================== --> + <target name="preGenerate"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do after generating the build scripts. --> + <!-- ===================================================================== --> + <target name="postGenerate"> + <antcall target="clean" /> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do before running the build.xmls for the elements being built. --> + <!-- ===================================================================== --> + <target name="preProcess"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do after running the build.xmls for the elements being built. --> + <!-- ===================================================================== --> + <target name="postProcess"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do before running assemble. --> + <!-- ===================================================================== --> + <target name="preAssemble"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do after running assemble. --> + <!-- ===================================================================== --> + <target name="postAssemble"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do before running package. --> + <!-- ===================================================================== --> + <target name="prePackage"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do after running package. --> + <!-- ===================================================================== --> + <target name="postPackage"> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do after the build is done. --> + <!-- ===================================================================== --> + <target name="postBuild"> + <antcall target="gatherLogs" /> + <antcall target="updateSiteContent" /> + </target> + + <target name="updateSiteContent" if="p2.gathering"> + <property file="${buildDirectory}/finalFeaturesVersions.properties" /> + <copy file="${otherSrcDirectory}/features/org.yocto.sdk.site/site.xml" todir="${buildDirectory}" /> + <replace file="${buildDirectory}/site.xml"> + <replacefilter token="@SDKGenVersion@" value="${org.yocto.sdk}"/> + </replace> + <zip destfile="${buildDirectory}/${buildLabel}/org.yocto.sdk-${buildId}-group.group.group.zip" update="true"> + <zipfileset dir="${buildDirectory}"> + <include name="site.xml"/> + </zipfileset> + <zipfileset dir="${otherSrcDirectory}/features/org.yocto.sdk.site"> + <include name="index.html"/> + </zipfileset> + <zipfileset dir="${otherSrcDirectory}/features/org.yocto.sdk.site/web" prefix="web"/> + </zip> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do to test the build results --> + <!-- ===================================================================== --> + <target name="test"> + <property name="test-target" value="all" /> + <property name="test-classes" value="**/*Test.class" /> + <java classname="org.eclipse.equinox.launcher.Main" fork="true" failonerror="true" dir="${test-sandbox}"> + + <arg value="-Dos=${os}" /> + <arg value="-Dws=${ws}" /> + <arg value="-Darch=${arch}" /> + <arg value="-Dextra.jvm.options=${extra.jvm.options}" /> + + <!-- one each for each feature that is built --> + <arg value="-Dfeature.id=${feature.id}" /> + <arg value="-Dfeature.id.test=${feature.id.test}" /> + + <arg value="-Dall.buildId=${all.buildId}" /> + + <arg value="-Dbuild.base=${basedir}/target" /> + <arg value="-Dresults.dir=${basedir}/artifacts/tests" /> + + + <!-- properties containing the plugin directory name including version number --> + <arg value="-Dorg.yocto.sdk.ide.tests.ui=org.yocto.sdk.ide.tests.ui_${all.buildId}" /> + <!-- <arg value="-Danother.plugin.test=another.plugin.test_1.0.0" /> --> + + <arg value="-DbuildId=${eclipse.buildId}" /> + + <!-- pass in locations of any other plugins that may be needed for tests, see the "copy-eclipse" target above + <arg value="-Dmylyn.base=${mylyn.base}" /> + --> + + <arg value="-application" /> + <arg value="org.eclipse.ant.core.antRunner" /> + <arg value="-file" /> + <arg value="${test-sandbox}/test.xml" /> + <arg value="${test-target}" /> + <arg value="-Dtest-classes=${test-classes}" /> + + <jvmarg value="-Xmx512M" /> + <classpath> + <fileset dir="${eclipse-target}/plugins"> + <include name="org.eclipse.equinox.launcher_*.jar" /> + </fileset> + </classpath> + </java> + </target> + + <!-- ===================================================================== --> + <!-- Steps to do to publish the build results --> + <!-- ===================================================================== --> + <target name="publish"> + </target> + + <!-- ===================================================================== --> + <!-- Default target --> + <!-- ===================================================================== --> + <target name="noDefault"> + <echo message="You must specify a target when invoking this file" /> + </target> + +</project> diff --git a/plugins/org.yocto.sdk.ide.ui.tests/pom.xml b/plugins/org.yocto.sdk.ide.ui.tests/pom.xml new file mode 100644 index 00000000000..96ba9db278b --- /dev/null +++ b/plugins/org.yocto.sdk.ide.ui.tests/pom.xml @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.yocto.crops</groupId> + <artifactId>crops-parent</artifactId> + <version>0.3.0-SNAPSHOT</version> + <relativePath>../../../pom.xml</relativePath> + </parent> + + <version>0.1.0-SNAPSHOT</version> + <artifactId>org.yocto.crops.poky.tests.ui</artifactId> + <packaging>eclipse-test-plugin</packaging> + + <properties> + <tycho.test.jvmArgs>-Xmx800m</tycho.test.jvmArgs> + <tycho.surefire.timeout>900</tycho.surefire.timeout> + </properties> + + + <profiles> + <profile> + <!-- Ignore optional deps to swt.macosx --> + <id>ignore-mac-deps-on-other-os-and-skip-swtbot-tests</id> + <activation> + <os> + <family>!mac</family> + </os> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>target-platform-configuration</artifactId> + <configuration> + <dependency-resolution> + <optionalDependencies>ignore</optionalDependencies> + </dependency-resolution> + </configuration> + </plugin> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-compiler-plugin</artifactId> + <configuration> + <optionalDependencies>ignore</optionalDependencies> + </configuration> + </plugin> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-surefire-plugin</artifactId> + <version>${tycho-version}</version> + <configuration> + <!-- skipTests>true</skipTests --> + <!-- useUIHarness>true</useUIHarness --> + <useUIThread>false</useUIThread> + <!-- kill test JVM if tests take more than 10 minutes (600 seconds) + to finish --> + <forkedProcessTimeoutInSeconds>${tycho.surefire.timeout}</forkedProcessTimeoutInSeconds> + <argLine>${tycho.test.jvmArgs}</argLine> + <includes> + <include>**/AllIntegrationTests.class</include> + </includes> + <excludes> + <exclude>**/*SWTBotTest.class</exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>mac</id> + <activation> + <os> + <family>mac</family> + </os> + </activation> + <properties> + <!-- Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=388084 --> + <!-- THE FOLLOWING LINE MUST NOT BE BROKEN BY AUTOFORMATTING --> + <tycho.test.jvmArgs>-Xmx800m -XstartOnFirstThread</tycho.test.jvmArgs> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>target-platform-configuration</artifactId> + <configuration> + <environments> + <environment> + <os>macosx</os> + <ws>cocoa</ws> + <arch>x86_64</arch> + </environment> + </environments> + </configuration> + </plugin> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-surefire-plugin</artifactId> + <configuration> + <!-- skipTests>true</skipTests --> + <useUIHarness>true</useUIHarness> + <useUIThread>false</useUIThread> + <!-- kill test JVM if tests take more than 10 minutes (600 seconds) to + finish --> + <forkedProcessTimeoutInSeconds>${tycho.surefire.timeout}</forkedProcessTimeoutInSeconds> + <argLine>${tycho.test.jvmArgs}</argLine> + <!-- execute all tests on Mac --> + <includes> + <include>**/AllIntegrationTests.class</include> + </includes> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> diff --git a/plugins/org.yocto.sdk.ide.ui.tests/src/org/yocto/sdk/ide/tests/ui/AllIntegrationTests.java b/plugins/org.yocto.sdk.ide.ui.tests/src/org/yocto/sdk/ide/tests/ui/AllIntegrationTests.java new file mode 100644 index 00000000000..4b5cd633b4b --- /dev/null +++ b/plugins/org.yocto.sdk.ide.ui.tests/src/org/yocto/sdk/ide/tests/ui/AllIntegrationTests.java @@ -0,0 +1,11 @@ +package org.yocto.sdk.ide.tests.ui; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({ IntegrationTestNewCProject.class }) +public class AllIntegrationTests { + +} diff --git a/plugins/org.yocto.sdk.ide.ui.tests/src/org/yocto/sdk/ide/tests/ui/IntegrationTestNewCProject.java b/plugins/org.yocto.sdk.ide.ui.tests/src/org/yocto/sdk/ide/tests/ui/IntegrationTestNewCProject.java new file mode 100644 index 00000000000..b9b8ccfeebf --- /dev/null +++ b/plugins/org.yocto.sdk.ide.ui.tests/src/org/yocto/sdk/ide/tests/ui/IntegrationTestNewCProject.java @@ -0,0 +1,210 @@ +package org.yocto.sdk.ide.tests.ui; + +import static org.junit.Assert.assertTrue; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +/* FIXME: ALL strings should be internationalized */ + +@RunWith(SWTBotJunit4ClassRunner.class) +public class IntegrationTestNewCProject { + + private static SWTWorkbenchBot bot; + + /* Use unique project names for each type that is to be tested + * this is a simple way to make sure the projects can be created + * without trying (and failing) to clobber each other + */ + private static final String cProjName = "MyFirstTestProject"; //$NON-NLS-1$ + private static final String cHelloWorldProjName = "MyFirstHelloWorldTestProject"; //$NON-NLS-1$ + private static final String cAutotoolsProjName = "MyFirstAutotoolsTestProject"; //$NON-NLS-1$ + private static final String cGTKProjName = "MyFirstGTKTestProject"; //$NON-NLS-1$ + private static final String cppProjName = "MyFirstCPPTestProject"; //$NON-NLS-1$ + private static final String testAuthor = "Ima Tester"; //$NON-NLS-1$ + + + @BeforeClass + public static void beforeClass() throws Exception { + bot = new SWTWorkbenchBot(); + bot.viewByTitle("Welcome").close(); + bot.perspectiveByLabel("C/C++").activate(); + } + + /* TODO: need to set the Yocto Project preferences first */ + + /* java.lang.RuntimeException: java.lang.InterruptedException: New Project failure: Yocto Wizard Configuration Error: + * Specified Toolchain Root Location is empty. + * You need specify Toolchain Root Location before building any project. + * Do IDE-wide settings from Window > Preferences > Yocto Project SDK + * Or do Project-wide settings from Project > Change Yocto Project Settings. + */ + + /* Test standard C Project creation, to make sure CDT is installed and working */ + @Test + public void canCreateANewEmptyCProject() throws Exception { + bot.menu("File").menu("New").menu("Project...").click(); + + SWTBotShell shell = bot.shell("New Project"); + shell.activate(); + bot.tree().expandNode("C/C++").select("C Project"); + bot.button("Next >").click(); + + bot.textWithLabel("Project name:").setText(cProjName); + + bot.button("Finish").click(); + + assertProjectCreated(cProjName); + assertTrue("New Project dialog should not be active after project creation.", !shell.isActive()); + } + + @Test + public void canCreateANewANSICHelloWorldProject() throws Exception { + bot.menu("File").menu("New").menu("Project...").click(); + + SWTBotShell shell = bot.shell("New Project"); + shell.activate(); + bot.tree().expandNode("C/C++").select("C Project"); + bot.button("Next >").click(); + + bot.textWithLabel("Project name:").setText(cHelloWorldProjName); + bot.treeWithLabel("Project type:").expandNode("Executable").select("Hello World ANSI C Project"); + bot.button("Finish").click(); + assertProjectCreatedIsNotEmpty(cHelloWorldProjName); + assertTrue("New Project dialog should not be active after project creation.", !shell.isActive()); + } + + /* Yocto Project SDK specific tests */ + /* FIXME: D.R.Y. these next three methods should be abstracted/simplified */ + @Test + public void canCreateANewCAutotoolsProject() throws Exception { + bot.menu("File").menu("New").menu("Project...").click(); + + SWTBotShell shell = bot.shell("New Project"); + shell.activate(); + bot.tree().expandNode("C/C++").select("C Project"); + bot.button("Next >").click(); + + bot.tree().expandNode("Yocto Project SDK Autotools Project").select("Hello World ANSI C Autotools Project"); + bot.textWithLabel("Project name:").setText(cAutotoolsProjName); + bot.button("Next >").click(); + + bot.textWithLabel("Author").setText(testAuthor); + bot.button("Next >").click(); + + bot.button("Finish").click(); + + assertProjectCreatedIsNotEmpty(cAutotoolsProjName); + + try { + assertTrue("New Project dialog should not be active after project creation.", !shell.isActive()); + } finally { + // Allow testing to continue + shell.close(); + } + // TODO: should do something more interesting here, like build the project. + } + + @Test + public void canCreateANewGTKAutotoolsProject() throws Exception { + bot.menu("File").menu("New").menu("Project...").click(); + + SWTBotShell shell = bot.shell("New Project"); + shell.activate(); + bot.tree().expandNode("C/C++").select("C Project"); + bot.button("Next >").click(); + + bot.tree().expandNode("Yocto Project SDK Autotools Project").select("Hello World GTK C Autotools Project"); + bot.textWithLabel("Project name:").setText(cGTKProjName); + bot.button("Next >").click(); + + bot.textWithLabel("Author").setText(testAuthor); + bot.button("Next >").click(); + + bot.button("Finish").click(); + + assertProjectCreatedIsNotEmpty(cGTKProjName); + + try { + assertTrue("New Project dialog should not be active after project creation.", !shell.isActive()); + } finally { + // Allow testing to continue + shell.close(); + } + } + + @Test + public void canCreateANewCPPAutotoolsProject() throws Exception { + bot.menu("File").menu("New").menu("Project...").click(); + + SWTBotShell shell = bot.shell("New Project"); + shell.activate(); + bot.tree().expandNode("C/C++").select("C++ Project"); + bot.button("Next >").click(); + + bot.tree().expandNode("Yocto Project SDK Autotools Project").select("Hello World C++ Autotools Project"); + bot.textWithLabel("Project name:").setText(cppProjName); + bot.button("Next >").click(); + + bot.textWithLabel("Author").setText(testAuthor); + bot.button("Next >").click(); + + bot.button("Finish").click(); + + assertProjectCreatedIsNotEmpty(cppProjName); + + // FIXME: Need to fix template so that New Project "shell" (aka dialog) closes on its own + try { + assertTrue("New Project dialog should not be active after project creation.", !shell.isActive()); + } finally { + // Allow testing to continue + shell.close(); + } + } + + /* TODO need to add CMake projects */ + + /* Helper methods */ + private void assertProjectCreated(String projName) { + assertProjectCreated(projName, false); + } + + private void assertProjectCreated(String projName, boolean shouldBeNonEmpty) { + SWTBotView projectExplorerView = bot.viewByTitle("Project Explorer"); + projectExplorerView.show(); + Composite projectExplorerComposite = (Composite) projectExplorerView.getWidget(); + + Tree swtTree = (Tree) bot.widget(WidgetMatcherFactory.widgetOfType(Tree.class), projectExplorerComposite); + SWTBotTree tree = new SWTBotTree(swtTree); + // throws WidgetNotFoundException (WNFE) if the item does not exist + SWTBotTreeItem treeItem = tree.getTreeItem(projName).expand(); + if (shouldBeNonEmpty) { + assertTrue(projName + " expected to be non-empty", !treeItem.getNodes().isEmpty()); + } + } + + private void assertProjectCreatedIsNotEmpty(String projName) { + assertProjectCreated(projName, true); + + } + + @AfterClass + public static void sleep() { + bot.sleep(2000); + } + +} diff --git a/scripts/setup.sh b/scripts/setup.sh index 01d1631c771..8b527e6eec5 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -282,6 +282,11 @@ echo -e "\nPlease wait. Installing OSGI.COMPATIBILITY.PLUGINS.FEATURE.FEATURE.GR COMPAT_VER="1.0.0" update_feature_remote ${UPDATE_SITE} org.eclipse.osgi.compatibility.plugins.feature.feature.group ${COMPAT_VER} +#SWTBOT automated UI testing +echo -e "\nPlease wait. Installing SWTBOT features" +# VERSION="x.y.z" +# update_feature_remote ${MAIN_SITE} org.eclipse.swtbot.whatever.its.called ${VERSION} + echo -e "\nYour build environment is successfully created." echo -e "\nPlease execute the following command to build the plugins and their documentation." echo -e "\nThe build log will be stored at `pwd`/build.log." |