Changeset 1025
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-events-test/src/test/java/de/ugoe/cs/autoquest/eventcore/guimodel/GUIElementTreeTest.java
r1005 r1025 48 48 public void testFindNonExisting(){ 49 49 GUIElementTree tree = new GUIElementTree(); 50 try{ 51 tree.find(10l); 52 fail("Exception was not thrown."); 53 } 54 catch(Exception e){ 55 } 50 assertEquals(tree.find(10l), null); 56 51 } 57 52 -
trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/guimodel/GUIElementTree.java
r1005 r1025 173 173 * <p> 174 174 * Searches the tree for a GUI element with the specified id and returns its 175 * {@link IGUIElement Spec} .175 * {@link IGUIElement} . 176 176 * </p> 177 177 * … … 181 181 */ 182 182 public IGUIElement find(long id) { 183 IGUIElement guiElement = guiElements.get(id); 184 if (guiElement == null) { 185 List<IGUIElementSpec> guiElementPath = new ArrayList<IGUIElementSpec>(); 186 187 IGUIElementSpec elementSpec = guiElementSpecs.get(id); 188 189 if (elementSpec == null) { 190 throw new RuntimeException("no GUI element found with hash " + id); 191 } 192 193 Long currentElementID = id; 194 while (elementSpec != null) { 195 guiElementPath.add(0, elementSpec); 196 currentElementID = parentRelations.get(currentElementID); 197 elementSpec = guiElementSpecs.get(currentElementID); 198 } 199 200 try { 201 guiElement = guiModel.integratePath(guiElementPath, guiElementFactory); 202 } 203 catch (GUIModelException e) { 204 throw new RuntimeException("could not instantiate GUI element with id " + id, e); 205 } 206 guiElements.put(id, guiElement); 207 } 208 return guiElement; 183 return guiElements.get(id); 209 184 } 210 185
Note: See TracChangeset
for help on using the changeset viewer.