diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..838e346a --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,97 @@ +cache: + paths: + - maven.repository/ + - models/ + - pdb-store/ + - .gradle-user-home/ + +variables: + # MAVEN_OPTS: "-Dmaven.repo.local=maven.repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Xmx4g" + JAVA_HOME: "/usr/lib/jvm/java-8-openjdk-amd64" + PDB_CACHE_DIR: "./pdb-store/cache" + PDB_DIR: "./pdb-store" + MODEL_DIR: "./models" + GRADLE_USER_HOME: "./.gradle-user-home" + +# simple unit tests without requiring GPUs +unit-tests-no-gpu: + image: ubuntu:bionic + before_script: + - mkdir -p ./pdb-store/cache + - apt-get update -qq --force-yes > /dev/null + - apt-get install -qq -y --allow-downgrades --allow-remove-essential --allow-change-held-packages unzip wget git openjdk-8-jdk-headless curl libgl1-mesa-glx sudo sed > /dev/null + - if [ ! -d "$MODEL_DIR" ]; then wget -q https://ulrik.is/scenery-demo-models.zip && unzip -q scenery-demo-models.zip; fi + - sudo sed -i -e '/^assistive_technologies=/s/^/#/' /etc/java-*-openjdk/accessibility.properties + - chmod +x gradlew + script: + - ./gradlew build -x dokkaHtml -x dokkaHtmlJar -x javadoc -x dokkaJavadocJar -PjvmTarget=1.8 -PsourceCompatibility=1.8 + +# base job for running with GPUs +.base-job-gpu: &base-job-gpu + before_script: + - mkdir -p ./pdb-store/cache + # Installs Maven, Vulkan development libraries, etc. + - apt-get update -qq --force-yes > /dev/null + - apt-get install -qq -y --allow-downgrades --allow-remove-essential --allow-change-held-packages unzip wget git openjdk-8-jdk-headless libvulkan1 libvulkan-dev vulkan-utils ocl-icd-opencl-dev clinfo curl > /dev/null + - curl -sL https://deb.nodesource.com/setup_14.x | bash - + - apt-get install -qq --force-yes nodejs + - npm install --save argos-cli + - mkdir -p /etc/OpenCL/vendors && echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd + # Output Vulkan driver information, but do not fail in case of non-zero + # return (happens e.g. if $DISPLAY is not set) + - vulkaninfo || true + - clinfo || true + - if [ ! -d "$MODEL_DIR" ]; then wget -q https://ulrik.is/scenery-demo-models.zip && unzip -q scenery-demo-models.zip; fi + - chmod +x gradlew + - ./gradlew --stop # stop any deamon https://stackoverflow.com/a/58397542/1047713 + script: + - ./gradlew build -S -x dokkaHtml -x dokkaHtmlJar -x javadoc -x dokkaJavadocJar -PjvmTarget=1.8 -PsourceCompatibility=1.8 -Pgpu=true -i + artifacts: + when: always + expire_in: 48h + paths: + - results.tar.bz2 + +scenery-nvidia: + image: nvidia/vulkan:1.1.121-cuda-10.1-alpha + <<: *base-job-gpu + after_script: + - nvidia-smi + - tar cvjf results.tar.bz2 screenshots/ + - ARGOS_COMMIT=$CI_COMMIT_SHA ARGOS_BRANCH=$CI_COMMIT_REF_NAME ./node_modules/argos-cli/bin/argos upload screenshots/ --token $ARGOS_TOKEN || true + tags: + - cuda + - intel + +#scenery-amd: +# image: rocm/rocm-terminal +# <<: *base-job +# variables: +# SUDO: "sudo" +# GPURUN: "sudo su -m - rocm-user -c" +# before_script: +# # The rocm docker container requires the user to be in the video group which +# # can usually be set via docker's --group-add option. GitLab-Runner currently +# # has no known option for doing that. Therefore, it manually has to happen in +# # the job description. +# - $SUDO usermod -a -G video rocm-user +# # Installs Maven, Vulkan development libraries, etc. +# - $SUDO apt-get -qq --force-yes update > /dev/null +# - $SUDO apt-get install -qq --force-yes unzip kmod wget git maven openjdk-8-jdk libvulkan1 libvulkan-dev vulkan-utils > /dev/null +# # Installs the AMD GPUopen Vulkan driver +# - wget https://github.com/GPUOpen-Drivers/AMDVLK/releases/download/v-2019.Q3.6/amdvlk_2019.Q3.6_amd64.deb +# - $SUDO dpkg -i amdvlk_2019.Q3.6_amd64.deb +# - $SUDO apt-get -f install +# - $SUDO lsmod +# # Output Vulkan driver information, but do not fail in case of non-zero +# # return (happens e.g. if $DISPLAY is not set) +# - vulkaninfo || true +# - wget -q https://ulrik.is/scenery-demo-models.zip +# - unzip -q scenery-demo-models.zip +# after_script: +# - rocm-smi +# tags: +# - amd +# - rocm +# +# diff --git a/build.gradle.kts b/build.gradle.kts index 2a1e7d14..1fd956e6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,4 @@ +import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.kotlin.dsl.implementation import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import sciview.implementation @@ -125,6 +126,22 @@ tasks { } test { finalizedBy(jacocoTestReport) // report is always generated after tests run + testLogging { + // set options for log level LIFECYCLE +// events "failed" +// exceptionFormat "short" + + // set options for log level DEBUG + debug { +// events "started", "skipped", "failed" + exceptionFormat = TestExceptionFormat.FULL + } + + // remove standard output/error logging from --info builds + // by assigning only 'failed' and 'skipped' events +// info.events = ["failed", "skipped"] + showStandardStreams = true + } } jar { archiveVersion.set(rootProject.version.toString()) diff --git a/pom.xml b/pom.xml index 75a48644..914fbeb6 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ 0.8.1 1.0.0-beta-21 - 1.4.20 + 1.4.32-release-371 1.3.9 1.8 @@ -350,11 +350,27 @@ ${kotlin.version} test + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + - + - src/test/tests + src/test org.apache.maven.plugins @@ -390,34 +406,34 @@ compile - validate + compile compile - - src/main/java - target/generated-sources/kapt - target/generated-sources/kaptKotlin - - ${kotlin.compiler.jvmTarget} + ${kotlin.compiler.jvmTarget} -Werror -Xopt-in=kotlin.RequiresOptIn - + + src/main/java + src/main/kotlin + + test-compile test-compile test-compile - - - ${project.basedir}/src/test/tests - - - + + + src/test/java + src/test/kotlin + + + - ${kotlin.compiler.jvmTarget} + 1.8 -Werror -Xopt-in=kotlin.RequiresOptIn @@ -442,7 +458,15 @@ testCompile - + + default-compile + none + + + default-testCompile + none + + diff --git a/src/main/kotlin/sc/iview/SciView.kt b/src/main/kotlin/sc/iview/SciView.kt index 8b8a9b1f..9d024873 100644 --- a/src/main/kotlin/sc/iview/SciView.kt +++ b/src/main/kotlin/sc/iview/SciView.kt @@ -480,7 +480,10 @@ class SciView : SceneryBase, CalibratedRealInterval { * Center the camera on the specified Node */ fun centerOnPosition(currentPos: Vector3f?) { - controls.centerOnPosition(currentPos) + if(currentPos != null) { + controls.centerOnPosition(currentPos) + } + else { logger.info("The current position is null.") } } /** diff --git a/src/test/java/sc/iview/SciViewTest.java b/src/test/java/sc/iview/SciViewTest.java deleted file mode 100644 index da8af1fc..00000000 --- a/src/test/java/sc/iview/SciViewTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * #%L - * Scenery-backed 3D visualization package for ImageJ. - * %% - * Copyright (C) 2016 - 2021 SciView developers. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package sc.iview; - -import cleargl.GLVector; -import graphics.scenery.*; -import io.scif.SCIFIOService; -import net.imagej.ImageJService; -import org.joml.Vector3f; -import org.junit.Assert; -import org.scijava.Context; -import org.scijava.service.SciJavaService; -import org.scijava.thread.ThreadService; -import sc.iview.SciView; -import sc.iview.SciViewService; - -public class SciViewTest { - - //@Test - public void nodeDeletionTest() throws Exception { - SceneryBase.xinitThreads(); - - System.setProperty( "scijava.log.level:sc.iview", "debug" ); - Context context = new Context( ImageJService.class, SciJavaService.class, SCIFIOService.class, ThreadService.class); - - SciViewService sciViewService = context.service( SciViewService.class ); - SciView sciView = sciViewService.getOrCreateActiveSciView(); - - Node sphere = sciView.addSphere(); - - Assert.assertEquals( sciView.getAllSceneNodes().length, 7 ); - - sciView.deleteNode(sphere); - - Assert.assertEquals( sciView.getAllSceneNodes().length, 6 ); - - sciView.closeWindow(); - } - - //@Test - public void nestedNodeDeletionTest() throws Exception { - SceneryBase.xinitThreads(); - - System.setProperty( "scijava.log.level:sc.iview", "debug" ); - Context context = new Context( ImageJService.class, SciJavaService.class, SCIFIOService.class, ThreadService.class); - - SciViewService sciViewService = context.service( SciViewService.class ); - SciView sciView = sciViewService.getOrCreateActiveSciView(); - - Group group = new Group(); - - final Material material = new Material(); - material.setAmbient( new Vector3f( 1.0f, 0.0f, 0.0f ) ); - material.setDiffuse( new Vector3f( 1.0f, 0.0f, 0.0f ) ); - material.setSpecular( new Vector3f( 1.0f, 1.0f, 1.0f ) ); - - final Sphere sphere = new Sphere( 1, 20 ); - sphere.setMaterial( material ); - sphere.setPosition( new Vector3f(0,0,0) ); - //sphere.setParent(group); - group.addChild(sphere); - sciView.addNode(group); - - Assert.assertEquals( sciView.getAllSceneNodes().length, 7 ); - - sciView.deleteNode(group); - - Assert.assertEquals( sciView.getAllSceneNodes().length, 6 ); - - sciView.closeWindow(); - } - - // sceneResetTest() - - -} diff --git a/src/test/kotlin/sc/iview/ControlPointTests.kt b/src/test/kotlin/sc/iview/ControlPointTests.kt new file mode 100644 index 00000000..b29863f7 --- /dev/null +++ b/src/test/kotlin/sc/iview/ControlPointTests.kt @@ -0,0 +1,35 @@ +package sc.iview + +import graphics.scenery.Node +import org.joml.Vector3f +import org.junit.Test +import sc.iview.process.ControlPoints +import kotlin.test.assertTrue + +class ControlPointTests { + + @Test + fun testAddPoint() { + val controlPoints = ControlPoints() + val node = Node("testMe") + controlPoints.addPoint(node) + assertTrue(controlPoints.getNodes().contains(node)) + } + + @Test + fun testSetPoints() { + val controlPoints = ControlPoints() + val nodeList = arrayOf(Vector3f(1f, 2f, 3f), Vector3f(4f, 5f, 6f)) + controlPoints.setPoints(nodeList) + assertTrue { controlPoints.getNodes()[0].position == Vector3f(1f, 2f, 3f) } + } + + @Test + fun testInitializeSciView() { + val controlPoints = ControlPoints() + val sv = SciView.create() + val numberOfNodes = sv.allSceneNodes.size + controlPoints.initializeSciView(sv, 0f) + assertTrue { sv.allSceneNodes.size == numberOfNodes+1 } + } +} diff --git a/src/test/kotlin/sc/iview/Line3DTests.kt b/src/test/kotlin/sc/iview/Line3DTests.kt new file mode 100644 index 00000000..551ec8a5 --- /dev/null +++ b/src/test/kotlin/sc/iview/Line3DTests.kt @@ -0,0 +1,15 @@ +package sc.iview + +import junit.framework.Assert.assertNotNull +import org.junit.Test +import sc.iview.node.Line3D + +class Line3DTests { + + //tests if a bounding box becomes null when Line does not implement HasGeometry + @Test + fun testBoundingBox() { + val line = Line3D() + assertNotNull(line.generateBoundingBox()) + } +} diff --git a/src/test/kotlin/sc/iview/MeshConverterTests.kt b/src/test/kotlin/sc/iview/MeshConverterTests.kt new file mode 100644 index 00000000..e7eb6be1 --- /dev/null +++ b/src/test/kotlin/sc/iview/MeshConverterTests.kt @@ -0,0 +1,18 @@ +package sc.iview + +import graphics.scenery.Mesh +import org.junit.Test +import sc.iview.process.MeshConverter +import kotlin.test.assertEquals + +class MeshConverterTests { + + @Test + fun testToScenery() { + val mesh = Mesh("TestMe") + val convertedMesh = MeshConverter.toImageJ(mesh) + val reConvertedMesh = MeshConverter.toScenery(convertedMesh) + + assertEquals(mesh.children, reConvertedMesh.children) + } +} diff --git a/src/test/kotlin/sc/iview/RulerTests.kt b/src/test/kotlin/sc/iview/RulerTests.kt new file mode 100644 index 00000000..137d7ba6 --- /dev/null +++ b/src/test/kotlin/sc/iview/RulerTests.kt @@ -0,0 +1,18 @@ +package sc.iview + +import org.junit.Test +import sc.iview.controls.behaviours.Ruler +import kotlin.test.assertTrue + +class RulerTests { + + @Test + fun testRuler() { + val sv = SciView.create() + val numberOfNodes = sv.allSceneNodes.size + val ruler = Ruler(sv) + ruler.init(1, 2) + assertTrue { sv.allSceneNodes.size == numberOfNodes+1 } + + } +} diff --git a/src/test/kotlin/sc/iview/SciViewDisplayWindowTests.kt b/src/test/kotlin/sc/iview/SciViewDisplayWindowTests.kt new file mode 100644 index 00000000..6849815f --- /dev/null +++ b/src/test/kotlin/sc/iview/SciViewDisplayWindowTests.kt @@ -0,0 +1,15 @@ +package sc.iview + +import org.junit.Test +import sc.iview.display.SciViewDisplayWindow +import kotlin.test.assertEquals + +class SciViewDisplayWindowTests { + + @Test + fun findDisplayWindowTest() { + val sv = SciView.create() + val displayWindow = SciViewDisplayWindow(sv) + assertEquals(displayWindow.findDisplayContentScreenX(), 0) + } +} diff --git a/src/test/kotlin/sc/iview/SciViewTests.kt b/src/test/kotlin/sc/iview/SciViewTests.kt new file mode 100644 index 00000000..e65d1597 --- /dev/null +++ b/src/test/kotlin/sc/iview/SciViewTests.kt @@ -0,0 +1,168 @@ +/*- + * #%L + * Scenery-backed 3D visualization package for ImageJ. + * %% + * Copyright (C) 2016 - 2021 SciView developers. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package sc.iview + +import graphics.scenery.* +import graphics.scenery.SceneryBase.Companion.xinitThreads +import io.scif.SCIFIOService +import io.scif.services.DatasetIOService +import net.imagej.ImageJ +import net.imagej.ImageJService +import org.joml.Vector3f +import org.junit.Assert +import org.junit.Test +import org.scijava.Context +import org.scijava.service.SciJavaService +import org.scijava.thread.ThreadService +import org.scijava.ui.UIService +import sc.iview.SciView.Companion.create +import java.io.FileNotFoundException +import java.util.* + +class SciViewTests { + + + + @Test + @Throws(Exception::class) + fun nodeDeletionTest() { + xinitThreads() + System.setProperty("scijava.log.level:sc.iview", "debug") + val context = Context( + ImageJService::class.java, + SciJavaService::class.java, + SCIFIOService::class.java, + ThreadService::class.java + ) + val sciViewService = context.service(SciViewService::class.java) + val sciView = sciViewService.orCreateActiveSciView + val sphere: Node = sciView.addSphere() + Assert.assertEquals(sciView.allSceneNodes.size.toLong(), 7) + sciView.deleteNode(sphere) + Assert.assertEquals(sciView.allSceneNodes.size.toLong(), 6) + sciView.closeWindow() + } + + @Test + @Throws(Exception::class) + fun nestedNodeDeletionTest() { + xinitThreads() + System.setProperty("scijava.log.level:sc.iview", "debug") + val context = Context( + ImageJService::class.java, + SciJavaService::class.java, + SCIFIOService::class.java, + ThreadService::class.java + ) + val sciViewService = context.service(SciViewService::class.java) + val sciView = sciViewService.orCreateActiveSciView + val group = Group() + val material = Material() + material.ambient = Vector3f(1.0f, 0.0f, 0.0f) + material.diffuse = Vector3f(1.0f, 0.0f, 0.0f) + material.specular = Vector3f(1.0f, 1.0f, 1.0f) + val sphere = Sphere(1f, 20) + sphere.material = material + sphere.position = Vector3f(0f, 0f, 0f) + //sphere.setParent(group); + group.addChild(sphere) + sciView.addNode(group) + Assert.assertEquals(sciView.allSceneNodes.size.toLong(), 7) + sciView.deleteNode(group) + Assert.assertEquals(sciView.allSceneNodes.size.toLong(), 6) + sciView.closeWindow() + } + + @Test + @Throws(Exception::class) + fun deleteActiveMesh() { + System.setProperty("java.awt.headless", "false"); //Disables headless + val sciView = create() + val sphere: Node = sciView.addSphere() + sciView.setActiveNode(sphere) + sciView.deleteActiveNode() + Assert.assertNull(sciView.activeNode) + } + + @Test + @Throws(Exception::class) + fun deletedNodeNotFindable() { + System.setProperty("java.awt.headless", "false"); //Disables headless + val sciView = create() + val sphere: Node = sciView.addSphere() + sphere.name = "sphere" + sciView.deleteNode(sphere) + Assert.assertNotEquals(sphere, sciView.find("sphere")) + } + + @Test(expected = FileNotFoundException::class) + @Throws(Exception::class) + fun testOpenFunction() { + System.setProperty("java.awt.headless", "false"); //Disables headless + val sciView = create() + sciView.open("ThisShouldNotWork") + } + + @Test + fun openVolume() { + System.setProperty("java.awt.headless", "false"); //Disables headless + val sv = create() + val numberOfNodes = sv.allSceneNodes.size + sv.open("src/test/resources/mockFiles/sampleVolume.tiff") + assert(sv.allSceneNodes.size == numberOfNodes +1) + } + + @Test + fun testAlreadyOpenVolume() { + System.setProperty("java.awt.headless", "false"); //Disables headless + val sv = create() +// val context = sv.scijavaContext +// val ui = context?.service(UIService::class.java) + //TODO actually, how does one open volume files in SciJava on the coding level? + + } + + @Test(expected = IllegalArgumentException::class) + @Throws(Exception::class) + fun testOpenFunctionMockFile() { + System.setProperty("java.awt.headless", "false"); //Disables headless + val sciView = create() + sciView.open("src/test/resources/mockFiles/mockFile") + } + + @Test + @Throws(Exception::class) + fun verifyNullCheckForCenterOnPosition() { + System.setProperty("java.awt.headless", "false"); //Disables headless + val sciView = create() + sciView.centerOnPosition(null) + Assert.assertNull(null) + } +} diff --git a/src/test/kotlin/sc/iview/SwingMainWindowTests.kt b/src/test/kotlin/sc/iview/SwingMainWindowTests.kt new file mode 100644 index 00000000..2dc0ec97 --- /dev/null +++ b/src/test/kotlin/sc/iview/SwingMainWindowTests.kt @@ -0,0 +1,21 @@ +package sc.iview + +import junit.framework.Assert.* +import org.junit.Test +import sc.iview.ui.SwingMainWindow + +class SwingMainWindowTests { + + @Test + fun toggleSideBarTest() { + val sv = SciView.create() + val window = SwingMainWindow(sv) + if(!window.toggleSidebar()) { + print("yes") + assertNull(null) + } + else { + assertNotNull(null) + } + } +} diff --git a/src/test/kotlin/sc/iview/SwingNodePropertyEditorTests.kt b/src/test/kotlin/sc/iview/SwingNodePropertyEditorTests.kt new file mode 100644 index 00000000..26fa455a --- /dev/null +++ b/src/test/kotlin/sc/iview/SwingNodePropertyEditorTests.kt @@ -0,0 +1,14 @@ +package sc.iview + +import junit.framework.Assert.assertNull +import org.junit.Test +import sc.iview.ui.SwingNodePropertyEditor + +class SwingNodePropertyEditorTests { + @Test + fun testTrySelectedNode() { + val sv = SciView.create() + val swing = SwingNodePropertyEditor(sv) + assertNull(swing.currentNode) + } +} diff --git a/src/test/kotlin/sc/iview/SwingNodePropertyTreeCellRendererTests.kt b/src/test/kotlin/sc/iview/SwingNodePropertyTreeCellRendererTests.kt new file mode 100644 index 00000000..096d8531 --- /dev/null +++ b/src/test/kotlin/sc/iview/SwingNodePropertyTreeCellRendererTests.kt @@ -0,0 +1,15 @@ +package sc.iview + +import org.junit.Test +import sc.iview.ui.SwingNodePropertyTreeCellRenderer +import java.awt.Color +import kotlin.test.assertTrue + +class SwingNodePropertyTreeCellRendererTests { + + @Test + fun testColor() { + val snpcr = SwingNodePropertyTreeCellRenderer() + assertTrue{snpcr.background == Color.WHITE} + } +} diff --git a/src/test/kotlin/sc/iview/TaskManagerTests.kt b/src/test/kotlin/sc/iview/TaskManagerTests.kt new file mode 100644 index 00000000..18b68c8e --- /dev/null +++ b/src/test/kotlin/sc/iview/TaskManagerTests.kt @@ -0,0 +1,27 @@ +package sc.iview + +import org.junit.Test +import sc.iview.ui.Task +import sc.iview.ui.TaskManager +import kotlin.test.assertTrue + +class TaskManagerTests { + + @Test + fun addTaskTest() { + val taskManager = TaskManager() + val task = Task("source", "testing", 1f) + taskManager.addTask(task) + assertTrue{taskManager.currentTasks.contains(task)} + } + + @Test + fun removeTask() { + val taskManager = TaskManager() + val task = Task("source", "testing", 1f) + taskManager.addTask(task) + taskManager.removeTask(task) + assertTrue{!taskManager.currentTasks.contains(task)} + } + +} diff --git a/src/test/resources/mockFiles/mockFile b/src/test/resources/mockFiles/mockFile new file mode 100644 index 00000000..c1539868 --- /dev/null +++ b/src/test/resources/mockFiles/mockFile @@ -0,0 +1 @@ +This is a mock file to test wether sciView throws the right exception. \ No newline at end of file diff --git a/src/test/resources/mockFiles/sampleVolume.tiff b/src/test/resources/mockFiles/sampleVolume.tiff new file mode 100644 index 00000000..417e3955 Binary files /dev/null and b/src/test/resources/mockFiles/sampleVolume.tiff differ