Commit 768133f3 authored by Robert Smith's avatar Robert Smith
Browse files

Updated SWTBot and VIBE tests



Updated the tests for VIBE, as well as the SWTBOT UI tests.
Signed-off-by: Robert Smith's avatarRobert Smith <smithrw@ornl.gov>
parent 382df19e
...@@ -183,7 +183,7 @@ public class ReflectivityPage extends ICEResourcePage ...@@ -183,7 +183,7 @@ public class ReflectivityPage extends ICEResourcePage
Section listSection = formToolkit.createSection(sashForm, Section listSection = formToolkit.createSection(sashForm,
Section.TITLE_BAR | Section.DESCRIPTION | Section.TWISTIE Section.TITLE_BAR | Section.DESCRIPTION | Section.TWISTIE
| Section.EXPANDED | Section.COMPACT); | Section.EXPANDED | Section.COMPACT);
listSection.setLayout(new GridLayout(1, false)); listSection.setLayout(new GridLayout(1, false));
listSection.setLayoutData( listSection.setLayoutData(
new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
...@@ -243,9 +243,9 @@ public class ReflectivityPage extends ICEResourcePage ...@@ -243,9 +243,9 @@ public class ReflectivityPage extends ICEResourcePage
if (!newSelection.equals(selectedCell)) { if (!newSelection.equals(selectedCell)) {
selectedCell = newSelection; selectedCell = newSelection;
for (ISelectionChangedListener listener : listeners) { for (ISelectionChangedListener listener : listeners) {
listener.selectionChanged(new SelectionChangedEvent( listener.selectionChanged(
ReflectivityPage.this, ReflectivityPage.this new SelectionChangedEvent(ReflectivityPage.this,
.getSelection())); ReflectivityPage.this.getSelection()));
} }
} }
} }
...@@ -262,10 +262,12 @@ public class ReflectivityPage extends ICEResourcePage ...@@ -262,10 +262,12 @@ public class ReflectivityPage extends ICEResourcePage
// Create the resource form page contents // Create the resource form page contents
super.createFormContent(resourceForm); super.createFormContent(resourceForm);
//Open the properties view and set the focuse on this view to force the correct properties to display. // Open the properties view and set the focuse on this view to force the
// correct properties to display.
try { try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("org.eclipse.ui.propertiesView"); PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.showView("org.eclipse.ui.propertiesView");
} catch (PartInitException e) { } catch (PartInitException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -331,9 +333,9 @@ public class ReflectivityPage extends ICEResourcePage ...@@ -331,9 +333,9 @@ public class ReflectivityPage extends ICEResourcePage
list.getReadWriteLock().writeLock().unlock(); list.getReadWriteLock().writeLock().unlock();
} }
} }
} }
listTable.getTable().refresh(); listTable.getTable().refresh();
} }
...@@ -375,7 +377,7 @@ public class ReflectivityPage extends ICEResourcePage ...@@ -375,7 +377,7 @@ public class ReflectivityPage extends ICEResourcePage
} }
} }
} }
listTable.getTable().refresh(); listTable.getTable().refresh();
} }
...@@ -432,7 +434,7 @@ public class ReflectivityPage extends ICEResourcePage ...@@ -432,7 +434,7 @@ public class ReflectivityPage extends ICEResourcePage
} }
} }
listTable.getTable().refresh(); listTable.getTable().refresh();
} }
} }
...@@ -489,7 +491,7 @@ public class ReflectivityPage extends ICEResourcePage ...@@ -489,7 +491,7 @@ public class ReflectivityPage extends ICEResourcePage
listTable.setSelection(selected); listTable.setSelection(selected);
} }
} }
listTable.getTable().refresh(); listTable.getTable().refresh();
} }
} }
...@@ -515,7 +517,7 @@ public class ReflectivityPage extends ICEResourcePage ...@@ -515,7 +517,7 @@ public class ReflectivityPage extends ICEResourcePage
list.clear(); list.clear();
list.getReadWriteLock().writeLock().unlock(); list.getReadWriteLock().writeLock().unlock();
} }
listTable.getTable().refresh(); listTable.getTable().refresh();
} }
...@@ -676,7 +678,5 @@ public class ReflectivityPage extends ICEResourcePage ...@@ -676,7 +678,5 @@ public class ReflectivityPage extends ICEResourcePage
public void setSelection(ISelection selection) { public void setSelection(ISelection selection) {
// Do nothing, as we do not want this capability // Do nothing, as we do not want this capability
} }
} }
...@@ -30,7 +30,7 @@ public class MOOSETester extends AbstractWorkbenchTester { ...@@ -30,7 +30,7 @@ public class MOOSETester extends AbstractWorkbenchTester {
// Test the functionality of the Moose Actions drop down button // Test the functionality of the Moose Actions drop down button
@Test @Test
public void checkMooseActions() { public void checkMooseActions() {
// Open the MOOSE perspective // Open the MOOSE perspective
bot.menu("Window").menu("Perspective").menu("Open Perspective") bot.menu("Window").menu("Perspective").menu("Open Perspective")
.menu("Other...").click(); .menu("Other...").click();
...@@ -60,7 +60,7 @@ public class MOOSETester extends AbstractWorkbenchTester { ...@@ -60,7 +60,7 @@ public class MOOSETester extends AbstractWorkbenchTester {
// Open the add item dialog and add a MOOSE workflow // Open the add item dialog and add a MOOSE workflow
bot.viewByPartName("Item Viewer").setFocus(); bot.viewByPartName("Item Viewer").setFocus();
//bot.toolbarButton(0).click(); // bot.toolbarButton(0).click();
bot.toolbarButtonWithTooltip("Create an Item").click(); bot.toolbarButtonWithTooltip("Create an Item").click();
bot.list(0).select("MOOSE Workflow"); bot.list(0).select("MOOSE Workflow");
bot.button("Finish").click(); bot.button("Finish").click();
...@@ -85,11 +85,12 @@ public class MOOSETester extends AbstractWorkbenchTester { ...@@ -85,11 +85,12 @@ public class MOOSETester extends AbstractWorkbenchTester {
.equals("There are unsaved changes on the form.")); .equals("There are unsaved changes on the form."));
// Save and check that the header's text returned to normal. // Save and check that the header's text returned to normal.
try{ try {
bot.toolbarButtonWithTooltip("Save (Ctrl+S)").click(); bot.toolbarButtonWithTooltip("Save (Ctrl+S)").click();
//If the save button wasn't found with the windows/linux tooltip, try the mac tooltip // If the save button wasn't found with the windows/linux tooltip,
}catch(WidgetNotFoundException e){ // try the mac tooltip
} catch (WidgetNotFoundException e) {
bot.toolbarButtonWithTooltip("Save (\u2318S)").click(); bot.toolbarButtonWithTooltip("Save (\u2318S)").click();
} }
assertTrue(bot.clabel(0).getText().equals("Ready to process.")); assertTrue(bot.clabel(0).getText().equals("Ready to process."));
......
...@@ -127,6 +127,7 @@ public class ReflectivityModelTester extends AbstractWorkbenchTester { ...@@ -127,6 +127,7 @@ public class ReflectivityModelTester extends AbstractWorkbenchTester {
assertTrue("107Ag".equals(cellName)); assertTrue("107Ag".equals(cellName));
// Move it up two rows // Move it up two rows
table.selectCell(bot, 0, 5);
bot.button("^").click(); bot.button("^").click();
bot.button("^").click(); bot.button("^").click();
cellName = (String) realTable.getDataValueByPosition(1, 4); cellName = (String) realTable.getDataValueByPosition(1, 4);
......
...@@ -70,9 +70,12 @@ public class VIBEKeyValuePairTester extends AbstractWorkbenchTester { ...@@ -70,9 +70,12 @@ public class VIBEKeyValuePairTester extends AbstractWorkbenchTester {
// Change the first row's value to two // Change the first row's value to two
bot.table(1).click(0, 1); bot.table(1).click(0, 1);
bot.text().typeText("2"); bot.text("1 ", 0).setText("2");
bot.table(1).click(0, 0); bot.table(1).click(0, 0);
// Check that the cell was set
assertTrue("2".equals(bot.table(1).cell(0, 1)));
// Makes sure the form registers that it is dirty // Makes sure the form registers that it is dirty
assertTrue("There are unsaved changes on the form." assertTrue("There are unsaved changes on the form."
.equals(bot.clabel(0).getText())); .equals(bot.clabel(0).getText()));
...@@ -100,5 +103,37 @@ public class VIBEKeyValuePairTester extends AbstractWorkbenchTester { ...@@ -100,5 +103,37 @@ public class VIBEKeyValuePairTester extends AbstractWorkbenchTester {
bot.button("Go!").click(); bot.button("Go!").click();
assertTrue(bot.clabel(0).getText().equals("Done!")); assertTrue(bot.clabel(0).getText().equals("Done!"));
// Set the template to DualFoil
bot.radio(1).click();
// Check that a couple of the DualFoil's rows are set up correctly
assertTrue("NUMSEG".equals(bot.table(1).cell(14, 0)));
assertTrue("CUTOFFL".equals(bot.table(1).cell(17, 0)));
assertTrue("2.0,2.0,2.0,2.0,2.0".equals(bot.table(1).cell(17, 1)));
// Set the NUMSEG key to 8.
bot.table(1).click(14, 1);
bot.text("5", 0).setText("8");
bot.table(1).click(14, 0);
// CUTOFFL should have had its vector increased in size to account for
// the new NUMSEG value
assertTrue("2.0,2.0,2.0,2.0,2.0,0.0,0.0,0.0"
.equals(bot.table(1).cell(17, 1)));
// Set NUMSEG to 4
bot.table(1).click(14, 1);
bot.text("8", 0).setText("4");
bot.table(1).click(14, 0);
// CUTOFFL should have been reduced to only 4 numbers
assertTrue("2.0,2.0,2.0,2.0".equals(bot.table(1).cell(17, 1)));
// Set the template back to NTG
bot.radio(0).click();
// Check one of the rows to ensure that the NTG template has been loaded
assertTrue("CUTOFF".equals(bot.table(1).cell(15, 0)));
} }
} }
...@@ -155,15 +155,11 @@ public class VIBEModelTester extends AbstractWorkbenchTester { ...@@ -155,15 +155,11 @@ public class VIBEModelTester extends AbstractWorkbenchTester {
// Check each of the port types available in the menu and check the // Check each of the port types available in the menu and check the
// number of text fields they display. // number of text fields they display.
// FIXME INIT_STATE, CHARTRAN_ElECTRICAL_THERMAL_DRIVER, and NTG have
// different variables available for editing between the default
// provided sockets and the ones added by the button. Need to figure out
// if this is intentional.
bot.button(2).click(); bot.button(2).click();
bot.table().select("INIT_STATE"); bot.table().select("INIT_STATE");
bot.button("OK").click(); bot.button("OK").click();
// bot.table(1).select(5); bot.table(1).select(5);
// bot.text(13).typeText("Test"); bot.text(13).typeText("Test");
bot.button(2).click(); bot.button(2).click();
bot.table().select("AMPERES_THERMAL"); bot.table().select("AMPERES_THERMAL");
...@@ -180,14 +176,14 @@ public class VIBEModelTester extends AbstractWorkbenchTester { ...@@ -180,14 +176,14 @@ public class VIBEModelTester extends AbstractWorkbenchTester {
bot.button(2).click(); bot.button(2).click();
bot.table().select("CHARTRAN_ELECTRICAL_THERMAL_DRIVER"); bot.table().select("CHARTRAN_ELECTRICAL_THERMAL_DRIVER");
bot.button("OK").click(); bot.button("OK").click();
// bot.table(1).select(8); bot.table(1).select(8);
// bot.text(11).typeText("Test"); bot.text(12).typeText("Test");
bot.button(2).click(); bot.button(2).click();
bot.table().select("NTG"); bot.table().select("NTG");
bot.button("OK").click(); bot.button("OK").click();
// bot.table(1).select(9); bot.table(1).select(9);
// bot.text(13).typeText("Test"); bot.text(14).typeText("Test");
bot.button(2).click(); bot.button(2).click();
bot.table().select("DUALFOIL"); bot.table().select("DUALFOIL");
...@@ -197,9 +193,21 @@ public class VIBEModelTester extends AbstractWorkbenchTester { ...@@ -197,9 +193,21 @@ public class VIBEModelTester extends AbstractWorkbenchTester {
// table to see if it was added instead. // table to see if it was added instead.
assertEquals(11, bot.table(1).rowCount()); assertEquals(11, bot.table(1).rowCount());
bot.button(2).click();
bot.table().select("AMPERES");
bot.button("OK").click();
bot.table(1).select(11);
bot.text(14).typeText("Test");
bot.button(2).click();
bot.table().select("CHARTRAN_THERMAL_DRIVER");
bot.button("OK").click();
bot.table(1).select(12);
bot.text(10).typeText("Test");
// Delete a row and make sure it's gone // Delete a row and make sure it's gone
bot.table().select(0); bot.table().select(0);
bot.button("Delete").click(); bot.button("Delete").click();
assertTrue("11 DUALFOIL".equals(bot.table(1).cell(9, 0))); assertTrue("11 DUALFOIL".equals(bot.table(1).cell(10, 0)));
} }
} }
/*******************************************************************************
* 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.vibe.kvPair.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.eclipse.ice.datastructures.ICEObject.IUpdateable;
import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener;
import org.eclipse.ice.datastructures.entry.StringEntry;
import org.eclipse.ice.vibe.kvPair.VibeKVPairRow;
import org.junit.Test;
/**
* A class to test the functionality of the VibeKVPairRow
*
* @author Robert Smith
*
*/
public class VibeKVPairRowTester {
/**
* Test that rows can be cloned and copied.
*/
@Test
public void checkClone() {
// Initialize the test row
StringEntry testKey = new StringEntry();
StringEntry testValue = new StringEntry();
VibeKVPairRow row = new VibeKVPairRow(testKey, testValue);
// Set some values to the row
testKey.setValue("key");
testValue.setValue("value");
row.setName("row");
// Initialize another row
VibeKVPairRow copyRow = new VibeKVPairRow(new StringEntry(),
new StringEntry());
// Copy the first row's data into the second
copyRow.copy(row);
// Check that the data members were all copied correctly
assertTrue("key".equals(copyRow.getKey().getValue()));
assertTrue("value".equals(copyRow.getValue().getValue()));
assertTrue("row".equals(copyRow.getName()));
// Clone the row
VibeKVPairRow clone = (VibeKVPairRow) row.clone();
// Check that the data members were all copied correctly
assertTrue("key".equals(clone.getKey().getValue()));
assertTrue("value".equals(clone.getValue().getValue()));
assertTrue("row".equals(clone.getName()));
}
/**
* Check that the getters and setters for the class work correctly.
*/
@Test
public void checkSetters() {
// Initiailze the test row
StringEntry testKey = new StringEntry();
StringEntry testValue = new StringEntry();
VibeKVPairRow row = new VibeKVPairRow(testKey, testValue);
// Check that the key and value entries are correct
assertTrue(testKey == row.getKey());
assertTrue(testValue == row.getValue());
// Check the context methods
row.setContext("context");
assertTrue("context".equals(row.getContext()));
// Check the description methods
row.setDescription("description");
assertTrue("description".equals(row.getDescription()));
// Check the ID methods
row.setId(2);
assertEquals(2, row.getId());
// Check the name methods
row.setName("name");
assertTrue("name".equals(row.getName()));
}
/**
* Test the row's ability to give and receive updates
*/
@Test
public void checkUpdate() {
// Initiailze the test row
StringEntry testKey = new StringEntry();
StringEntry testValue = new StringEntry();
VibeKVPairRow row = new VibeKVPairRow(testKey, testValue);
// Add a listener
TestListener listener = new TestListener(row);
listener.wasUpdated();
// Update the value and make sure that the listener was notified.
testValue.setValue("test");
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail("Exception while waiting for update.");
}
assertTrue(listener.wasUpdated());
}
/**
* A simple class to listen to a VibeKVPairRow and record when it sends an
* update.
*
* @author Robert Smith
*
*/
private class TestListener implements IUpdateableListener {
/**
* Whether or not this object has received an update since the last time
* it was checked.
*/
private boolean updated = false;
public TestListener(VibeKVPairRow row) {
row.register(this);
}
/**
* Checks whether the listener was updated since the last time this
* message was called
*
* @return True if update() was called since the last time this method
* was invoked. False otherwise.
*/
public boolean wasUpdated() {
boolean temp = updated;
updated = false;
return temp;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ice.datastructures.ICEObject.IUpdateableListener#update(
* org.eclipse.ice.datastructures.ICEObject.IUpdateable)
*/
@Override
public void update(IUpdateable component) {
updated = true;
}
}
}
...@@ -17,6 +17,8 @@ import static org.junit.Assert.assertNotNull; ...@@ -17,6 +17,8 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.util.ArrayList;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
...@@ -26,8 +28,11 @@ import org.eclipse.core.runtime.CoreException; ...@@ -26,8 +28,11 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.ice.datastructures.ICEObject.Component;
import org.eclipse.ice.datastructures.form.DataComponent;
import org.eclipse.ice.datastructures.form.Form; import org.eclipse.ice.datastructures.form.Form;
import org.eclipse.ice.datastructures.form.FormStatus; import org.eclipse.ice.datastructures.form.FormStatus;
import org.eclipse.ice.datastructures.form.TableComponent;
import org.eclipse.ice.vibe.kvPair.VibeKVPair; import org.eclipse.ice.vibe.kvPair.VibeKVPair;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
...@@ -138,6 +143,119 @@ public class VibeKVPairTester { ...@@ -138,6 +143,119 @@ public class VibeKVPairTester {
vibeKVPair.getDescription()); vibeKVPair.getDescription());
} }
/**
* Test that changing the template will set the table up appropriately.
*/
@Test
public void checkTemplates() {
VibeKVPair vibeKVPair;
IProject project = projectSpace;
// Create a VibeLauncher