[615] | 1 | // Module : $RCSfile: AbstractDefaultGUIElementTest.java,v $ |
---|
| 2 | // Version : $Revision: 0.0 $ $Author: pharms $ $Date: 24.08.2012 $ |
---|
| 3 | // Project : quest-core-events-test |
---|
| 4 | // Creation : 2012 by pharms |
---|
| 5 | // Copyright : Patrick Harms, 2012 |
---|
| 6 | package de.ugoe.cs.quest.eventcore.guimodel; |
---|
| 7 | |
---|
| 8 | import static org.junit.Assert.*; |
---|
| 9 | |
---|
| 10 | import org.junit.Test; |
---|
| 11 | |
---|
| 12 | /** |
---|
| 13 | * <p> |
---|
| 14 | * TODO comment |
---|
| 15 | * </p> |
---|
| 16 | * |
---|
| 17 | * @version $Revision: $ $Date: 24.08.2012$ |
---|
| 18 | * @author 2012, last modified by $Author: pharms$ |
---|
| 19 | */ |
---|
| 20 | public class AbstractDefaultGUIElementTest { |
---|
| 21 | |
---|
| 22 | /** |
---|
| 23 | * <p> |
---|
| 24 | * TODO: comment |
---|
| 25 | * </p> |
---|
| 26 | */ |
---|
| 27 | @Test |
---|
| 28 | public void testRegisteringEqualGuiElements() { |
---|
| 29 | IGUIElement guiElement1 = new AbstractDefaultGUIElementTestImpl(); |
---|
| 30 | IGUIElement guiElement2 = new AbstractDefaultGUIElementTestImpl(); |
---|
| 31 | |
---|
| 32 | assertCompletelyUnequal(guiElement1, guiElement2); |
---|
| 33 | |
---|
| 34 | guiElement1.addEqualGUIElement(guiElement2); |
---|
| 35 | assertCompletelyEqual(guiElement1, guiElement2); |
---|
| 36 | |
---|
| 37 | IGUIElement guiElement3 = new AbstractDefaultGUIElementTestImpl(); |
---|
| 38 | |
---|
| 39 | assertCompletelyEqual(guiElement1, guiElement2); |
---|
| 40 | assertCompletelyUnequal(guiElement1, guiElement3); |
---|
| 41 | assertCompletelyUnequal(guiElement2, guiElement3); |
---|
| 42 | |
---|
| 43 | guiElement1.addEqualGUIElement(guiElement3); |
---|
| 44 | assertCompletelyEqual(guiElement1, guiElement2, guiElement3); |
---|
| 45 | |
---|
| 46 | IGUIElement guiElement4 = new AbstractDefaultGUIElementTestImpl(); |
---|
| 47 | |
---|
| 48 | assertCompletelyEqual(guiElement1, guiElement2, guiElement3); |
---|
| 49 | assertCompletelyUnequal(guiElement1, guiElement4); |
---|
| 50 | assertCompletelyUnequal(guiElement2, guiElement4); |
---|
| 51 | assertCompletelyUnequal(guiElement3, guiElement4); |
---|
| 52 | |
---|
| 53 | guiElement3.addEqualGUIElement(guiElement4); |
---|
| 54 | assertCompletelyEqual(guiElement1, guiElement2, guiElement3, guiElement4); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | /** |
---|
| 58 | * <p> |
---|
| 59 | * |
---|
| 60 | * </p> |
---|
| 61 | */ |
---|
| 62 | private void assertCompletelyUnequal(IGUIElement... guiElements) { |
---|
| 63 | for (int i = 0; i < guiElements.length; i++) { |
---|
| 64 | for (int j = i + 1; j < guiElements.length; j++) { |
---|
| 65 | assertFalse(guiElements[i].equals(guiElements[j])); |
---|
| 66 | assertFalse(guiElements[j].equals(guiElements[i])); |
---|
| 67 | assertNotSame(guiElements[i].hashCode(), guiElements[j].hashCode()); |
---|
| 68 | } |
---|
| 69 | } |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | /** |
---|
| 73 | * <p> |
---|
| 74 | * |
---|
| 75 | * </p> |
---|
| 76 | */ |
---|
| 77 | private void assertCompletelyEqual(IGUIElement... guiElements) { |
---|
| 78 | for (int i = 0; i < guiElements.length; i++) { |
---|
| 79 | for (int j = i; j < guiElements.length; j++) { |
---|
| 80 | assertTrue(guiElements[i].equals(guiElements[j])); |
---|
| 81 | assertTrue(guiElements[j].equals(guiElements[i])); |
---|
| 82 | assertEquals(guiElements[i].hashCode(), guiElements[j].hashCode()); |
---|
| 83 | } |
---|
| 84 | } |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | /** |
---|
| 88 | * <p> |
---|
| 89 | * TODO comment |
---|
| 90 | * </p> |
---|
| 91 | * |
---|
| 92 | * @version $Revision: $ $Date: 24.08.2012$ |
---|
| 93 | * @author 2012, last modified by $Author: pharms$ |
---|
| 94 | */ |
---|
| 95 | public class AbstractDefaultGUIElementTestImpl extends AbstractDefaultGUIElement |
---|
| 96 | implements IGUIElement |
---|
| 97 | { |
---|
| 98 | |
---|
| 99 | /** |
---|
| 100 | * <p> |
---|
| 101 | * TODO: comment |
---|
| 102 | * </p> |
---|
| 103 | * |
---|
| 104 | * @param specification |
---|
| 105 | * @param parent |
---|
| 106 | */ |
---|
| 107 | public AbstractDefaultGUIElementTestImpl() { |
---|
| 108 | super(null, null); |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | /** */ |
---|
| 112 | private static final long serialVersionUID = 1L; |
---|
| 113 | |
---|
| 114 | /* (non-Javadoc) |
---|
| 115 | * @see de.ugoe.cs.quest.eventcore.IEventTarget#getPlatform() |
---|
| 116 | */ |
---|
| 117 | @Override |
---|
| 118 | public String getPlatform() { |
---|
| 119 | return "TEST"; |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | /* (non-Javadoc) |
---|
| 123 | * @see de.ugoe.cs.quest.eventcore.guimodel.IGUIElement#updateSpecification(de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec) |
---|
| 124 | */ |
---|
| 125 | @Override |
---|
| 126 | public void updateSpecification(IGUIElementSpec furtherSpec) { |
---|
| 127 | throw new UnsupportedOperationException(); |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | } |
---|