Commit 6598d49a authored by Robert Smith's avatar Robert Smith
Browse files

Added tests for JavaFX Packages



Finished up the last set of tests for the JavaFX packages.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent 0b0f2e61
......@@ -35,6 +35,22 @@ import javafx.scene.Group;
*/
public class FXShapeControllerTester {
/**
* Check that FXShapeControllers can be properly cloned.
*/
@Test
public void checkClone() {
// Create a cloned FXShape and check that it is identical to the
// original
ShapeMesh mesh = new ShapeMesh();
FXShapeController shape = new FXShapeController(mesh,
new FXShapeView(mesh));
shape.setProperty("Test", "Property");
FXShapeController clone = (FXShapeController) shape.clone();
assertTrue(shape.equals(clone));
}
/**
* Test the FXShapeController's handling of the JavaFX Nodes' associations
* with ICE datastructures.
......
......@@ -33,6 +33,20 @@ import javafx.scene.shape.Sphere;
*/
public class FXShapeViewTester {
/**
* Test that FXShapeViews are cloned correctly
*/
@Test
public void checkClone() {
// Create a cloned view and check that it is identical to the original
ShapeMesh mesh = new ShapeMesh();
mesh.setProperty("Type", "Cube");
FXShapeView view = new FXShapeView(mesh);
FXShapeView clone = (FXShapeView) view.clone();
assertTrue(view.equals(clone));
}
/**
* Check that the view is constructed properly.
*/
......@@ -62,7 +76,7 @@ public class FXShapeViewTester {
assertTrue(((Shape3D) node).getDrawMode() == DrawMode.FILL);
// Check if a box has been found
if (view.getRepresentation() instanceof Box) {
if (node instanceof Box) {
boxFound = true;
}
}
......
......@@ -27,6 +27,24 @@ import org.junit.Test;
*/
public class FXHeatExchangerControllerTester {
/**
* Test that the FXHeatExchangerController is cloned correctly.
*/
@Test
public void checkClone() {
// Create a cloned FXHeatExchangerController and check that it is
// identical to the
// original
HeatExchangerMesh mesh = new HeatExchangerMesh();
FXHeatExchangerController exchanger = new FXHeatExchangerController(
mesh, new FXHeatExchangerView(mesh));
exchanger.setProperty("Test", "Property");
FXHeatExchangerController clone = (FXHeatExchangerController) exchanger
.clone();
assertTrue(exchanger.equals(clone));
}
/**
* Check that the exchanger will ignore Wireframe type messages except when
* they are sent by the controller's view.
......
......@@ -11,6 +11,7 @@
package org.eclipse.ice.viz.service.javafx.geometry.plant.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.eclipse.ice.viz.service.geometry.reactor.HeatExchangerMesh;
import org.eclipse.ice.viz.service.geometry.reactor.JunctionController;
......@@ -36,6 +37,19 @@ import javafx.scene.shape.MeshView;
*/
public class FXHeatExchangerViewTester {
/**
* Test that FXHeatExchangerViews are cloned correctly
*/
@Test
public void checkClone() {
// Create a cloned view and check that it is identical to the original
HeatExchangerMesh mesh = new HeatExchangerMesh();
FXHeatExchangerView view = new FXHeatExchangerView(mesh);
FXHeatExchangerView clone = (FXHeatExchangerView) view.clone();
assertTrue(view.equals(clone));
}
/**
* Check that the view produces the correct JavaFX output.
*/
......
......@@ -32,6 +32,19 @@ import javafx.scene.shape.Shape3D;
*/
public class FXJunctionViewTester {
/**
* Test that FXJunctionViews are cloned correctly
*/
@Test
public void checkClone() {
// Create a cloned view and check that it is identical to the original
JunctionMesh mesh = new JunctionMesh();
FXJunctionView view = new FXJunctionView(mesh);
FXJunctionView clone = (FXJunctionView) view.clone();
assertTrue(view.equals(clone));
}
/**
* Check that the junction is drawn in the right position to cover the ends
* of its pipes.
......
......@@ -26,6 +26,23 @@ import org.junit.Test;
*/
public class FXPipeViewTester {
/**
* Test that FXPipeViews are cloned correctly
*/
@Test
public void checkClone() {
// Create a cloned view and check that it is identical to the original
PipeMesh mesh = new PipeMesh();
mesh.setLength(100);
mesh.setInnerRadius(5);
mesh.setRadius(5);
mesh.setAxialSamples(3);
FXPipeView view = new FXPipeView(mesh);
FXPipeView clone = (FXPipeView) view.clone();
assertTrue(view.equals(clone));
}
/**
* Check that a pipe returns the bounds of its ends correctly
*/
......
......@@ -70,8 +70,7 @@ public class FXPlantViewRootControllerTester {
// The core channel should have been added to the reactor. The non-core
// channel pipe should not have been
assertTrue(
reactor.getEntitiesByCategory("Core Channels").contains(core));
assertTrue(reactor.getEntities().contains(core));
assertFalse(reactor.getEntities().contains(pipe));
// Create a second set of objects
......@@ -97,6 +96,23 @@ public class FXPlantViewRootControllerTester {
assertFalse(reactor2.getEntities().contains(pipe2));
}
/**
* Test that the FXPlantViewRootController is cloned correctly.
*/
@Test
public void checkClone() {
// Create a cloned FXPlantViewRootController and check that it is
// identical to the original
AbstractMesh mesh = new AbstractMesh();
FXPlantViewRootController root = new FXPlantViewRootController(mesh,
new AbstractView());
root.setProperty("Test", "Property");
FXPlantViewRootController clone = (FXPlantViewRootController) root
.clone();
assertTrue(root.equals(clone));
}
/**
* Check that the root sets the wireframe modes of its children correctly
*/
......
......@@ -35,6 +35,19 @@ import javafx.scene.shape.Shape3D;
*/
public class FXReactorViewTester {
/**
* Test that FXReactorViews are cloned correctly
*/
@Test
public void checkClone() {
// Create a cloned view and check that it is identical to the original
ReactorMesh mesh = new ReactorMesh();
FXReactorView view = new FXReactorView(mesh);
FXReactorView clone = (FXReactorView) view.clone();
assertTrue(view.equals(clone));
}
/**
* Check that the view sets its shapes to the proper drawmode for
* wireframes.
......
......@@ -447,10 +447,24 @@ public class FXHeatExchangerView extends AbstractView
}
// Notify listeners of the change
SubscriptionType[] eventTypes = {
SubscriptionType.WIREFRAME };
SubscriptionType[] eventTypes = { SubscriptionType.WIREFRAME };
updateManager.notifyListeners(eventTypes);
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#clone()
*/
@Override
public Object clone() {
// Create a new AbstractView and make it a copy of this
FXHeatExchangerView clone = new FXHeatExchangerView();
clone.copy(this);
return clone;
}
}
......@@ -224,6 +224,20 @@ public class FXJunctionView extends JunctionView implements IWireFramePart {
} else {
box.setDrawMode(DrawMode.FILL);
}
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#clone()
*/
@Override
public Object clone() {
// Create a new AbstractView and make it a copy of this
FXJunctionView clone = new FXJunctionView();
clone.copy(this);
return clone;
}
}
......@@ -220,4 +220,19 @@ public class FXPipeView extends FXShapeView implements IPipeView {
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.viz.service.modeling.AbstractView#clone()
*/
@Override
public Object clone() {
FXPipeView clone = new FXPipeView();
clone.copy(this);
// Force an update from the transformation
clone.transformation.setSize(clone.transformation.getSize());
return clone;
}
}
......@@ -155,4 +155,21 @@ public class FXPlantViewRootController extends AbstractController
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.viz.service.modeling.AbstractController#clone()
*/
@Override
public Object clone() {
// Create a new shape from clones of the model and view
FXPlantViewRootController clone = new FXPlantViewRootController();
// Copy any other data into the clone
clone.copy(this);
return clone;
}
}
......@@ -465,4 +465,18 @@ public class FXReactorView extends AbstractView implements IWireFramePart {
}
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#clone()
*/
@Override
public Object clone() {
// Create a new AbstractView and make it a copy of this
FXReactorView clone = new FXReactorView();
clone.copy(this);
return clone;
}
}
......@@ -27,6 +27,22 @@ import org.junit.Test;
*/
public class FXEdgeControllerTester {
/**
* Check that FXEdgeControllers can be properly cloned.
*/
@Test
public void checkClone() {
// Create a cloned FXShape and check that it is identical to the
// original
EdgeMesh mesh = new EdgeMesh();
FXEdgeController edge = new FXEdgeController(mesh,
new FXLinearEdgeView(mesh));
edge.setProperty("Test", "Property");
FXEdgeController clone = (FXEdgeController) edge.clone();
assertTrue(edge.equals(clone));
}
/**
* Check that the controller propagates properties changes to its children
* correctly.
......
/*******************************************************************************
* Copyright (c) 2016 UT-Battelle, LLC.
* 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:
* Robert Smith
*******************************************************************************/
package org.eclipse.ice.viz.service.javafx.mesh.datatypes;
import static org.junit.Assert.assertTrue;
import org.eclipse.ice.viz.service.modeling.FaceMesh;
import org.junit.Test;
/**
* A class to test the functionality of the FXFaceView.
*
* @author Robert Smith
*
*/
public class FXFaceViewTester {
/**
* Test that FXFaceViews are cloned correctly
*/
@Test
public void checkClone() {
// Create a cloned view and check that it is identical to the original
FaceMesh mesh = new FaceMesh();
FXFaceView view = new FXFaceView(mesh);
FXFaceView clone = (FXFaceView) view.clone();
assertTrue(view.equals(clone));
}
}
/*******************************************************************************
* Copyright (c) 2016 UT-Battelle, LLC.
* 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:
* Robert Smith
*******************************************************************************/
package org.eclipse.ice.viz.service.javafx.mesh.datatypes;
import static org.junit.Assert.assertTrue;
import org.eclipse.ice.viz.service.modeling.EdgeMesh;
import org.junit.Test;
/**
* A class to test the functionality of the FXLinearEdgeView.
*
* @author Robert Smith
*
*/
public class FXLinearEdgeViewTester {
/**
* Test that FXLinearViews are cloned correctly
*/
@Test
public void checkClone() {
// Create a cloned view and check that it is identical to the original
EdgeMesh mesh = new EdgeMesh();
FXLinearEdgeView view = new FXLinearEdgeView(mesh);
FXLinearEdgeView clone = (FXLinearEdgeView) view.clone();
assertTrue(view.equals(clone));
}
}
......@@ -27,6 +27,22 @@ import org.junit.Test;
*/
public class FXVertexControllerTester {
/**
* Check that FXEdgeControllers can be properly cloned.
*/
@Test
public void checkClone() {
// Create a cloned FXVertex and check that it is identical to the
// original
VertexMesh mesh = new VertexMesh();
FXVertexController vertex = new FXVertexController(mesh,
new FXVertexView(mesh));
vertex.setProperty("Test", "Property");
FXVertexController clone = (FXVertexController) vertex.clone();
assertTrue(vertex.equals(clone));
}
/**
* Checks that the controller correctly triggers refreshes in its view
*/
......
/*******************************************************************************
* Copyright (c) 2016 UT-Battelle, LLC.
* 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:
* Robert Smith
*******************************************************************************/
package org.eclipse.ice.viz.service.javafx.mesh.datatypes;
import static org.junit.Assert.assertTrue;
import org.eclipse.ice.viz.service.modeling.VertexMesh;
import org.junit.Test;
/**
* A class to test the functionality of the FXVertexView.
*
* @author Robert Smith
*
*/
public class FXVertexViewTester {
/**
* Test that FXLinearViews are cloned correctly
*/
@Test
public void checkClone() {
// Create a cloned view and check that it is identical to the original
VertexMesh mesh = new VertexMesh();
FXVertexView view = new FXVertexView(mesh);
FXVertexView clone = (FXVertexView) view.clone();
assertTrue(view.equals(clone));
}
}
......@@ -64,4 +64,20 @@ public class FXEdgeController extends EdgeController {
updateManager.flushQueue();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.viz.service.modeling.AbstractController#clone()
*/
@Override
public Object clone() {
// Clone the model and view
EdgeMesh modelClone = (EdgeMesh) model.clone();
AbstractView viewClone = (AbstractView) view.clone();
// Create a new controller for the clones and return it
FXEdgeController clone = new FXEdgeController(modelClone, viewClone);
return clone;
}
}
......@@ -30,6 +30,13 @@ public class FXFaceView extends AbstractView {
*/
Group node;
/**
* The nullary constructor.
*/
public FXFaceView() {
super();
}
/**
* The default constructor.
*
......@@ -49,4 +56,19 @@ public class FXFaceView extends AbstractView {
public Object getRepresentation() {
return node;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#clone()
*/
@Override
public Object clone() {
// Create a new AbstractView and make it a copy of this
FXFaceView clone = new FXFaceView();
clone.copy(this);
return clone;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment
</