mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 17:35:35 +02:00
autotools: Tests improvements.
* assertNotNull instead of assertTrue(var != null) * better types for swtbot api to prevent useless casts after that * LanguageSettingsManager.getLanguages instead of deprecated api * assertFalse instead of assertTrue(!var) Change-Id: Icdde01f10617b6ec51938bc1998a690cfe7ff1d4 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
This commit is contained in:
parent
76f53cecce
commit
07488984d9
6 changed files with 28 additions and 29 deletions
|
@ -20,7 +20,6 @@ import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
|
|||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
|
||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
|
||||
|
@ -66,9 +65,7 @@ public class LibtoolGCCBuildCommandParserTest {
|
|||
IFile file1 = ResourceHelper.createFile(project, "file1.cpp");
|
||||
IFile file2 = ResourceHelper.createFile(project, "file2.cpp");
|
||||
IFile file3 = ResourceHelper.createFile(project, "file3.cpp");
|
||||
@SuppressWarnings("deprecation")
|
||||
ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file1.getProjectRelativePath(), true);
|
||||
String languageId = ls.getLanguageId();
|
||||
String languageId = LanguageSettingsManager.getLanguages(file1, cfgDescription).get(0);
|
||||
|
||||
// create GCCBuildCommandParser
|
||||
GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager
|
||||
|
|
|
@ -17,7 +17,7 @@ import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withRe
|
|||
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.assertTrue;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -37,7 +37,6 @@ import org.eclipse.swt.widgets.Control;
|
|||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
import org.eclipse.swt.widgets.Widget;
|
||||
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
|
||||
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
|
||||
import org.eclipse.swtbot.swt.finder.SWTBot;
|
||||
|
@ -156,7 +155,7 @@ public abstract class AbstractTest {
|
|||
|
||||
IProjectNature nature = checkProject().getNature(
|
||||
"org.eclipse.cdt.autotools.core.autotoolsNatureV2");
|
||||
assertTrue(nature != null);
|
||||
assertNotNull(nature);
|
||||
|
||||
projectExplorer = bot.viewByTitle("Project Explorer");
|
||||
}
|
||||
|
@ -249,13 +248,13 @@ public abstract class AbstractTest {
|
|||
final String inGroup) {
|
||||
UIThreadRunnable.syncExec(() -> {
|
||||
@SuppressWarnings("unchecked")
|
||||
Matcher<Widget> matcher = allOf(inGroup(inGroup), widgetOfType(Button.class),
|
||||
Matcher<Button> 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++);
|
||||
b = bot.widget(matcher, i++);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
return;
|
||||
}
|
||||
|
@ -327,11 +326,11 @@ public abstract class AbstractTest {
|
|||
|
||||
public static IProject checkProject() {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
assertTrue(workspace != null);
|
||||
assertNotNull(workspace);
|
||||
IWorkspaceRoot root = workspace.getRoot();
|
||||
assertTrue(root != null);
|
||||
assertNotNull(root);
|
||||
IProject project = root.getProject(projectName);
|
||||
assertTrue(project != null);
|
||||
assertNotNull(project);
|
||||
return project;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.autotools.ui.tests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@ -100,7 +101,7 @@ public class SetConfigurationParameter extends AbstractTest {
|
|||
@Test
|
||||
public void t1canSetConfigParm() throws Exception {
|
||||
IProject project = checkProject();
|
||||
assertTrue(project != null);
|
||||
assertNotNull(project);
|
||||
IPath path = project.getLocation();
|
||||
path = path.append(".autotools");
|
||||
File f = new File(path.toOSString());
|
||||
|
@ -123,8 +124,8 @@ public class SetConfigurationParameter extends AbstractTest {
|
|||
NamedNodeMap optionAttrs = child.getAttributes();
|
||||
Node idNode = optionAttrs.getNamedItem("id"); // $NON-NLS-1$
|
||||
Node valueNode = optionAttrs.getNamedItem("value"); // $NON-NLS-1$
|
||||
assertTrue(idNode != null);
|
||||
assertTrue(valueNode != null);
|
||||
assertNotNull(idNode);
|
||||
assertNotNull(valueNode);
|
||||
String id = idNode.getNodeValue();
|
||||
String value = valueNode.getNodeValue();
|
||||
if (id.equals("user")) {
|
||||
|
@ -149,11 +150,11 @@ public class SetConfigurationParameter extends AbstractTest {
|
|||
bot.waitUntil(Conditions.shellCloses(shell), 120000);
|
||||
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
assertTrue(workspace != null);
|
||||
assertNotNull(workspace);
|
||||
IWorkspaceRoot root = workspace.getRoot();
|
||||
assertTrue(root != null);
|
||||
assertNotNull(root);
|
||||
IProject project = root.getProject(projectName);
|
||||
assertTrue(project != null);
|
||||
assertNotNull(project);
|
||||
IPath path = project.getLocation();
|
||||
File f = new File(path.append("src/a.out").toOSString());
|
||||
assertTrue(f.exists());
|
||||
|
@ -273,11 +274,11 @@ public class SetConfigurationParameter extends AbstractTest {
|
|||
clickContextMenu(projectExplorer.bot().tree().select(projectName),
|
||||
"Build Project");
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
assertTrue(workspace != null);
|
||||
assertNotNull(workspace);
|
||||
IWorkspaceRoot root = workspace.getRoot();
|
||||
assertTrue(root != null);
|
||||
assertNotNull(root);
|
||||
IProject project = root.getProject(projectName);
|
||||
assertTrue(project != null);
|
||||
assertNotNull(project);
|
||||
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
|
||||
|
@ -344,8 +345,8 @@ public class SetConfigurationParameter extends AbstractTest {
|
|||
NamedNodeMap optionAttrs = child.getAttributes();
|
||||
Node idNode = optionAttrs.getNamedItem("id"); // $NON-NLS-1$
|
||||
Node valueNode = optionAttrs.getNamedItem("value"); // $NON-NLS-1$
|
||||
assertTrue(idNode != null);
|
||||
assertTrue(valueNode != null);
|
||||
assertNotNull(idNode);
|
||||
assertNotNull(valueNode);
|
||||
String id = idNode.getNodeValue();
|
||||
String value = valueNode.getNodeValue();
|
||||
if (id.equals("user")) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.autotools.ui.tests;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
|
@ -69,7 +70,7 @@ public class TestEnvironmentVars extends AbstractTest {
|
|||
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());
|
||||
assertFalse(m.matches());
|
||||
|
||||
setEnvVar();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.autotools.ui.tests;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -43,11 +44,11 @@ public class TestMakeTargets extends AbstractTest {
|
|||
bot.waitUntil(Conditions.shellCloses(shell), 120000);
|
||||
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
assertTrue(workspace != null);
|
||||
assertNotNull(workspace);
|
||||
IWorkspaceRoot root = workspace.getRoot();
|
||||
assertTrue(root != null);
|
||||
assertNotNull(root);
|
||||
IProject project = root.getProject(projectName);
|
||||
assertTrue(project != null);
|
||||
assertNotNull(project);
|
||||
IPath path = project.getLocation();
|
||||
path = path.append("config.status");
|
||||
File f = new File(path.toOSString());
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.autotools.ui.tests;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -72,7 +72,7 @@ public class TestToolActions extends AbstractTest {
|
|||
bot.waitUntil(consoleTextMatches(consoleView, p));
|
||||
// Verify we still don't have an aclocal.m4 file yet
|
||||
f = new File(path.toOSString());
|
||||
assertTrue(!f.exists());
|
||||
assertFalse(f.exists());
|
||||
// Now lets run aclocal for our hello world project which hasn't had any
|
||||
// autotool files generated yet.
|
||||
clickProjectContextMenu("Invoke Autotools", "Invoke Aclocal");
|
||||
|
|
Loading…
Add table
Reference in a new issue