aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernd Hufmann2013-03-14 16:12:40 (EDT)
committerBernd Hufmann2013-03-14 18:44:52 (EDT)
commit01abb8d8c4f67163147e3c0ac0a6b32e68e07ea1 (patch)
treee8417f21353c8bc8921359fdec0a41308e4b81ac
parent81419e5fbe524df94d0e6abec98fe17731e88a49 (diff)
downloadorg.eclipse.linuxtools-01abb8d8c4f67163147e3c0ac0a6b32e68e07ea1.zip
org.eclipse.linuxtools-01abb8d8c4f67163147e3c0ac0a6b32e68e07ea1.tar.gz
org.eclipse.linuxtools-01abb8d8c4f67163147e3c0ac0a6b32e68e07ea1.tar.bz2
tmf ui: Make UML2SD UI tests independent from each otherrefs/changes/71/11171/3
This fixes the problem introduced when using JUnit version 4.11 where the order of test execution within a file is not the order in the file. Change-Id: I49ac3560c2cb5138c3dc606524a9a741d9827a2a Signed-off-by: Bernd Hufmann <bhufmann@gmail.com> Reviewed-on: https://git.eclipse.org/r/11171 Tested-by: Hudson CI Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderFilterTest.java44
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderFindTest.java66
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/Uml2SDSignalValidator.java12
3 files changed, 83 insertions, 39 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderFilterTest.java b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderFilterTest.java
index 0c47012..26aa414 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderFilterTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderFilterTest.java
@@ -24,7 +24,9 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.Criteria;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.FilterCriteria;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader.TmfSyncMessage;
+import org.junit.After;
import org.junit.AfterClass;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -52,7 +54,7 @@ public class TmfUml2SDSyncLoaderFilterTest {
Criteria criteria = new Criteria();
criteria.setLifeLineSelected(true);
criteria.setExpression(IUml2SDTestConstants.FIRST_PLAYER_NAME);
- filterToSave.add(new FilterCriteria(criteria, true, false));
+ filterToSave.add(new FilterCriteria(criteria, false, false));
criteria = new Criteria();
criteria.setLifeLineSelected(true);
@@ -75,6 +77,27 @@ public class TmfUml2SDSyncLoaderFilterTest {
}
/**
+ * Test Case set-up code.
+ */
+ @Before
+ public void beforeTest(){
+ // Make sure we are at the first page
+ fFacility.firstPage();
+ }
+
+ /**
+ * Test case clean-up code.
+ */
+ @After
+ public void afterTest() {
+ filterToSave.get(0).setActive(false);
+ filterToSave.get(1).setActive(false);
+ filterToSave.get(2).setActive(false);
+ fFacility.getLoader().filter(filterToSave);
+ fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
+ }
+
+ /**
* Verify the filter lifelines (1 out of 2 is hidden)
*
* Verified Methods: loader.filter()
@@ -82,6 +105,9 @@ public class TmfUml2SDSyncLoaderFilterTest {
*/
@Test
public void verifyFilter1of2() {
+ // Initialize the filter
+ filterToSave.get(0).setActive(true);
+ // Run the filter
fFacility.getLoader().filter(filterToSave);
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
@@ -99,7 +125,10 @@ public class TmfUml2SDSyncLoaderFilterTest {
*/
@Test
public void verifyFilter2of2() {
+ // Initialize the filter
+ filterToSave.get(0).setActive(true);
filterToSave.get(1).setActive(true);
+ // Run the filter
fFacility.getLoader().filter(filterToSave);
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
@@ -115,6 +144,13 @@ public class TmfUml2SDSyncLoaderFilterTest {
*/
@Test
public void verifyRemoval() {
+ // First set 2 filter
+ filterToSave.get(0).setActive(true);
+ filterToSave.get(1).setActive(true);
+ fFacility.getLoader().filter(filterToSave);
+ fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
+
+ // Remove the filter
filterToSave.get(0).setActive(false);
filterToSave.get(1).setActive(false);
fFacility.getLoader().filter(filterToSave);
@@ -133,7 +169,9 @@ public class TmfUml2SDSyncLoaderFilterTest {
*/
@Test
public void verifyMessageFilter() {
+ // Initialize the filter
filterToSave.get(2).setActive(true);
+ // Run the filter
fFacility.getLoader().filter(filterToSave);
fFacility.delay(IUml2SDTestConstants.GUI_REFESH_DELAY);
@@ -160,7 +198,7 @@ public class TmfUml2SDSyncLoaderFilterTest {
@Test
public void verifyFilter1of3() {
filterToSave.get(0).setActive(true);
- filterToSave.get(2).setActive(false);
+ fFacility.getLoader().filter(filterToSave);
fFacility.setPage(IUml2SDTestConstants.PAGE_OF_ALL_LIFELINES);
assertEquals("filter", 2, fFacility.getSdView().getFrame().lifeLinesCount());
@@ -172,7 +210,5 @@ public class TmfUml2SDSyncLoaderFilterTest {
}
assertTrue(fFacility.getSdView().getFrame().syncMessageCount() > 0);
-
- filterToSave.get(2).setActive(false);
}
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderFindTest.java b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderFindTest.java
index b66c0df..c3e60a4 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderFindTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/TmfUml2SDSyncLoaderFindTest.java
@@ -97,6 +97,7 @@ public class TmfUml2SDSyncLoaderFindTest {
public static void setUpClass() {
fFacility = Uml2SDTestFacility.getInstance();
fFacility.selectExperiment();
+ fTmfComponent = new Uml2SDSignalValidator();
}
/**
@@ -104,6 +105,7 @@ public class TmfUml2SDSyncLoaderFindTest {
*/
@AfterClass
public static void tearDownClass() {
+ fTmfComponent.dispose();
fFacility.disposeExperiment();
fFacility = null;
}
@@ -117,7 +119,8 @@ public class TmfUml2SDSyncLoaderFindTest {
*/
@Test
public void verifyISDGraphNodeSupporter() {
- fTmfComponent = new Uml2SDSignalValidator();
+
+ fFacility.firstPage();
assertTrue("isNodeSupported", fFacility.getLoader().isNodeSupported(ISDGraphNodeSupporter.LIFELINE));
assertTrue("isNodeSupported", fFacility.getLoader().isNodeSupported(ISDGraphNodeSupporter.SYNCMESSAGE));
@@ -144,6 +147,8 @@ public class TmfUml2SDSyncLoaderFindTest {
*/
@Test
public void verifyFirstMessage() {
+ fFacility.firstPage();
+
criteria = new Criteria();
criteria.setSyncMessageSelected(true);
criteria.setExpression("GAME_.*");
@@ -174,16 +179,14 @@ public class TmfUml2SDSyncLoaderFindTest {
assertEquals("find", TC_002_END_OCCURRANCE, msg.getEndOccurrence());
assertEquals("find", TC_002_START_LIFELINE, msg.getStartLifeline().getName());
assertEquals("find", TC_002_END_LIFELINE, msg.getEndLifeline().getName());
- }
- /**
- * Verify 2nd message find within page.
- *
- * Verified Methods: loader.find(), loader.moveToMessage()
- * Expected result: Correct message is selected
- */
- @Test
- public void verifySecondMessage() {
+ /**
+ * Verify 2nd message find within page.
+ *
+ * Verified Methods: loader.find(), loader.moveToMessage()
+ * Expected result: Correct message is selected
+ */
+
// set expected values
fTmfComponent.setSource(fFacility.getLoader());
fTmfComponent.setCurrentTime(TC_003_TIME_VALUE);
@@ -211,16 +214,13 @@ public class TmfUml2SDSyncLoaderFindTest {
assertEquals("find", TC_003_END_OCCURRANCE, msg.getEndOccurrence());
assertEquals("find", TC_003_START_LIFELINE, msg.getStartLifeline().getName());
assertEquals("find", TC_003_END_LIFELINE, msg.getEndLifeline().getName());
- }
- /**
- * Verify 1st message across page.
- *
- * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
- * Expected result: Correct message is selected
- */
- @Test
- public void verifyFirstMesage() {
+ /**
+ * Verify 1st message across page.
+ *
+ * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
+ * Expected result: Correct message is selected
+ */
// set expected values
fTmfComponent.setSource(fFacility.getLoader());
fTmfComponent.setCurrentTime(TC_004_TIME_VALUE);
@@ -255,7 +255,6 @@ public class TmfUml2SDSyncLoaderFindTest {
// cancel find and go back to first page
fFacility.getLoader().cancel();
- fFacility.firstPage();
}
/**
@@ -266,6 +265,8 @@ public class TmfUml2SDSyncLoaderFindTest {
*/
@Test
public void verifyFind() {
+ fFacility.firstPage();
+
criteria = new Criteria();
criteria.setLifeLineSelected(true);
criteria.setExpression(IUml2SDTestConstants.FIRST_PLAYER_NAME);
@@ -280,16 +281,13 @@ public class TmfUml2SDSyncLoaderFindTest {
assertTrue(selection.get(0) instanceof Lifeline);
lifeline = (Lifeline) selection.get(0);
assertEquals("find", TC_005_LIFELINE_NAME, lifeline.getName());
- }
- /**
- * Verify lifeline across page.
- *
- * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
- * Expected result: Correct message is selected
- */
- @Test
- public void verifyLifeline() {
+ /**
+ * Verify lifeline across page.
+ *
+ * Verified Methods: loader.find(), loader.moveToPage(), loader.moveToMessage()
+ * Expected result: Correct message is selected
+ */
criteria = new Criteria();
criteria.setLifeLineSelected(true);
criteria.setExpression(IUml2SDTestConstants.SECOND_PLAYER_NAME);
@@ -309,10 +307,8 @@ public class TmfUml2SDSyncLoaderFindTest {
lifeline = (Lifeline) selection.get(0);
assertEquals("find", TC_006_LIFELINE_NAME, lifeline.getName());
-
// cancel find and go back to first page
fFacility.getLoader().cancel();
- fFacility.firstPage();
}
/**
@@ -323,6 +319,9 @@ public class TmfUml2SDSyncLoaderFindTest {
*/
@Test
public void verifyCancelSearch() {
+
+ fFacility.firstPage();
+
criteria = new Criteria();
criteria.setLifeLineSelected(true);
criteria.setExpression(IUml2SDTestConstants.SECOND_PLAYER_NAME);
@@ -332,6 +331,9 @@ public class TmfUml2SDSyncLoaderFindTest {
fFacility.getLoader().cancel();
assertEquals("find", 0, fFacility.getLoader().currentPage()); // we are still at the first page
- fTmfComponent.dispose();
+
+ // cancel find and go back to first page
+ fFacility.getLoader().cancel();
+ fFacility.firstPage();
}
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/Uml2SDSignalValidator.java b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/Uml2SDSignalValidator.java
index 85c591f..6f6bd81 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/Uml2SDSignalValidator.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/views/uml2sd/loader/Uml2SDSignalValidator.java
@@ -73,9 +73,15 @@ public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignal
public void synchToTimeRange(TmfRangeSynchSignal signal) {
// Set results so that it can be validated in the test case
setSignalReceived(true);
- setSourceError(getSource() != signal.getSource());
- setCurrentTimeError(!getCurrentTime().equals(signal.getCurrentTime()));
- setRangeError(!getCurrentRange().equals(signal.getCurrentRange()));
+ if (getSource() != null) {
+ setSourceError(getSource() != signal.getSource());
+ }
+ if (getCurrentTime() != null) {
+ setCurrentTimeError(!getCurrentTime().equals(signal.getCurrentTime()));
+ }
+ if (getCurrentRange() != null) {
+ setRangeError(!getCurrentRange().equals(signal.getCurrentRange()));
+ }
}
/**