mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
Update Autotools SWTBot tests.
Change-Id: I830ca99f83548a5fc0e6fcfdeb26d00cd68e3060 Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/29608 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com>
This commit is contained in:
parent
0f355b1929
commit
cc2fe9086b
9 changed files with 884 additions and 1228 deletions
|
@ -3,27 +3,26 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: %bundleName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.autotools.ui.tests
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.autotools.ui.tests.Activator
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.swtbot.eclipse.core;bundle-version="2.0.0",
|
||||
org.eclipse.swtbot.eclipse.finder;bundle-version="2.0.0",
|
||||
org.eclipse.swtbot.junit4_x;bundle-version="2.0.0",
|
||||
org.eclipse.swtbot.swt.finder;bundle-version="2.0.0",
|
||||
org.junit;bundle-version="4.8.1",
|
||||
org.apache.log4j;bundle-version="1.2.13",
|
||||
org.eclipse.core.resources;bundle-version="3.5.1",
|
||||
org.eclipse.cdt.autotools.core;bundle-version="1.0.0",
|
||||
org.eclipse.cdt.autotools.ui;bundle-version="1.0.0",
|
||||
org.eclipse.cdt.core;bundle-version="5.1.1",
|
||||
org.eclipse.cdt.launch;bundle-version="6.0.0",
|
||||
org.eclipse.cdt.make.core;bundle-version="6.0.0",
|
||||
org.eclipse.cdt.make.ui;bundle-version="6.0.1",
|
||||
org.eclipse.cdt.managedbuilder.core;bundle-version="6.0.0",
|
||||
org.eclipse.cdt.managedbuilder.gnu.ui;bundle-version="5.0.100",
|
||||
org.eclipse.cdt.managedbuilder.ui;bundle-version="5.1.0",
|
||||
org.eclipse.cdt.ui;bundle-version="5.1.1"
|
||||
org.eclipse.swtbot.eclipse.core,
|
||||
org.eclipse.swtbot.eclipse.finder,
|
||||
org.eclipse.swtbot.junit4_x,
|
||||
org.eclipse.swtbot.swt.finder,
|
||||
org.eclipse.swtbot.go,
|
||||
org.apache.log4j,
|
||||
org.eclipse.core.resources,
|
||||
org.eclipse.cdt.autotools.core,
|
||||
org.eclipse.cdt.autotools.ui,
|
||||
org.eclipse.cdt.core,
|
||||
org.eclipse.cdt.launch,
|
||||
org.eclipse.cdt.make.core,
|
||||
org.eclipse.cdt.make.ui,
|
||||
org.eclipse.cdt.managedbuilder.core,
|
||||
org.eclipse.cdt.managedbuilder.gnu.ui,
|
||||
org.eclipse.cdt.managedbuilder.ui,
|
||||
org.eclipse.cdt.ui
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-Vendor: %provider
|
||||
|
|
50
build/org.eclipse.cdt.autotools.ui.tests/pom.xml
Normal file
50
build/org.eclipse.cdt.autotools.ui.tests/pom.xml
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2014, Red Hat, Inc.
|
||||
|
||||
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
|
||||
-->
|
||||
<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.eclipse.cdt</groupId>
|
||||
<artifactId>cdt-parent</artifactId>
|
||||
<version>8.4.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.autotools.ui.tests</artifactId>
|
||||
<packaging>eclipse-test-plugin</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
<artifactId>tycho-surefire-plugin</artifactId>
|
||||
<version>${tycho-version}</version>
|
||||
<configuration>
|
||||
<useUIHarness>true</useUIHarness>
|
||||
<useUIThread>false</useUIThread>
|
||||
<product>org.eclipse.platform.ide</product>
|
||||
<application>org.eclipse.ui.ide.workbench</application>
|
||||
<argLine>${base.ui.test.vmargs}</argLine>
|
||||
<includes>
|
||||
<include>**/AllTests.*</include>
|
||||
</includes>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>org.eclipse.platform.feature.group</artifactId>
|
||||
<type>p2-installable-unit</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,340 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Red Hat Inc.
|
||||
* 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:
|
||||
* Red Hat - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.autotools.ui.tests;
|
||||
|
||||
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
|
||||
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.inGroup;
|
||||
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
|
||||
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withRegex;
|
||||
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withStyle;
|
||||
import static org.eclipse.swtbot.swt.finder.waits.Conditions.waitForWidget;
|
||||
import static org.eclipse.swtbot.swt.finder.waits.Conditions.widgetIsEnabled;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectNature;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.jface.bindings.keys.KeyStroke;
|
||||
import org.eclipse.jface.bindings.keys.ParseException;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
import org.eclipse.swt.widgets.Widget;
|
||||
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
|
||||
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
|
||||
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
|
||||
import org.eclipse.swtbot.swt.finder.finders.ContextMenuHelper;
|
||||
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
|
||||
import org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory;
|
||||
import org.eclipse.swtbot.swt.finder.results.VoidResult;
|
||||
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
|
||||
import org.eclipse.swtbot.swt.finder.waits.Conditions;
|
||||
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.After;
|
||||
|
||||
public abstract class AbstractTest {
|
||||
protected static SWTWorkbenchBot bot;
|
||||
protected static String projectName;
|
||||
protected static SWTBotShell mainShell;
|
||||
protected static SWTBotView projectExplorer;
|
||||
|
||||
public static void init(String projectName) throws Exception {
|
||||
SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
|
||||
bot = new SWTWorkbenchBot();
|
||||
mainShell = null;
|
||||
for (int i = 0, attempts = 100; i < attempts; i++) {
|
||||
for (SWTBotShell shell : bot.shells()) {
|
||||
if (shell.getText().contains("Eclipse Platform")) {
|
||||
mainShell = shell;
|
||||
shell.setFocus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
assertNotNull(mainShell);
|
||||
// Close the Welcome view if it exists
|
||||
try {
|
||||
bot.viewByTitle("Welcome").close();
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
// Turn off automatic building by default
|
||||
clickMainMenu("Window", "Preferences");
|
||||
SWTBotShell shell = bot.shell("Preferences");
|
||||
shell.activate();
|
||||
bot.text().setText("Workspace");
|
||||
bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "General",
|
||||
"Workspace"));
|
||||
SWTBotCheckBox buildAuto = bot.checkBox("Build automatically");
|
||||
if (buildAuto != null && buildAuto.isChecked()) {
|
||||
buildAuto.click();
|
||||
}
|
||||
bot.button("Apply").click();
|
||||
// Ensure that the C/C++ perspective is chosen automatically
|
||||
// and doesn't require user intervention
|
||||
bot.text().setText("Perspectives");
|
||||
bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "General",
|
||||
"Perspectives"));
|
||||
clickRadioButtonInGroup("Always open",
|
||||
"Open the associated perspective when creating a new project");
|
||||
bot.button("OK").click();
|
||||
|
||||
AbstractTest.projectName = projectName;
|
||||
clickMainMenu("File", "New", "Project...");
|
||||
shell = bot.shell("New Project");
|
||||
shell.activate();
|
||||
bot.text().setText("C Project");
|
||||
bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "C/C++",
|
||||
"C Project"));
|
||||
bot.button("Next >").click();
|
||||
|
||||
bot.textWithLabel("Project name:").setText(projectName);
|
||||
bot.tree().expandNode("GNU Autotools")
|
||||
.select("Hello World ANSI C Autotools Project");
|
||||
bot.button("Finish").click();
|
||||
bot.waitUntil(Conditions.shellCloses(shell));
|
||||
|
||||
IProjectNature nature = checkProject().getNature(
|
||||
"org.eclipse.cdt.autotools.core.autotoolsNatureV2");
|
||||
assertTrue(nature != null);
|
||||
|
||||
projectExplorer = bot.viewByTitle("Project Explorer");
|
||||
}
|
||||
|
||||
public static class NodeAvailableAndSelect extends DefaultCondition {
|
||||
|
||||
private SWTBotTree tree;
|
||||
private String parent;
|
||||
private String node;
|
||||
|
||||
/**
|
||||
* Wait for a tree node (with a known parent) to become visible, and
|
||||
* select it when it does. Note that this wait condition should only be
|
||||
* used after having made an attempt to reveal the node.
|
||||
*
|
||||
* @param tree
|
||||
* The SWTBotTree that contains the node to select.
|
||||
* @param parent
|
||||
* The text of the parent node that contains the node to
|
||||
* select.
|
||||
* @param node
|
||||
* The text of the node to select.
|
||||
*/
|
||||
public NodeAvailableAndSelect(SWTBotTree tree, String parent,
|
||||
String node) {
|
||||
this.tree = tree;
|
||||
this.node = node;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test() {
|
||||
try {
|
||||
SWTBotTreeItem parentNode = tree.getTreeItem(parent);
|
||||
parentNode.getNode(node).select();
|
||||
return true;
|
||||
} catch (WidgetNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFailureMessage() {
|
||||
return "Timed out waiting for " + node; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter the project folder so as to avoid expanding trees later
|
||||
*/
|
||||
public static void enterProjectFolder() {
|
||||
projectExplorer.setFocus();
|
||||
projectExplorer.bot().tree().select(projectName).contextMenu("Go Into")
|
||||
.click();
|
||||
bot.waitUntil(waitForWidget(WidgetMatcherFactory.withText(projectName),
|
||||
projectExplorer.getWidget()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit from the project tree.
|
||||
*/
|
||||
public static void exitProjectFolder() {
|
||||
projectExplorer.setFocus();
|
||||
SWTBotToolbarButton forwardButton;
|
||||
try {
|
||||
forwardButton = projectExplorer.toolbarPushButton("Forward");
|
||||
} catch (WidgetNotFoundException e) {
|
||||
// If the "Forward" button is not found, already at the top level.
|
||||
return;
|
||||
}
|
||||
SWTBotToolbarButton backButton = projectExplorer
|
||||
.toolbarPushButton("Back to Workspace");
|
||||
if (backButton.isEnabled()) {
|
||||
backButton.click();
|
||||
bot.waitUntil(widgetIsEnabled(forwardButton));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects a radio button with the given <code>mnemonicText</code> in a
|
||||
* group with the given label <inGroup>, while also deselecting whatever
|
||||
* other radio button in the group that is already selected. Workaround for
|
||||
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=344484
|
||||
*/
|
||||
public static void clickRadioButtonInGroup(String mnemonicText,
|
||||
final String inGroup) {
|
||||
UIThreadRunnable.syncExec(new VoidResult() {
|
||||
@Override
|
||||
public void run() {
|
||||
@SuppressWarnings("unchecked")
|
||||
Matcher<Widget> matcher = allOf(inGroup(inGroup),
|
||||
widgetOfType(Button.class),
|
||||
withStyle(SWT.RADIO, "SWT.RADIO"));
|
||||
int i = 0;
|
||||
while (true) {
|
||||
Button b;
|
||||
try {
|
||||
b = (Button) bot.widget(matcher, i++);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
return;
|
||||
}
|
||||
if (b.getSelection()) {
|
||||
b.setSelection(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
bot.radioInGroup(mnemonicText, inGroup).click();
|
||||
}
|
||||
|
||||
public static void clickContextMenu(AbstractSWTBot<? extends Control> bot,
|
||||
String... texts) {
|
||||
new SWTBotMenu(ContextMenuHelper.contextMenu(bot, texts)).click();
|
||||
}
|
||||
|
||||
public static void clickVolatileContextMenu(
|
||||
AbstractSWTBot<? extends Control> bot, String... texts) {
|
||||
int tries = 0;
|
||||
final int maxTries = 2;
|
||||
while (true) {
|
||||
try {
|
||||
clickContextMenu(bot, texts);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
if (++tries > maxTries) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void clickProjectContextMenu(String... texts) {
|
||||
clickVolatileContextMenu(bot.viewByTitle("Project Explorer").bot()
|
||||
.tree().select(projectName), texts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Click an item from the main Eclipse menu, with a guarantee that the main
|
||||
* shell will be in focus.
|
||||
*
|
||||
* @param items
|
||||
*/
|
||||
public static void clickMainMenu(String... items) {
|
||||
if (items.length == 0) {
|
||||
return;
|
||||
}
|
||||
mainShell.setFocus();
|
||||
SWTBotMenu menu = bot.menu(items[0]);
|
||||
for (int i = 1; i < items.length; i++) {
|
||||
menu = menu.menu(items[i]);
|
||||
}
|
||||
menu.click();
|
||||
}
|
||||
|
||||
public static SWTBotShell openProperties(String parentCategory,
|
||||
String category) {
|
||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
||||
"Properties");
|
||||
SWTBotShell shell = bot.shell("Properties for " + projectName);
|
||||
shell.activate();
|
||||
bot.text().setText(category);
|
||||
bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), parentCategory,
|
||||
category));
|
||||
shell.activate();
|
||||
return shell;
|
||||
}
|
||||
|
||||
public static IProject checkProject() {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
assertTrue(workspace != null);
|
||||
IWorkspaceRoot root = workspace.getRoot();
|
||||
assertTrue(root != null);
|
||||
IProject project = root.getProject(projectName);
|
||||
assertTrue(project != null);
|
||||
return project;
|
||||
}
|
||||
|
||||
public static SWTBotView viewConsole(String consoleType) {
|
||||
SWTBotView view = bot.viewByPartName("Console");
|
||||
view.setFocus();
|
||||
SWTBotToolbarDropDownButton b = view
|
||||
.toolbarDropDownButton("Display Selected Console");
|
||||
org.hamcrest.Matcher<MenuItem> withRegex = withRegex(".*" + consoleType
|
||||
+ ".*");
|
||||
bot.shell("C/C++ - Eclipse Platform").activate();
|
||||
b.menuItem(withRegex).click();
|
||||
try {
|
||||
b.pressShortcut(KeyStroke.getInstance("ESC"));
|
||||
} catch (ParseException e) {
|
||||
}
|
||||
view.setFocus();
|
||||
return view;
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanUp() {
|
||||
exitProjectFolder();
|
||||
SWTBotShell[] shells = bot.shells();
|
||||
for (final SWTBotShell shell : shells) {
|
||||
if (!shell.equals(mainShell)) {
|
||||
String shellTitle = shell.getText();
|
||||
if (shellTitle.length() > 0
|
||||
&& !shellTitle.startsWith("Quick Access")) {
|
||||
UIThreadRunnable.syncExec(new VoidResult() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (shell.widget.getParent() != null
|
||||
&& !shell.isOpen()) {
|
||||
shell.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
bot.closeAllEditors();
|
||||
mainShell.activate();
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Red Hat Inc..
|
||||
* 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:
|
||||
* Red Hat Incorporated - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.autotools.ui.tests;
|
||||
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
*/
|
||||
public class Activator extends AbstractUIPlugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "org.eclipse.cdt.autotools.ui.tests";
|
||||
|
||||
// The shared instance
|
||||
private static Activator plugin;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public Activator() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
plugin = null;
|
||||
super.stop(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance
|
||||
*
|
||||
* @return the shared instance
|
||||
*/
|
||||
public static Activator getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
}
|
|
@ -18,7 +18,7 @@ import org.junit.runners.Suite;
|
|||
SetConfigurationParameter.class,
|
||||
TestToolActions.class,
|
||||
TestEnvironmentVars.class,
|
||||
TestMakeTargets.class,
|
||||
TestMakeTargets.class
|
||||
})
|
||||
public class AllTests {
|
||||
// needed for this class to compile
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.autotools.ui.tests;
|
||||
|
||||
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withRegex;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
@ -23,27 +22,17 @@ import java.util.regex.Pattern;
|
|||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.eclipse.cdt.ui.newui.UIMessages;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectNature;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.jface.bindings.keys.KeyStroke;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
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.utils.SWTBotPreferences;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
|
||||
import org.eclipse.swtbot.swt.finder.waits.Conditions;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -54,96 +43,74 @@ import org.w3c.dom.Node;
|
|||
import org.w3c.dom.NodeList;
|
||||
|
||||
@RunWith(SWTBotJunit4ClassRunner.class)
|
||||
public class SetConfigurationParameter {
|
||||
|
||||
private static SWTWorkbenchBot bot;
|
||||
public class SetConfigurationParameter extends AbstractTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
|
||||
bot = new SWTWorkbenchBot();
|
||||
// Close the Welcome view if it exists
|
||||
try {
|
||||
bot.viewByTitle("Welcome").close();
|
||||
// Turn off automatic building by default
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
// Turn off automatic building by default
|
||||
bot.menu("Window").menu("Preferences").click();
|
||||
SWTBotShell shell = bot.shell("Preferences");
|
||||
shell.activate();
|
||||
bot.tree().expandNode("General").select("Workspace");
|
||||
SWTBotCheckBox buildAuto = bot.checkBox("Build automatically");
|
||||
if (buildAuto != null && buildAuto.isChecked())
|
||||
buildAuto.click();
|
||||
bot.button("Apply").click();
|
||||
// Ensure that the C/C++ perspective is chosen automatically
|
||||
// and doesn't require user intervention
|
||||
bot.tree().expandNode("General").select("Perspectives");
|
||||
SWTBotRadio radio = bot.radio("Always open");
|
||||
if (radio != null && !radio.isSelected())
|
||||
radio.click();
|
||||
bot.button("OK").click();
|
||||
AbstractTest.init("GnuProject0");
|
||||
initConfigParm();
|
||||
}
|
||||
|
||||
@Test
|
||||
// Verify we can create a sample Autotools project using the New C Project UI
|
||||
public void canCreateANewAutotoolsProject() 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("GnuProject0");
|
||||
bot.tree().expandNode("GNU Autotools").select("Hello World ANSI C Autotools Project");
|
||||
|
||||
bot.button("Finish").click();
|
||||
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
assertTrue(workspace != null);
|
||||
IWorkspaceRoot root = workspace.getRoot();
|
||||
assertTrue(root != null);
|
||||
IProject project = root.getProject("GnuProject0");
|
||||
assertTrue(project != null);
|
||||
IProjectNature nature = project.getNature("org.eclipse.cdt.autotools.core.autotoolsNatureV2");
|
||||
assertTrue(nature != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
// Verify we can set a configuration parameter and that it is recorded in
|
||||
// the .autotools file for the project
|
||||
public void canSetConfigParm() throws Exception {
|
||||
SWTBotView view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject0");
|
||||
bot.menu("Project", 1).menu("Properties").click();
|
||||
SWTBotShell shell = bot.shell("Properties for GnuProject0");
|
||||
shell.activate();
|
||||
bot.tree().expandNode("Autotools").select("Configure Settings");
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||
// Set the configure parameters to be --enable-jeff via user-defined options
|
||||
|
||||
// Prepare initial settings that will be tested.
|
||||
private static void initConfigParm() {
|
||||
// Set the configure parameters to be --enable-jeff via user-defined
|
||||
// options
|
||||
SWTBotShell shell = openProperties("Autotools", "Configure Settings");
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
||||
.select("Advanced");
|
||||
SWTBotText text = bot.textWithLabel("Additional command-line options");
|
||||
text.typeText("--enable-jeff");
|
||||
bot.button("OK").click();
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
assertTrue(workspace != null);
|
||||
IWorkspaceRoot root = workspace.getRoot();
|
||||
assertTrue(root != null);
|
||||
IProject project = root.getProject("GnuProject0");
|
||||
bot.waitUntil(Conditions.shellCloses(shell), 120000);
|
||||
|
||||
// Create new build configurations that will be used throughout tests
|
||||
projectExplorer.bot().tree().select(projectName);
|
||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
||||
"Build Configurations", "Manage...");
|
||||
shell = bot.shell(projectName + ": Manage Configurations");
|
||||
shell.activate();
|
||||
bot.button("New...").click();
|
||||
shell = bot.shell("Create New Configuration");
|
||||
shell.activate();
|
||||
SWTBotText t = bot.textWithLabel("Name:");
|
||||
t.setText("debug");
|
||||
AbstractTest.clickRadioButtonInGroup("Existing configuration",
|
||||
"Copy settings from");
|
||||
bot.button("OK").click();
|
||||
shell = bot.shell(projectName + ": Manage Configurations");
|
||||
shell.activate();
|
||||
bot.button("New...").click();
|
||||
shell = bot.shell("Create New Configuration");
|
||||
shell.activate();
|
||||
t = bot.textWithLabel("Name:");
|
||||
t.setText("default");
|
||||
AbstractTest.clickRadioButtonInGroup("Default configuration",
|
||||
"Copy settings from");
|
||||
bot.button("OK").click();
|
||||
shell = bot.shell(projectName + ": Manage Configurations");
|
||||
shell.activate();
|
||||
bot.button("OK").click();
|
||||
bot.waitUntil(Conditions.shellCloses(shell));
|
||||
}
|
||||
|
||||
// Verify we can set a configuration parameter and that it is recorded in
|
||||
// the .autotools file for the project
|
||||
@Test
|
||||
public void canSetConfigParm() throws Exception {
|
||||
IProject project = checkProject();
|
||||
assertTrue(project != null);
|
||||
IPath path = project.getLocation();
|
||||
path = path.append(".autotools");
|
||||
File f = new File(path.toOSString());
|
||||
assertTrue(f.exists());
|
||||
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
Document d = db.parse(f);
|
||||
Element e = d.getDocumentElement();
|
||||
// Get the stored configuration data
|
||||
NodeList cfgs = e.getElementsByTagName("configuration"); // $NON-NLS-1$
|
||||
assertEquals(1, cfgs.getLength());
|
||||
assertTrue(cfgs.getLength() > 0);
|
||||
Node n = cfgs.item(0);
|
||||
NodeList l = n.getChildNodes();
|
||||
// Verify user field in .autotools file is set to --enable-jeff
|
||||
|
@ -167,198 +134,183 @@ public class SetConfigurationParameter {
|
|||
assertTrue(foundUser);
|
||||
}
|
||||
|
||||
@Test
|
||||
// Verify we can build the project with a configuration parameter and that
|
||||
// the configuration parameter can be found in the config.status file.
|
||||
@Test
|
||||
public void canBuildWithConfigParm() throws Exception {
|
||||
SWTBotView view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject0");
|
||||
bot.menu("Project", 1).menu("Build Project").click();
|
||||
projectExplorer.bot().tree().select(projectName);
|
||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
||||
"Build Project");
|
||||
|
||||
// Wait until the project is built
|
||||
SWTBotShell shell = bot.shell("Build Project");
|
||||
bot.waitUntil(Conditions.shellCloses(shell), 120000);
|
||||
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
assertTrue(workspace != null);
|
||||
IWorkspaceRoot root = workspace.getRoot();
|
||||
assertTrue(root != null);
|
||||
IProject project = root.getProject("GnuProject0");
|
||||
IProject project = root.getProject(projectName);
|
||||
assertTrue(project != null);
|
||||
IPath path = project.getLocation();
|
||||
// We need to wait until the a.out file is created so
|
||||
// sleep a bit and look for it...give up after 120 seconds
|
||||
for (int i = 0; i < 240; ++i) {
|
||||
bot.sleep(500);
|
||||
File f = new File(path.append("src/a.out").toOSString());
|
||||
if (f.exists())
|
||||
break;
|
||||
}
|
||||
File f = new File(path.append("config.status").toOSString());
|
||||
File f = new File(path.append("src/a.out").toOSString());
|
||||
assertTrue(f.exists());
|
||||
BufferedReader r = new BufferedReader(new FileReader(f));
|
||||
int ch;
|
||||
boolean optionFound = false;
|
||||
// Read config.status and look for the string --enable-jeff
|
||||
// which is a simple verification that the option was used in the
|
||||
// configure step.
|
||||
while ((ch = r.read()) != -1) {
|
||||
if (ch == '-') {
|
||||
char[] buf = new char[12];
|
||||
r.mark(100);
|
||||
int count = r.read(buf);
|
||||
if (count < 12)
|
||||
break;
|
||||
String s = new String(buf);
|
||||
if (s.equals("-enable-jeff")) {
|
||||
optionFound = true;
|
||||
break;
|
||||
} else {
|
||||
r.reset();
|
||||
f = new File(path.append("config.status").toOSString());
|
||||
assertTrue(f.exists());
|
||||
|
||||
try (BufferedReader r = new BufferedReader(new FileReader(f))) {
|
||||
int ch;
|
||||
boolean optionFound = false;
|
||||
// Read config.status and look for the string --enable-jeff
|
||||
// which is a simple verification that the option was used in the
|
||||
// configure step.
|
||||
while ((ch = r.read()) != -1) {
|
||||
if (ch == '-') {
|
||||
char[] buf = new char[12];
|
||||
r.mark(100);
|
||||
int count = r.read(buf);
|
||||
if (count < 12) {
|
||||
break;
|
||||
}
|
||||
String s = new String(buf);
|
||||
if (s.equals("-enable-jeff")) {
|
||||
optionFound = true;
|
||||
break;
|
||||
} else {
|
||||
r.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
assertTrue(optionFound);
|
||||
}
|
||||
assertTrue(optionFound);
|
||||
view = bot.viewByTitle("Console");
|
||||
view.setFocus();
|
||||
SWTBotToolbarDropDownButton b = bot.toolbarDropDownButtonWithTooltip("Display Selected Console");
|
||||
org.hamcrest.Matcher<MenuItem> withRegex = withRegex(".*Configure.*");
|
||||
b.menuItem(withRegex).click();
|
||||
b.pressShortcut(KeyStroke.getInstance("ESC"));
|
||||
String output = view.bot().styledText().getText();
|
||||
|
||||
String output = viewConsole("Configure").bot().styledText().getText();
|
||||
// Verify we got some help output to the console
|
||||
Pattern p = Pattern.compile(".*WARNING:.*unrecognized.*--enable-jeff.*", Pattern.DOTALL);
|
||||
Pattern p = Pattern.compile(
|
||||
".*WARNING:.*unrecognized.*--enable-jeff.*", Pattern.DOTALL);
|
||||
Matcher m = p.matcher(output);
|
||||
assertTrue(m.matches());
|
||||
|
||||
// Verify that if we build again, we don't reconfigure.
|
||||
// Verifies fix for bug: #308261
|
||||
long oldDate = f.lastModified();
|
||||
view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject0");
|
||||
bot.menu("Project", 1).menu("Build Project").click();
|
||||
projectExplorer.bot().tree().select(projectName);
|
||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
||||
"Build Project");
|
||||
path = project.getLocation();
|
||||
// We need to wait until the a.out file is created so
|
||||
// sleep a bit and look for it...give up after 120 seconds
|
||||
for (int i = 0; i < 240; ++i) {
|
||||
bot.sleep(500);
|
||||
File tmp = new File(path.append("src/a.out").toOSString());
|
||||
if (tmp.exists())
|
||||
f = new File(path.append("src/a.out").toOSString());
|
||||
if (f.exists()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertTrue(f.exists());
|
||||
f = new File(path.append("config.status").toOSString());
|
||||
assertTrue(f.exists());
|
||||
long newDate = f.lastModified();
|
||||
assertEquals(newDate, oldDate);
|
||||
}
|
||||
|
||||
@Test
|
||||
// Verify a new configuration will copy the configuration parameters
|
||||
// of its base configuration.
|
||||
@Test
|
||||
public void newConfigCopiesParms() throws Exception {
|
||||
SWTBotView view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject0");
|
||||
bot.menu("Project", 1).menu("Build Configurations").menu("Manage...").click();
|
||||
SWTBotShell shell = bot.shell("GnuProject0: Manage Configurations");
|
||||
projectExplorer.bot().tree().select(projectName);
|
||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
||||
"Build Configurations", "Manage...");
|
||||
SWTBotShell shell = bot.shell(projectName + ": Manage Configurations");
|
||||
shell.activate();
|
||||
bot.button("New...").click();
|
||||
shell = bot.shell("Create New Configuration");
|
||||
shell.activate();
|
||||
SWTBotText t = bot.textWithLabel("Name:");
|
||||
t.typeText("debug");
|
||||
SWTBotRadio radio = bot.radio("Existing configuration");
|
||||
if (!radio.isSelected())
|
||||
radio.click();
|
||||
bot.button("OK").click();
|
||||
shell = bot.shell("GnuProject0: Manage Configurations");
|
||||
shell.activate();
|
||||
bot.button("New...").click();
|
||||
shell = bot.shell("Create New Configuration");
|
||||
shell.activate();
|
||||
t = bot.textWithLabel("Name:");
|
||||
t.typeText("default");
|
||||
radio = bot.radio("Default configuration");
|
||||
if (!radio.isSelected())
|
||||
radio.click();
|
||||
bot.button("OK").click();
|
||||
shell = bot.shell("GnuProject0: Manage Configurations");
|
||||
shell = bot.shell(projectName + ": Manage Configurations");
|
||||
shell.activate();
|
||||
SWTBotTable table = bot.table();
|
||||
assertTrue(table.containsItem("debug"));
|
||||
table.getTableItem("debug").select();
|
||||
bot.button("Set Active").click();
|
||||
bot.button("OK").click();
|
||||
// Verify the debug configuration is active and has a user parameter: --enable-jeff
|
||||
view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject0");
|
||||
bot.menu("Project", 1).menu("Properties").click();
|
||||
shell = bot.shell("Properties for GnuProject0");
|
||||
shell.activate();
|
||||
bot.tree().expandNode("Autotools").select("Configure Settings");
|
||||
SWTBotCombo configs = bot.comboBoxWithLabel(UIMessages.getString("AbstractPage.6"));
|
||||
// Verify the debug configuration is active and has a user parameter:
|
||||
// --enable-jeff
|
||||
openProperties("Autotools", "Configure Settings");
|
||||
SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: ");
|
||||
configs.setFocus();
|
||||
String[] items = configs.items();
|
||||
for (int i = 0; i < items.length; ++i) {
|
||||
if (items[i].contains("debug") && items[i].contains("Active"))
|
||||
if (items[i].contains("debug") && items[i].contains("Active")) {
|
||||
configs.setSelection(i);
|
||||
}
|
||||
}
|
||||
assertTrue(configs.getText().contains("debug"));
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
||||
.select("Advanced");
|
||||
SWTBotText text = bot.textWithLabel("Additional command-line options");
|
||||
String val = text.getText();
|
||||
assertEquals(val, "--enable-jeff");
|
||||
assertEquals("--enable-jeff", val);
|
||||
// Verify that the build directory for the new configuration has been
|
||||
// switched to build-debug
|
||||
bot.tree().expandNode("C/C++ Build").select();
|
||||
bot.tree().select("C/C++ Build");
|
||||
String buildDir = bot.textWithLabel("Build directory:").getText();
|
||||
assertTrue(buildDir.endsWith("build-debug"));
|
||||
// Verify the default configuration has no user setting
|
||||
bot.tree().expandNode("Autotools").select("Configure Settings");
|
||||
configs = bot.comboBoxWithLabel(UIMessages.getString("AbstractPage.6"));
|
||||
configs = bot.comboBoxWithLabel("Configuration: ");
|
||||
configs.setSelection("default");
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
||||
.select("Advanced");
|
||||
text = bot.textWithLabel("Additional command-line options");
|
||||
val = text.getText();
|
||||
assertEquals(val, "");
|
||||
assertEquals("", val);
|
||||
bot.button("OK").click();
|
||||
// Build the project again and verify we get a build-debug directory
|
||||
view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject0");
|
||||
bot.menu("Project", 1).menu("Build Project").click();
|
||||
projectExplorer.bot().tree().select(projectName);
|
||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
||||
"Build Project");
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
assertTrue(workspace != null);
|
||||
IWorkspaceRoot root = workspace.getRoot();
|
||||
assertTrue(root != null);
|
||||
IProject project = root.getProject("GnuProject0");
|
||||
IProject project = root.getProject(projectName);
|
||||
assertTrue(project != null);
|
||||
IPath path = project.getLocation();
|
||||
// We need to wait until the config.status file is created so
|
||||
// sleep a bit and look for it...give up after 20 seconds
|
||||
File f = null;
|
||||
for (int i = 0; i < 40; ++i) {
|
||||
bot.sleep(500);
|
||||
File f = new File(path.append("build-debug/src/a.out").toOSString());
|
||||
if (f.exists())
|
||||
f = new File(path.append("build-debug/src/a.out").toOSString());
|
||||
if (f.exists()) {
|
||||
break;
|
||||
}
|
||||
File f = new File(path.append("build-debug/config.status").toOSString());
|
||||
assertTrue(f.exists());
|
||||
BufferedReader r = new BufferedReader(new FileReader(f));
|
||||
int ch;
|
||||
boolean optionFound = false;
|
||||
// Read config.status and look for the string --enable-jeff
|
||||
// which is a simple verification that the option was used in the
|
||||
// configure step.
|
||||
while ((ch = r.read()) != -1) {
|
||||
if (ch == '-') {
|
||||
char[] buf = new char[12];
|
||||
r.mark(100);
|
||||
int count = r.read(buf);
|
||||
if (count < 12)
|
||||
break;
|
||||
String s = new String(buf);
|
||||
if (s.equals("-enable-jeff")) {
|
||||
optionFound = true;
|
||||
break;
|
||||
} else {
|
||||
r.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
assertTrue(optionFound);
|
||||
assertTrue(f.exists());
|
||||
f = new File(path.append("build-debug/config.status").toOSString());
|
||||
assertTrue(f.exists());
|
||||
try (BufferedReader r = new BufferedReader(new FileReader(f))) {
|
||||
int ch;
|
||||
boolean optionFound = false;
|
||||
// Read config.status and look for the string --enable-jeff
|
||||
// which is a simple verification that the option was used in the
|
||||
// configure step.
|
||||
while ((ch = r.read()) != -1) {
|
||||
if (ch == '-') {
|
||||
char[] buf = new char[12];
|
||||
r.mark(100);
|
||||
int count = r.read(buf);
|
||||
if (count < 12) {
|
||||
break;
|
||||
}
|
||||
String s = new String(buf);
|
||||
if (s.equals("-enable-jeff")) {
|
||||
optionFound = true;
|
||||
break;
|
||||
} else {
|
||||
r.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
assertTrue(optionFound);
|
||||
}
|
||||
// Verify we cleaned out the top-level build directory (i.e. that there
|
||||
// is no config.status there anymore).
|
||||
path = project.getLocation().append("config.status");
|
||||
|
@ -378,7 +330,8 @@ public class SetConfigurationParameter {
|
|||
for (int x = 0; x < cfgs.getLength(); ++x) {
|
||||
Node n = cfgs.item(x);
|
||||
NodeList l = n.getChildNodes();
|
||||
// Verify two of the user fields in .autotools file are set to --enable-jeff
|
||||
// Verify two of the user fields in .autotools file are set to
|
||||
// --enable-jeff
|
||||
for (int y = 0; y < l.getLength(); ++y) {
|
||||
Node child = l.item(y);
|
||||
if (child.getNodeName().equals("option")) { // $NON-NLS-1$
|
||||
|
@ -390,65 +343,54 @@ public class SetConfigurationParameter {
|
|||
String id = idNode.getNodeValue();
|
||||
String value = valueNode.getNodeValue();
|
||||
if (id.equals("user")) {
|
||||
if (value.equals("--enable-jeff"))
|
||||
if (value.equals("--enable-jeff")) {
|
||||
++foundUser;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assertEquals(foundUser, 2);
|
||||
assertEquals(2, foundUser);
|
||||
|
||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
||||
"Build Configurations", "Manage...");
|
||||
shell = bot.shell(projectName + ": Manage Configurations");
|
||||
shell.activate();
|
||||
table = bot.table();
|
||||
assertTrue(table.containsItem("Build (GNU)"));
|
||||
table.getTableItem("Build (GNU)").select();
|
||||
bot.button("Set Active").click();
|
||||
bot.button("OK").click();
|
||||
bot.waitUntil(Conditions.shellCloses(shell));
|
||||
}
|
||||
|
||||
@Test
|
||||
// Verify we can do a double rename of configurations, renaming one configuration to
|
||||
// Verify we can do a double rename of configurations, renaming one
|
||||
// configuration to
|
||||
// another and then cancel without changing configuration settings.
|
||||
@Test
|
||||
public void doubleRenameCancel() throws Exception {
|
||||
SWTBotView view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject0");
|
||||
bot.menu("Project", 1).menu("Properties").click();
|
||||
SWTBotShell shell = bot.shell("Properties for GnuProject0");
|
||||
shell.activate();
|
||||
bot.tree().expandNode("Autotools").select("Configure Settings");
|
||||
SWTBotCombo configs = bot.comboBoxWithLabel(UIMessages.getString("AbstractPage.6"));
|
||||
assertTrue(configs.getText().contains("debug"));
|
||||
openProperties("Autotools", "Configure Settings");
|
||||
SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: ");
|
||||
bot.button("Manage Configurations...").click();
|
||||
shell = bot.shell("GnuProject0: Manage Configurations");
|
||||
shell.activate();
|
||||
bot.table().select("debug");
|
||||
// Rename "debug" to "release" and rename "default" to "debug".
|
||||
// The settings should follow the rename operation.
|
||||
bot.button("Rename...").click();
|
||||
shell = bot.shell("Rename Configuration");
|
||||
shell.activate();
|
||||
SWTBotText text = bot.textWithLabel("Name:");
|
||||
text.setText("");
|
||||
text.typeText("release");
|
||||
bot.button("OK").click();
|
||||
shell = bot.shell("GnuProject0: Manage Configurations");
|
||||
shell.activate();
|
||||
bot.table().select("default");
|
||||
bot.button("Rename...").click();
|
||||
shell = bot.shell("Rename Configuration");
|
||||
shell.activate();
|
||||
text = bot.textWithLabel("Name:");
|
||||
text.setText("");
|
||||
text.typeText("debug");
|
||||
bot.button("OK").click();
|
||||
shell = bot.shell("GnuProject0: Manage Configurations");
|
||||
shell.activate();
|
||||
renameConfiguration("debug", "release");
|
||||
renameConfiguration("default", "debug");
|
||||
bot.button("OK").click();
|
||||
// Verify that "release" has --enable-jeff set and that
|
||||
// the new "debug" configuration has no user setting.
|
||||
shell = bot.shell("Properties for GnuProject0");
|
||||
SWTBotShell shell = bot.shell("Properties for " + projectName);
|
||||
shell.activate();
|
||||
configs = bot.comboBoxWithLabel(UIMessages.getString("AbstractPage.6"));
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||
text = bot.textWithLabel("Additional command-line options");
|
||||
configs = bot.comboBoxWithLabel("Configuration: ");
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
||||
.select("Advanced");
|
||||
SWTBotText text = bot.textWithLabel("Additional command-line options");
|
||||
String setting = text.getText();
|
||||
assertEquals("--enable-jeff", setting);
|
||||
configs.setFocus();
|
||||
configs.setSelection("debug");
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
||||
.select("Advanced");
|
||||
text = bot.textWithLabel("Additional command-line options");
|
||||
setting = text.getText();
|
||||
assertEquals("", setting);
|
||||
|
@ -456,96 +398,96 @@ public class SetConfigurationParameter {
|
|||
// Cancel and then verify that "debug" is back to normal with
|
||||
// --enable-jeff set and that "default" is back to normal with
|
||||
// no user setting.
|
||||
view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject0");
|
||||
bot.menu("Project", 1).menu("Properties").click();
|
||||
shell = bot.shell("Properties for GnuProject0");
|
||||
shell.activate();
|
||||
bot.tree().expandNode("Autotools").select("Configure Settings");
|
||||
configs = bot.comboBoxWithLabel(UIMessages.getString("AbstractPage.6"));
|
||||
openProperties("Autotools", "Configure Settings");
|
||||
configs = bot.comboBoxWithLabel("Configuration: ");
|
||||
configs.setSelection("debug");
|
||||
assertTrue(configs.getText().contains("debug"));
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
||||
.select("Advanced");
|
||||
text = bot.textWithLabel("Additional command-line options");
|
||||
setting = text.getText();
|
||||
assertEquals("--enable-jeff", setting);
|
||||
configs.setFocus();
|
||||
configs.setSelection("default");
|
||||
assertTrue(configs.getText().contains("default"));
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
||||
.select("Advanced");
|
||||
text = bot.textWithLabel("Additional command-line options");
|
||||
setting = text.getText();
|
||||
assertEquals("", setting);
|
||||
bot.button("OK").click();
|
||||
bot.waitUntil(Conditions.shellCloses(shell));
|
||||
}
|
||||
|
||||
@Test
|
||||
// Verify we can do a double rename of configurations, renaming one configuration to
|
||||
// Verify we can do a double rename of configurations, renaming one
|
||||
// configuration to
|
||||
// another and inheriting the settings properly.
|
||||
@Test
|
||||
public void doubleRenameOk() throws Exception {
|
||||
SWTBotView view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject0");
|
||||
bot.menu("Project", 1).menu("Properties").click();
|
||||
SWTBotShell shell = bot.shell("Properties for GnuProject0");
|
||||
shell.activate();
|
||||
bot.tree().expandNode("Autotools").select("Configure Settings");
|
||||
SWTBotCombo configs = bot.comboBoxWithLabel(UIMessages.getString("AbstractPage.6"));
|
||||
assertTrue(configs.getText().contains("debug"));
|
||||
openProperties("Autotools", "Configure Settings");
|
||||
SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: ");
|
||||
bot.button("Manage Configurations...").click();
|
||||
shell = bot.shell("GnuProject0: Manage Configurations");
|
||||
SWTBotShell shell = bot.shell(projectName + ": Manage Configurations");
|
||||
shell.activate();
|
||||
bot.table().select("debug");
|
||||
bot.button("Set Active").click();
|
||||
// Rename "debug" to "release" and rename "default" to "debug".
|
||||
// The settings should follow the rename operation.
|
||||
bot.button("Rename...").click();
|
||||
shell = bot.shell("Rename Configuration");
|
||||
shell.activate();
|
||||
SWTBotText text = bot.textWithLabel("Name:");
|
||||
text.setText("");
|
||||
text.typeText("release");
|
||||
renameConfiguration("debug", "release");
|
||||
renameConfiguration("default", "debug");
|
||||
bot.button("OK").click();
|
||||
shell = bot.shell("GnuProject0: Manage Configurations");
|
||||
shell.activate();
|
||||
bot.table().select("default");
|
||||
bot.button("Rename...").click();
|
||||
shell = bot.shell("Rename Configuration");
|
||||
shell.activate();
|
||||
text = bot.textWithLabel("Name:");
|
||||
text.setText("");
|
||||
text.typeText("debug");
|
||||
bot.button("OK").click();
|
||||
shell = bot.shell("GnuProject0: Manage Configurations");
|
||||
shell.activate();
|
||||
bot.button("OK").click();
|
||||
shell = bot.shell("Properties for GnuProject0");
|
||||
shell = bot.shell("Properties for " + projectName);
|
||||
shell.activate();
|
||||
bot.button("OK").click();
|
||||
|
||||
// Verify changes have taken effect permanently
|
||||
view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject0");
|
||||
bot.menu("Project", 1).menu("Properties").click();
|
||||
shell = bot.shell("Properties for GnuProject0");
|
||||
shell.activate();
|
||||
bot.tree().expandNode("Autotools").select("Configure Settings");
|
||||
configs = bot.comboBoxWithLabel(UIMessages.getString("AbstractPage.6"));
|
||||
openProperties("Autotools", "Configure Settings");
|
||||
configs = bot.comboBoxWithLabel("Configuration: ");
|
||||
assertTrue(configs.getText().contains("release"));
|
||||
assertTrue(configs.getText().contains("Active"));
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||
text = bot.textWithLabel("Additional command-line options");
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
||||
.select("Advanced");
|
||||
SWTBotText text = bot.textWithLabel("Additional command-line options");
|
||||
String setting = text.getText();
|
||||
assertEquals("--enable-jeff", setting);
|
||||
configs.setFocus();
|
||||
configs.setSelection("debug");
|
||||
assertTrue(configs.getText().contains("debug"));
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
||||
.select("Advanced");
|
||||
text = bot.textWithLabel("Additional command-line options");
|
||||
setting = text.getText();
|
||||
assertEquals("", setting);
|
||||
|
||||
// Undo the changes made by this test
|
||||
configs = bot.comboBoxWithLabel("Configuration: ");
|
||||
bot.button("Manage Configurations...").click();
|
||||
shell = bot.shell(projectName + ": Manage Configurations");
|
||||
shell.activate();
|
||||
bot.table().select("Build (GNU)");
|
||||
bot.button("Set Active").click();
|
||||
renameConfiguration("debug", "default");
|
||||
renameConfiguration("release", "debug");
|
||||
bot.button("OK").click();
|
||||
shell = bot.shell("Properties for " + projectName);
|
||||
shell.activate();
|
||||
bot.button("OK").click();
|
||||
bot.waitUntil(Conditions.shellCloses(shell));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void sleep() {
|
||||
bot.sleep(4000);
|
||||
// Renames a configuration. Assumes the "Manage Configurations" dialog will
|
||||
// be open.
|
||||
private void renameConfiguration(String original, String newname) {
|
||||
SWTBotShell shell = bot.shell(projectName + ": Manage Configurations");
|
||||
shell.activate();
|
||||
bot.table().select(original);
|
||||
bot.button("Rename...").click();
|
||||
shell = bot.shell("Rename Configuration");
|
||||
shell.activate();
|
||||
bot.textWithLabel("Name:").setText(newname);
|
||||
bot.button("OK").click();
|
||||
shell = bot.shell(projectName + ": Manage Configurations");
|
||||
shell.activate();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,172 +18,114 @@ import java.io.FileWriter;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
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.utils.SWTBotPreferences;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio;
|
||||
import org.eclipse.swtbot.swt.finder.waits.Conditions;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(SWTBotJunit4ClassRunner.class)
|
||||
public class TestEnvironmentVars {
|
||||
private static SWTWorkbenchBot bot;
|
||||
public class TestEnvironmentVars extends AbstractTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
|
||||
bot = new SWTWorkbenchBot();
|
||||
// Close the Welcome view if it exists
|
||||
try {
|
||||
bot.viewByTitle("Welcome").close();
|
||||
// Turn off automatic building by default
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
bot.menu("Window").menu("Preferences").click();
|
||||
SWTBotShell shell = bot.shell("Preferences");
|
||||
shell.activate();
|
||||
bot.tree().expandNode("General").select("Workspace");
|
||||
SWTBotCheckBox buildAuto = bot.checkBox("Build automatically");
|
||||
if (buildAuto != null && buildAuto.isChecked())
|
||||
buildAuto.click();
|
||||
bot.button("Apply").click();
|
||||
// Ensure that the C/C++ perspective is chosen automatically
|
||||
// and doesn't require user intervention
|
||||
bot.tree().expandNode("General").select("Perspectives");
|
||||
SWTBotRadio radio = bot.radio("Always open");
|
||||
if (radio != null && !radio.isSelected())
|
||||
radio.click();
|
||||
bot.button("OK").click();
|
||||
bot.menu("File").menu("New").menu("Project...").click();
|
||||
|
||||
shell = bot.shell("New Project");
|
||||
shell.activate();
|
||||
bot.tree().expandNode("C/C++").select("C Project");
|
||||
bot.button("Next >").click();
|
||||
|
||||
bot.textWithLabel("Project name:").setText("GnuProject2");
|
||||
bot.tree().expandNode("GNU Autotools").select("Hello World ANSI C Autotools Project");
|
||||
|
||||
bot.button("Finish").click();
|
||||
AbstractTest.init("GnuProject2");
|
||||
}
|
||||
|
||||
@Test
|
||||
// Verify we can pass an unknown env var in configure options and it will be nulled out
|
||||
|
||||
// Verify we can pass an unknown env var in configure options and it will be
|
||||
// nulled out
|
||||
// Verifies fix for Bug: #303616
|
||||
@Test
|
||||
public void referenceUnknownEnvVar() throws Exception {
|
||||
SWTBotView view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject2");
|
||||
bot.menu("Project", 1).menu("Properties").click();
|
||||
SWTBotShell shell = bot.shell("Properties for GnuProject2");
|
||||
shell.activate();
|
||||
bot.tree().expandNode("Autotools").select("Configure Settings");
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced");
|
||||
// Set the configure parameters to be --enable-jeff via user-defined options
|
||||
SWTBotShell shell = openProperties("Autotools", "Configure Settings");
|
||||
// Set the configure parameters to be --enable-jeff via user-defined
|
||||
// options
|
||||
bot.treeWithLabel("Configure Settings").expandNode("configure")
|
||||
.select("Advanced");
|
||||
SWTBotText text = bot.textWithLabel("Additional command-line options");
|
||||
text.typeText("${some_var}");
|
||||
bot.button("OK").click();
|
||||
view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject2");
|
||||
bot.menu("Project", 1).menu("Reconfigure Project").click();
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
assertTrue(workspace != null);
|
||||
IWorkspaceRoot root = workspace.getRoot();
|
||||
assertTrue(root != null);
|
||||
IProject project = root.getProject("GnuProject2");
|
||||
assertTrue(project != null);
|
||||
IPath path = project.getLocation();
|
||||
bot.waitUntil(Conditions.shellCloses(shell), 120000);
|
||||
|
||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
||||
"Reconfigure Project");
|
||||
IPath path = checkProject().getLocation();
|
||||
File f = null;
|
||||
// We need to wait until the config.status file is created so
|
||||
// sleep a bit and look for it...give up after 40 seconds
|
||||
for (int i = 0; i < 80; ++i) {
|
||||
bot.sleep(500);
|
||||
f = new File(path.append("config.status").toOSString());
|
||||
if (f.exists())
|
||||
if (f.exists()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertTrue(f.exists());
|
||||
bot.sleep(1000);
|
||||
SWTBotView consoleView = bot.viewByTitle("Console");
|
||||
SWTBotView consoleView = viewConsole("Configure");
|
||||
consoleView.setFocus();
|
||||
String output = consoleView.bot().styledText().getText();
|
||||
Pattern p = Pattern.compile(".*some_var.*", Pattern.DOTALL);
|
||||
Matcher m = p.matcher(output);
|
||||
// We shouldn't see some_var anywhere in the console
|
||||
assertTrue(!m.matches());
|
||||
|
||||
setEnvVar();
|
||||
}
|
||||
|
||||
@Test
|
||||
// Verify we can set an environment variable and use it as a configure parameter
|
||||
// Verify we can set an environment variable and use it as a configure
|
||||
// parameter
|
||||
// Verifies fix for Bug: #303616
|
||||
public void setEnvVar() throws Exception {
|
||||
SWTBotView view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject2");
|
||||
bot.menu("Project", 1).menu("Properties").click();
|
||||
SWTBotShell shell = bot.shell("Properties for GnuProject2");
|
||||
shell.activate();
|
||||
bot.tree().expandNode("C/C++ Build").select("Environment");
|
||||
openProperties("C/C++ Build", "Environment");
|
||||
bot.button("Add...").click();
|
||||
shell = bot.shell("New variable");
|
||||
SWTBotShell shell = bot.shell("New variable");
|
||||
shell.activate();
|
||||
SWTBotText text = bot.textWithLabel("Name:");
|
||||
text.typeText("some_var");
|
||||
text.setText("some_var");
|
||||
text = bot.textWithLabel("Value:");
|
||||
text.typeText("--enable-somevar");
|
||||
text.setText("--enable-somevar");
|
||||
bot.button("OK").click();
|
||||
shell = bot.shell("Properties for GnuProject2");
|
||||
bot.waitUntil(Conditions.shellCloses(shell));
|
||||
shell = bot.shell("Properties for " + projectName);
|
||||
shell.activate();
|
||||
bot.button("OK").click();
|
||||
view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject2");
|
||||
bot.menu("Project", 1).menu("Reconfigure Project").click();
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
assertTrue(workspace != null);
|
||||
IWorkspaceRoot root = workspace.getRoot();
|
||||
assertTrue(root != null);
|
||||
IProject project = root.getProject("GnuProject2");
|
||||
assertTrue(project != null);
|
||||
IPath path = project.getLocation();
|
||||
bot.waitUntil(Conditions.shellCloses(shell));
|
||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
||||
"Reconfigure Project");
|
||||
|
||||
IPath path = checkProject().getLocation();
|
||||
File f = null;
|
||||
// We need to wait until the config.status file is created so
|
||||
// sleep a bit and look for it...give up after 40 seconds
|
||||
for (int i = 0; i < 80; ++i) {
|
||||
bot.sleep(500);
|
||||
f = new File(path.append("config.status").toOSString());
|
||||
if (f.exists())
|
||||
if (f.exists()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertTrue(f.exists());
|
||||
bot.sleep(1000);
|
||||
SWTBotView consoleView = bot.viewByTitle("Console");
|
||||
consoleView.setFocus();
|
||||
SWTBotView consoleView = viewConsole("Configure");
|
||||
String output = consoleView.bot().styledText().getText();
|
||||
Pattern p = Pattern.compile(".*--enable-somevar.*", Pattern.DOTALL);
|
||||
Matcher m = p.matcher(output);
|
||||
// We should see the expanded some_var variable in the console
|
||||
assertTrue(m.matches());
|
||||
|
||||
setEnvVarOnCommandLine();
|
||||
}
|
||||
|
||||
@Test
|
||||
// Verify we can set an environment variable prior to the configuration command and
|
||||
|
||||
// Verify we can set an environment variable prior to the configuration
|
||||
// command and
|
||||
// it will be seen by the configure script
|
||||
public void setEnvVarOnCommandLine() throws Exception {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
assertTrue(workspace != null);
|
||||
IWorkspaceRoot root = workspace.getRoot();
|
||||
assertTrue(root != null);
|
||||
IProject project = root.getProject("GnuProject2");
|
||||
assertTrue(project != null);
|
||||
IPath path = project.getLocation();
|
||||
IPath path = checkProject().getLocation();
|
||||
// Create a fake configure script which prints out the values of
|
||||
// envvars some_var1, some_var2, and some_var3
|
||||
File f = new File(path.append("fake_configure").toOSString());
|
||||
|
@ -201,34 +143,32 @@ public class TestEnvironmentVars {
|
|||
w.append("echo VAR6 is ${some_var6}");
|
||||
w.newLine();
|
||||
w.close();
|
||||
// Now change the configure script command to be the fake configure script
|
||||
// Now change the configure script command to be the fake configure
|
||||
// script
|
||||
// and set the three envvars on the command itself
|
||||
SWTBotView view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject2");
|
||||
bot.menu("Project", 1).menu("Properties").click();
|
||||
SWTBotShell shell = bot.shell("Properties for GnuProject2");
|
||||
shell.activate();
|
||||
bot.tree().expandNode("Autotools").select("Configure Settings");
|
||||
openProperties("Autotools", "Configure Settings");
|
||||
bot.treeWithLabel("Configure Settings").select("configure");
|
||||
bot.textWithLabel("Command").setText("");
|
||||
// Choose three different forms, some using quotes to allow blanks in them
|
||||
bot.textWithLabel("Command").typeText("some_var1=\"a boat\" some_var2='a train' some_var3=car fake_configure some_var4=\"a wagon\" some_var5='a plane' some_var6=skates");
|
||||
// Choose three different forms, some using quotes to allow blanks in
|
||||
// them
|
||||
bot.textWithLabel("Command")
|
||||
.typeText(
|
||||
"some_var1=\"a boat\" some_var2='a train' some_var3=car fake_configure some_var4=\"a wagon\" some_var5='a plane' some_var6=skates");
|
||||
bot.button("OK").click();
|
||||
// Reconfigure the project and make sure the env variables are seen in the script
|
||||
view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject2");
|
||||
bot.menu("Project", 1).menu("Reconfigure Project").click();
|
||||
// Reconfigure the project and make sure the env variables are seen in
|
||||
// the script
|
||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
||||
"Reconfigure Project");
|
||||
bot.shell("C/C++ - Eclipse Platform").activate();
|
||||
bot.sleep(3000);
|
||||
SWTBotView consoleView = bot.viewByTitle("Console");
|
||||
SWTBotView consoleView = bot.viewByPartName("Console");
|
||||
consoleView.setFocus();
|
||||
String output = consoleView.bot().styledText().getText();
|
||||
Pattern p = Pattern.compile(".*VAR1 is a boat.*VAR2 is a train.*VAR3 is car.*VAR4 is a wagon.*VAR5 is a plane.*VAR6 is skates.*", Pattern.DOTALL);
|
||||
Pattern p = Pattern.compile(
|
||||
".*a boat.*a train.*car.*a wagon.*a plane.*skates.*",
|
||||
Pattern.DOTALL);
|
||||
Matcher m = p.matcher(output);
|
||||
assertTrue(m.matches());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void sleep() {
|
||||
bot.sleep(2000);
|
||||
}
|
||||
}
|
|
@ -10,13 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.autotools.ui.tests;
|
||||
|
||||
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
|
||||
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
|
||||
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -25,160 +21,73 @@ import org.eclipse.core.resources.IWorkspace;
|
|||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
|
||||
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
|
||||
import org.eclipse.swtbot.swt.finder.SWTBot;
|
||||
import org.eclipse.swtbot.swt.finder.finders.ContextMenuFinder;
|
||||
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
|
||||
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
|
||||
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio;
|
||||
import org.eclipse.swtbot.swt.finder.waits.Conditions;
|
||||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
|
||||
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;
|
||||
|
||||
@RunWith(SWTBotJunit4ClassRunner.class)
|
||||
public class TestMakeTargets {
|
||||
|
||||
private static SWTWorkbenchBot bot;
|
||||
public class TestMakeTargets extends AbstractTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
|
||||
bot = new SWTWorkbenchBot();
|
||||
// Close the Welcome view if it exists
|
||||
try {
|
||||
bot.viewByTitle("Welcome").close();
|
||||
// Turn off automatic building by default
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
bot.menu("Window").menu("Preferences").click();
|
||||
SWTBotShell shell = bot.shell("Preferences");
|
||||
shell.activate();
|
||||
bot.tree().expandNode("General").select("Workspace");
|
||||
SWTBotCheckBox buildAuto = bot.checkBox("Build automatically");
|
||||
if (buildAuto != null && buildAuto.isChecked())
|
||||
buildAuto.click();
|
||||
bot.button("Apply").click();
|
||||
// Ensure that the C/C++ perspective is chosen automatically
|
||||
// and doesn't require user intervention
|
||||
bot.tree().expandNode("General").select("Perspectives");
|
||||
SWTBotRadio radio = bot.radio("Always open");
|
||||
if (radio != null && !radio.isSelected())
|
||||
radio.click();
|
||||
bot.button("OK").click();
|
||||
bot.menu("File").menu("New").menu("Project...").click();
|
||||
|
||||
shell = bot.shell("New Project");
|
||||
shell.activate();
|
||||
bot.tree().expandNode("C/C++").select("C Project");
|
||||
bot.button("Next >").click();
|
||||
|
||||
bot.textWithLabel("Project name:").setText("GnuProject3");
|
||||
bot.tree().expandNode("GNU Autotools").select("Hello World ANSI C Autotools Project");
|
||||
|
||||
bot.button("Finish").click();
|
||||
AbstractTest.init("GnuProject3");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
// Verify we can build and run the info MakeTarget tool
|
||||
public void canBuildAndAccessInfoTarget() throws Exception {
|
||||
SWTBotView view = bot.viewByTitle("Project Explorer");
|
||||
view.bot().tree().select("GnuProject3");
|
||||
bot.menu("Project", 1).menu("Build Project").click();
|
||||
clickProjectContextMenu("Build Project");
|
||||
|
||||
// Wait until the project is built
|
||||
SWTBotShell shell = bot.shell("Build Project");
|
||||
bot.waitUntil(Conditions.shellCloses(shell), 120000);
|
||||
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
assertTrue(workspace != null);
|
||||
IWorkspaceRoot root = workspace.getRoot();
|
||||
assertTrue(root != null);
|
||||
IProject project = root.getProject("GnuProject3");
|
||||
IProject project = root.getProject(projectName);
|
||||
assertTrue(project != null);
|
||||
IPath path = project.getLocation();
|
||||
path = path.append("config.status");
|
||||
// We need to wait until the config.status file is created so
|
||||
// sleep a bit and look for it...give up after 120 seconds
|
||||
for (int i = 0; i < 240; ++i) {
|
||||
bot.sleep(500);
|
||||
File f = new File(path.toOSString());
|
||||
if (f.exists())
|
||||
break;
|
||||
}
|
||||
File f = new File(path.toOSString());
|
||||
assertTrue(f.exists());
|
||||
view = bot.viewByTitle("Project Explorer");
|
||||
// FIXME: there is a problem with the CDT adding multiple MakeTargets
|
||||
// so the Autotools plugin adds them into the saved data all at
|
||||
// once. The targets aren't refreshed until the project is reopened.
|
||||
// We do this by manually closing and opening the project. This
|
||||
// will not be needed as of CDT 7.0.0.
|
||||
SWTBotTreeItem node = view.bot().tree().getTreeItem("GnuProject3");
|
||||
node.setFocus();
|
||||
node.select().contextMenu("Close Project").click();
|
||||
node.setFocus();
|
||||
node.select().contextMenu("Open Project").click();
|
||||
view.bot().tree().select("GnuProject3");
|
||||
bot.menu("Project", 1).menu("Make Target").menu("Build...").click();
|
||||
SWTBotShell shell = bot.shell("Make Targets");
|
||||
f = new File(path.toOSString());
|
||||
assertTrue(f.exists());
|
||||
|
||||
projectExplorer.bot().tree().getTreeItem(projectName).select();
|
||||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
||||
"Make Targets", "Build...");
|
||||
shell = bot.shell("Make Targets");
|
||||
shell.activate();
|
||||
bot.table().getTableItem("info").setFocus();
|
||||
bot.table().getTableItem("info").select();
|
||||
bot.button("Build").click();
|
||||
bot.sleep(3000);
|
||||
SWTBotView consoleView = bot.viewByTitle("Console");
|
||||
consoleView.setFocus();
|
||||
|
||||
SWTBotView consoleView = viewConsole("CDT Build Console");
|
||||
String output = consoleView.bot().styledText().getText();
|
||||
Pattern p = Pattern.compile(".*make info.*", Pattern.DOTALL);
|
||||
Matcher m = p.matcher(output);
|
||||
assertTrue(m.matches());
|
||||
view = bot.viewByTitle("Project Explorer");
|
||||
view.setFocus();
|
||||
node = view.bot().tree().getTreeItem("GnuProject3");
|
||||
node.setFocus();
|
||||
node.select();
|
||||
// FIXME: when context menus work properly, add test to try out
|
||||
|
||||
// Make Targets using right-click on project.
|
||||
// node.contextMenu("Make Targets").contextMenu("Build...").click();
|
||||
// org.hamcrest.Matcher<MenuItem> withMnemonic = withMnemonic("Make Targets");
|
||||
// final org.hamcrest.Matcher<MenuItem> matcher = allOf(widgetOfType(MenuItem.class));
|
||||
// final ContextMenuFinder menuFinder = new ContextMenuFinder((Control)view.bot().tree().widget);
|
||||
// new SWTBot().waitUntil(new DefaultCondition() {
|
||||
// public String getFailureMessage() {
|
||||
// return "Could not find context menu with text: Make Targets"; //$NON-NLS-1$
|
||||
// }
|
||||
//
|
||||
// public boolean test() throws Exception {
|
||||
// return !menuFinder.findMenus(matcher).isEmpty();
|
||||
// }
|
||||
// });
|
||||
// List<MenuItem> list = menuFinder.findMenus(matcher);
|
||||
// bot.sleep(23000);
|
||||
// // Following does not work but should
|
||||
// SWTBotMenu menu = node.select().contextMenu("Make Targets");
|
||||
// bot.sleep(4000);
|
||||
// shell = bot.shell("Make Targets");
|
||||
// shell.activate();
|
||||
// bot.table().getTableItem("check").setFocus();
|
||||
// bot.table().getTableItem("check").select();
|
||||
// bot.button("Build").click();
|
||||
// bot.sleep(3000);
|
||||
// consoleView = bot.viewByTitle("Console");
|
||||
// consoleView.setFocus();
|
||||
// output = consoleView.bot().styledText().getText();
|
||||
// p = Pattern.compile(".*make check.*Making check in src.*", Pattern.DOTALL);
|
||||
// m = p.matcher(output);
|
||||
// assertTrue(m.matches());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void sleep() {
|
||||
bot.sleep(4000);
|
||||
clickProjectContextMenu("Make Targets", "Build...");
|
||||
shell = bot.shell("Make Targets");
|
||||
shell.activate();
|
||||
bot.table().getTableItem("check").select();
|
||||
bot.button("Build").click();
|
||||
bot.sleep(3000);
|
||||
consoleView = bot.viewByPartName("Console");
|
||||
consoleView.setFocus();
|
||||
output = consoleView.bot().styledText().getText();
|
||||
p = Pattern.compile(".*make check.*Making check in src.*",
|
||||
Pattern.DOTALL);
|
||||
m = p.matcher(output);
|
||||
assertTrue(m.matches());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue