Skip to content
Snippets Groups Projects
Commit ac319a7a authored by Leonard Kupper's avatar Leonard Kupper
Browse files

Update tests (because of new representation namespace).

parent 52e3d5e4
No related branches found
No related tags found
1 merge request!33Feat/bar chart update 46
...@@ -34,7 +34,7 @@ public class RasterCanvasTest { ...@@ -34,7 +34,7 @@ public class RasterCanvasTest {
Assertions.assertDoesNotThrow( Assertions.assertDoesNotThrow(
() -> { () -> {
ConfigurationParser parser = new JavaPropertiesConfigurationParser(mBaseConfig, mDefaultConfig); ConfigurationParser parser = new JavaPropertiesConfigurationParser(mBaseConfig, mDefaultConfig);
RasterCanvas canvas = new SixDotBrailleRasterCanvas(parser.getPrinter(), parser.getFormat("test")); RasterCanvas canvas = new SixDotBrailleRasterCanvas(parser.getPrinter(), parser.getRepresentation(), parser.getFormat("test"));
// pre-calculated and measured correct values: // pre-calculated and measured correct values:
int x = 0; int x = 0;
...@@ -80,7 +80,7 @@ public class RasterCanvasTest { ...@@ -80,7 +80,7 @@ public class RasterCanvasTest {
Assertions.assertDoesNotThrow( Assertions.assertDoesNotThrow(
() -> { () -> {
ConfigurationParser parser = new JavaPropertiesConfigurationParser(mMarginsOnlyConfig, mDefaultConfig); ConfigurationParser parser = new JavaPropertiesConfigurationParser(mMarginsOnlyConfig, mDefaultConfig);
RasterCanvas canvas = new SixDotBrailleRasterCanvas(parser.getPrinter(), parser.getFormat("test")); RasterCanvas canvas = new SixDotBrailleRasterCanvas(parser.getPrinter(), parser.getRepresentation(), parser.getFormat("test"));
// pre-calculated and measured correct values: // pre-calculated and measured correct values:
// 6 mm left margin -> 1 cell border // 6 mm left margin -> 1 cell border
...@@ -114,7 +114,7 @@ public class RasterCanvasTest { ...@@ -114,7 +114,7 @@ public class RasterCanvasTest {
Assertions.assertDoesNotThrow( Assertions.assertDoesNotThrow(
() -> { () -> {
ConfigurationParser parser = new JavaPropertiesConfigurationParser(mConstraintOnlyConfig, mDefaultConfig); ConfigurationParser parser = new JavaPropertiesConfigurationParser(mConstraintOnlyConfig, mDefaultConfig);
RasterCanvas canvas = new SixDotBrailleRasterCanvas(parser.getPrinter(), parser.getFormat("test")); RasterCanvas canvas = new SixDotBrailleRasterCanvas(parser.getPrinter(), parser.getRepresentation(), parser.getFormat("test"));
// pre-calculated and measured correct values: // pre-calculated and measured correct values:
// width-constraint: 190.0 mm -> fits 32 cells h. // width-constraint: 190.0 mm -> fits 32 cells h.
...@@ -147,7 +147,7 @@ public class RasterCanvasTest { ...@@ -147,7 +147,7 @@ public class RasterCanvasTest {
Assertions.assertDoesNotThrow( Assertions.assertDoesNotThrow(
() -> { () -> {
ConfigurationParser parser = new JavaPropertiesConfigurationParser(mBothConfig, mDefaultConfig); ConfigurationParser parser = new JavaPropertiesConfigurationParser(mBothConfig, mDefaultConfig);
RasterCanvas canvas = new SixDotBrailleRasterCanvas(parser.getPrinter(), parser.getFormat("test")); RasterCanvas canvas = new SixDotBrailleRasterCanvas(parser.getPrinter(), parser.getRepresentation(), parser.getFormat("test"));
// pre-calculated and measured correct values: // pre-calculated and measured correct values:
// width-constraint: 190.0 mm -> fits 32 cells h. // width-constraint: 190.0 mm -> fits 32 cells h.
...@@ -181,7 +181,7 @@ public class RasterCanvasTest { ...@@ -181,7 +181,7 @@ public class RasterCanvasTest {
Assertions.assertDoesNotThrow( Assertions.assertDoesNotThrow(
() -> { () -> {
ConfigurationParser parser = new JavaPropertiesConfigurationParser(mBaseConfig, mDefaultConfig); ConfigurationParser parser = new JavaPropertiesConfigurationParser(mBaseConfig, mDefaultConfig);
MasterRenderer renderer = new MasterRenderer(parser.getPrinter(), parser.getFormat("test")); MasterRenderer renderer = new MasterRenderer(parser.getPrinter(), parser.getRepresentation(), parser.getFormat("test"));
RasterCanvas result = renderer.rasterize(new Image(getResource("examples/img/dummy.bmp"))); RasterCanvas result = renderer.rasterize(new Image(getResource("examples/img/dummy.bmp")));
ListIterator iter = result.getPageIterator(); ListIterator iter = result.getPageIterator();
while (iter.hasNext()) { while (iter.hasNext()) {
......
package de.tudresden.inf.mci.brailleplot.rendering; package de.tudresden.inf.mci.brailleplot.rendering;
import de.tudresden.inf.mci.brailleplot.configparser.ConfigurationParser; import de.tudresden.inf.mci.brailleplot.configparser.*;
import de.tudresden.inf.mci.brailleplot.configparser.Format;
import de.tudresden.inf.mci.brailleplot.configparser.JavaPropertiesConfigurationParser;
import de.tudresden.inf.mci.brailleplot.configparser.Printer;
import de.tudresden.inf.mci.brailleplot.layout.RasterCanvas; import de.tudresden.inf.mci.brailleplot.layout.RasterCanvas;
import de.tudresden.inf.mci.brailleplot.layout.SixDotBrailleRasterCanvas; import de.tudresden.inf.mci.brailleplot.layout.SixDotBrailleRasterCanvas;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
...@@ -18,6 +15,7 @@ public class FunctionalRasterizerTest { ...@@ -18,6 +15,7 @@ public class FunctionalRasterizerTest {
public static final String mDefaultConfig = getResource("config/rasterizer_test_default.properties").getAbsolutePath(); public static final String mDefaultConfig = getResource("config/rasterizer_test_default.properties").getAbsolutePath();
public static final String mBaseConfig = getResource("config/base_format.properties").getAbsolutePath(); public static final String mBaseConfig = getResource("config/base_format.properties").getAbsolutePath();
public static Printer mPrinter; public static Printer mPrinter;
public static Representation mRepresentation;
public static Format mFormat; public static Format mFormat;
public static File getResource(String fileName) { public static File getResource(String fileName) {
...@@ -32,6 +30,7 @@ public class FunctionalRasterizerTest { ...@@ -32,6 +30,7 @@ public class FunctionalRasterizerTest {
() -> { () -> {
ConfigurationParser parser = new JavaPropertiesConfigurationParser(mBaseConfig, mDefaultConfig); ConfigurationParser parser = new JavaPropertiesConfigurationParser(mBaseConfig, mDefaultConfig);
mPrinter = parser.getPrinter(); mPrinter = parser.getPrinter();
mRepresentation = parser.getRepresentation();
mFormat = parser.getFormat("test"); mFormat = parser.getFormat("test");
} }
); );
...@@ -50,7 +49,7 @@ public class FunctionalRasterizerTest { ...@@ -50,7 +49,7 @@ public class FunctionalRasterizerTest {
// which decides which rasterizer to use based on the Renderable type. // which decides which rasterizer to use based on the Renderable type.
// Directly passing the wrong Renderable type must cause exception: // Directly passing the wrong Renderable type must cause exception:
Assertions.assertThrows(IllegalArgumentException.class, () -> { Assertions.assertThrows(IllegalArgumentException.class, () -> {
RasterCanvas testCanvas = new SixDotBrailleRasterCanvas(mPrinter, mFormat); RasterCanvas testCanvas = new SixDotBrailleRasterCanvas(mPrinter, mRepresentation, mFormat);
// Pass Image to BrailleText rasterizer. // Pass Image to BrailleText rasterizer.
textRasterizer.rasterize(new Image(getResource("examples/img/dummy.bmp")), testCanvas); textRasterizer.rasterize(new Image(getResource("examples/img/dummy.bmp")), testCanvas);
}); });
......
package de.tudresden.inf.mci.brailleplot.rendering; package de.tudresden.inf.mci.brailleplot.rendering;
import de.tudresden.inf.mci.brailleplot.configparser.ConfigurationParser; import de.tudresden.inf.mci.brailleplot.configparser.*;
import de.tudresden.inf.mci.brailleplot.configparser.Format;
import de.tudresden.inf.mci.brailleplot.configparser.JavaPropertiesConfigurationParser;
import de.tudresden.inf.mci.brailleplot.configparser.Printer;
import de.tudresden.inf.mci.brailleplot.layout.RasterCanvas; import de.tudresden.inf.mci.brailleplot.layout.RasterCanvas;
import de.tudresden.inf.mci.brailleplot.layout.Rectangle; import de.tudresden.inf.mci.brailleplot.layout.Rectangle;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
...@@ -18,6 +15,7 @@ public class MasterRendererTest { ...@@ -18,6 +15,7 @@ public class MasterRendererTest {
public static final String mDefaultConfig = getResource("config/rasterizer_test_default.properties").getAbsolutePath(); public static final String mDefaultConfig = getResource("config/rasterizer_test_default.properties").getAbsolutePath();
public static final String mBaseConfig = getResource("config/base_format.properties").getAbsolutePath(); public static final String mBaseConfig = getResource("config/base_format.properties").getAbsolutePath();
public static Printer mPrinter; public static Printer mPrinter;
public static Representation mRepresentation;
public static Format mFormat; public static Format mFormat;
public static File getResource(String fileName) { public static File getResource(String fileName) {
...@@ -32,6 +30,7 @@ public class MasterRendererTest { ...@@ -32,6 +30,7 @@ public class MasterRendererTest {
() -> { () -> {
ConfigurationParser parser = new JavaPropertiesConfigurationParser(mBaseConfig, mDefaultConfig); ConfigurationParser parser = new JavaPropertiesConfigurationParser(mBaseConfig, mDefaultConfig);
mPrinter = parser.getPrinter(); mPrinter = parser.getPrinter();
mRepresentation = parser.getRepresentation();
mFormat = parser.getFormat("test"); mFormat = parser.getFormat("test");
} }
); );
...@@ -62,7 +61,7 @@ public class MasterRendererTest { ...@@ -62,7 +61,7 @@ public class MasterRendererTest {
renderingBase.registerRasterizer(rasterizerRef2); renderingBase.registerRasterizer(rasterizerRef2);
// create renderer from rendering base // create renderer from rendering base
MasterRenderer renderer = new MasterRenderer(mPrinter, mFormat, renderingBase); MasterRenderer renderer = new MasterRenderer(mPrinter, mRepresentation, mFormat, renderingBase);
// Test rasterizer selection // Test rasterizer selection
RasterCanvas result; RasterCanvas result;
...@@ -93,7 +92,7 @@ public class MasterRendererTest { ...@@ -93,7 +92,7 @@ public class MasterRendererTest {
@Test @Test
public void testRasterizerNotAvailable() { public void testRasterizerNotAvailable() {
// Create MasterRenderer with empty rendering base. // Create MasterRenderer with empty rendering base.
MasterRenderer empty = new MasterRenderer(mPrinter, mFormat, new FunctionalRenderingBase()); MasterRenderer empty = new MasterRenderer(mPrinter, mRepresentation, mFormat, new FunctionalRenderingBase());
Assertions.assertThrows(IllegalArgumentException.class, () -> empty.rasterize(new Image(getResource("examples/img/dummy.bmp")))); Assertions.assertThrows(IllegalArgumentException.class, () -> empty.rasterize(new Image(getResource("examples/img/dummy.bmp"))));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment