Changeset 1025


Ignore:
Timestamp:
12/31/12 17:06:37 (12 years ago)
Author:
fglaser
Message:
  • Removed an inconsistency in GUIElementTree: find(...) does not throw exceptions if element was not found, but instead returns null.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-events-test/src/test/java/de/ugoe/cs/autoquest/eventcore/guimodel/GUIElementTreeTest.java

    r1005 r1025  
    4848        public void testFindNonExisting(){ 
    4949                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); 
    5651        } 
    5752 
  • trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/guimodel/GUIElementTree.java

    r1005 r1025  
    173173     * <p> 
    174174     * Searches the tree for a GUI element with the specified id and returns its 
    175      * {@link IGUIElementSpec} . 
     175     * {@link IGUIElement} . 
    176176     * </p> 
    177177     *  
     
    181181     */ 
    182182    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); 
    209184    } 
    210185 
Note: See TracChangeset for help on using the changeset viewer.