Add GraphicsPluginTest

This commit is contained in:
Peter Dell 2022-09-10 16:51:51 +02:00
parent e0e42aea0f
commit 7645450ef8
4 changed files with 113 additions and 2 deletions

View File

@ -12,7 +12,9 @@ Require-Bundle: com.wudsn.ide.base,
org.eclipse.ui.editors,
org.eclipse.ui.ide,
org.eclipse.ui.console,
org.eclipse.ui.views
org.eclipse.ui.views,
org.junit,
org.junit.jupiter.api
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-ActivationPolicy: lazy
Export-Package: com.wudsn.ide.gfx.editor

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
<booleanAttribute key="append.args" value="true"/>
<booleanAttribute key="askclear" value="false"/>
<booleanAttribute key="automaticAdd" value="true"/>
<booleanAttribute key="automaticValidate" value="true"/>
<stringAttribute key="bad_container_name" value="\com.wudsn.ide.gfx\launch"/>
<stringAttribute key="bootstrap" value=""/>
<stringAttribute key="checked" value="[NONE]"/>
<booleanAttribute key="clearConfig" value="true"/>
<booleanAttribute key="clearws" value="true"/>
<booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
<booleanAttribute key="default" value="true"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.wudsn.ide.gfx"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.wudsn.ide.gfx"/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit5"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.wudsn.ide.gfx"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.platform.ide"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
<booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
<booleanAttribute key="useDefaultConfig" value="true"/>
<booleanAttribute key="useDefaultConfigArea" value="false"/>
<booleanAttribute key="useProduct" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,63 @@
package com.wudsn.ide.gfx;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.fail;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.junit.jupiter.api.Test;
import com.wudsn.ide.base.common.MessageQueue;
import com.wudsn.ide.base.common.MessageQueue.Entry;
import com.wudsn.ide.gfx.converter.ConverterData;
import com.wudsn.ide.gfx.converter.ConverterDataLogic;
import com.wudsn.ide.gfx.model.ConverterMode;
// TODO Implement unit tests / run as plugin test?
class GraphicsPluginTest {
private static void assertContainsNoErrorMessage(MessageQueue messageQueue) {
if (messageQueue.containsError()) {
StringBuilder builder = new StringBuilder();
for (Entry entry : messageQueue.getEntries()) {
builder.append(entry.toString());
builder.append(",");
}
fail(builder.toString());
}
};
@Test
void test() {
MessageQueue messageQueue = new MessageQueue();
ConverterDataLogic converterDataLogic = new ConverterDataLogic(messageQueue);
ConverterData converterData = converterDataLogic.createData();
IPath path = new Path("Atari800/Graphics/GraphicsPluginTest.cnv"); // TODO Does not work
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IFile file = workspace.getRoot().getFile(path);
converterData.setFile(file);
converterData.setConverterMode(ConverterMode.NONE);
converterDataLogic.saveConversion(converterData, null);
assertContainsNoErrorMessage(messageQueue);
assertFalse(converterData.isChanged());
converterData.clear();
converterDataLogic.load(converterData);
if (messageQueue.containsError()) {
fail(messageQueue.getEntries().toString());
}
try {
converterData.getParameters().read(file);
} catch (CoreException ex) {
fail(ex);
}
fail("Not yet implemented");
}
}

View File

@ -232,7 +232,7 @@ public final class ConverterParameters {
serializer.getProperties().putAll(properties);
deserialize(serializer);
GraphicsPlugin.getInstance().log("ConverterParameters.read({0}):{1}",
GraphicsPlugin.getInstance().log("ConverterParameters.read(\"{0}\"): {1}",
new Object[] { file, serializer.getProperties() });
}