1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany |
---|
2 | // |
---|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
---|
4 | // you may not use this file except in compliance with the License. |
---|
5 | // You may obtain a copy of the License at |
---|
6 | // |
---|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
---|
8 | // |
---|
9 | // Unless required by applicable law or agreed to in writing, software |
---|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
---|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
12 | // See the License for the specific language governing permissions and |
---|
13 | // limitations under the License. |
---|
14 | |
---|
15 | package de.ugoe.cs.autoquest.eventcore.guimodel; |
---|
16 | |
---|
17 | import static org.junit.Assert.*; |
---|
18 | |
---|
19 | import org.junit.Test; |
---|
20 | |
---|
21 | import de.ugoe.cs.autoquest.eventcore.guimodel.AbstractDefaultGUIElement; |
---|
22 | import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; |
---|
23 | import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec; |
---|
24 | |
---|
25 | /** |
---|
26 | * <p> |
---|
27 | * TODO comment |
---|
28 | * </p> |
---|
29 | * |
---|
30 | * @version $Revision: $ $Date: 24.08.2012$ |
---|
31 | * @author 2012, last modified by $Author: pharms$ |
---|
32 | */ |
---|
33 | public class AbstractDefaultGUIElementTest { |
---|
34 | |
---|
35 | /** |
---|
36 | * <p> |
---|
37 | * TODO: comment |
---|
38 | * </p> |
---|
39 | */ |
---|
40 | @Test |
---|
41 | public void testRegisteringEqualGuiElements() { |
---|
42 | IGUIElement guiElement1 = new AbstractDefaultGUIElementTestImpl(); |
---|
43 | IGUIElement guiElement2 = new AbstractDefaultGUIElementTestImpl(); |
---|
44 | |
---|
45 | assertCompletelyUnequal(guiElement1, guiElement2); |
---|
46 | |
---|
47 | guiElement1.addEqualGUIElement(guiElement2); |
---|
48 | assertCompletelyEqual(guiElement1, guiElement2); |
---|
49 | |
---|
50 | IGUIElement guiElement3 = new AbstractDefaultGUIElementTestImpl(); |
---|
51 | |
---|
52 | assertCompletelyEqual(guiElement1, guiElement2); |
---|
53 | assertCompletelyUnequal(guiElement1, guiElement3); |
---|
54 | assertCompletelyUnequal(guiElement2, guiElement3); |
---|
55 | |
---|
56 | guiElement1.addEqualGUIElement(guiElement3); |
---|
57 | assertCompletelyEqual(guiElement1, guiElement2, guiElement3); |
---|
58 | |
---|
59 | IGUIElement guiElement4 = new AbstractDefaultGUIElementTestImpl(); |
---|
60 | |
---|
61 | assertCompletelyEqual(guiElement1, guiElement2, guiElement3); |
---|
62 | assertCompletelyUnequal(guiElement1, guiElement4); |
---|
63 | assertCompletelyUnequal(guiElement2, guiElement4); |
---|
64 | assertCompletelyUnequal(guiElement3, guiElement4); |
---|
65 | |
---|
66 | guiElement3.addEqualGUIElement(guiElement4); |
---|
67 | assertCompletelyEqual(guiElement1, guiElement2, guiElement3, guiElement4); |
---|
68 | } |
---|
69 | |
---|
70 | /** |
---|
71 | * <p> |
---|
72 | * |
---|
73 | * </p> |
---|
74 | */ |
---|
75 | private void assertCompletelyUnequal(IGUIElement... guiElements) { |
---|
76 | for (int i = 0; i < guiElements.length; i++) { |
---|
77 | for (int j = i + 1; j < guiElements.length; j++) { |
---|
78 | assertFalse(guiElements[i].equals(guiElements[j])); |
---|
79 | assertFalse(guiElements[j].equals(guiElements[i])); |
---|
80 | assertNotSame(guiElements[i].hashCode(), guiElements[j].hashCode()); |
---|
81 | } |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | /** |
---|
86 | * <p> |
---|
87 | * |
---|
88 | * </p> |
---|
89 | */ |
---|
90 | private void assertCompletelyEqual(IGUIElement... guiElements) { |
---|
91 | for (int i = 0; i < guiElements.length; i++) { |
---|
92 | for (int j = i; j < guiElements.length; j++) { |
---|
93 | assertTrue(guiElements[i].equals(guiElements[j])); |
---|
94 | assertTrue(guiElements[j].equals(guiElements[i])); |
---|
95 | assertEquals(guiElements[i].hashCode(), guiElements[j].hashCode()); |
---|
96 | } |
---|
97 | } |
---|
98 | } |
---|
99 | |
---|
100 | /** |
---|
101 | * <p> |
---|
102 | * TODO comment |
---|
103 | * </p> |
---|
104 | * |
---|
105 | * @version $Revision: $ $Date: 24.08.2012$ |
---|
106 | * @author 2012, last modified by $Author: pharms$ |
---|
107 | */ |
---|
108 | public class AbstractDefaultGUIElementTestImpl extends AbstractDefaultGUIElement |
---|
109 | implements IGUIElement |
---|
110 | { |
---|
111 | |
---|
112 | /** |
---|
113 | * <p> |
---|
114 | * TODO: comment |
---|
115 | * </p> |
---|
116 | * |
---|
117 | * @param specification |
---|
118 | * @param parent |
---|
119 | */ |
---|
120 | public AbstractDefaultGUIElementTestImpl() { |
---|
121 | super(null, null); |
---|
122 | } |
---|
123 | |
---|
124 | /** */ |
---|
125 | private static final long serialVersionUID = 1L; |
---|
126 | |
---|
127 | /* (non-Javadoc) |
---|
128 | * @see de.ugoe.cs.autoquest.eventcore.IEventTarget#getPlatform() |
---|
129 | */ |
---|
130 | @Override |
---|
131 | public String getPlatform() { |
---|
132 | return "TEST"; |
---|
133 | } |
---|
134 | |
---|
135 | /* (non-Javadoc) |
---|
136 | * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#updateSpecification(de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec) |
---|
137 | */ |
---|
138 | @Override |
---|
139 | public void updateSpecification(IGUIElementSpec furtherSpec) { |
---|
140 | throw new UnsupportedOperationException(); |
---|
141 | } |
---|
142 | |
---|
143 | @Override |
---|
144 | public String getStringIdentifier() { |
---|
145 | return "DUMMY"; |
---|
146 | } |
---|
147 | |
---|
148 | } |
---|
149 | |
---|
150 | } |
---|