source: trunk/autoquest-core-events-test/src/test/java/de/ugoe/cs/autoquest/eventcore/guimodel/GUIElementTreeTest.java @ 1085

Last change on this file since 1085 was 1085, checked in by pharms, 11 years ago
  • forwarded problems in GUI element mapping to parser to allow better handling of this exception
  • Property svn:mime-type set to text/plain
File size: 2.5 KB
RevLine 
[1005]1package de.ugoe.cs.autoquest.eventcore.guimodel;
2
3import static org.junit.Assert.*;
4
5import org.junit.Test;
6
7/**
8 * Test of {@link GUIElementTree}
9 * @author Fabian Glaser
10 *
11 */
12public class GUIElementTreeTest {
13
[1053]14    @Test
[1085]15    public void testAdd() throws Exception {
16        GUIElementTree<Long> tree = new GUIElementTree<Long>();
[1053]17        IGUIElementSpec spec = new MockGUIElementSpec();
18        tree.add(10l, null, spec);
19       
20        assertEquals(1, tree.size());
21    }
22   
23    @Test
[1085]24    public void testAddWithParent() throws Exception {
25        GUIElementTree<Long> tree = new GUIElementTree<Long>();
[1053]26        IGUIElementSpec parentspec = new MockGUIElementSpec();
27        IGUIElementSpec spec = new MockGUIElementSpec();
28        tree.add(10l, null, parentspec);
29        tree.add(20l, 10l, spec);
30       
31        assertEquals(2, tree.size());
32       
33        IGUIElement element = tree.find(20l);
34        assertEquals(parentspec, element.getParent().getSpecification());
35    }
[1005]36
[1053]37    @Test
[1085]38    public void testFindExisting() throws Exception {
39        GUIElementTree<Long> tree = new GUIElementTree<Long>();
[1053]40        IGUIElementSpec spec = new MockGUIElementSpec();
41        tree.add(10l, 0l, spec);
42       
43        IGUIElement element = tree.find(10l);
44        assertNotNull(element);
45    }
46   
47    @Test
[1085]48    public void testFindNonExisting() throws Exception {
49        GUIElementTree<Long> tree = new GUIElementTree<Long>();
[1053]50        assertEquals(tree.find(10l), null);
51    }
[1005]52
[1053]53    @Test
[1085]54    public void testRemoveSingleElement() throws Exception {
55        GUIElementTree<Long> tree = new GUIElementTree<Long>();
[1053]56        IGUIElementSpec spec = new MockGUIElementSpec();
57        tree.add(10l, null, spec);
58       
59        assertEquals(1, tree.size());
60        assertEquals(1, tree.remove(10l));
61    }
62   
63    @Test
[1085]64    public void testRemoveWithChildElement() throws Exception {
65        GUIElementTree<Long> tree = new GUIElementTree<Long>();
[1053]66        IGUIElementSpec parentspec = new MockGUIElementSpec();
67        IGUIElementSpec spec = new MockGUIElementSpec();
68        tree.add(10l, null, parentspec);
69        tree.add(20l, 10l, spec);
70       
71        assertEquals(2, tree.remove(10l));
72        assertEquals(0, tree.size());
73    }
74   
75    @Test
76    public void testRemoveNonExisting(){
[1085]77        GUIElementTree<Long> tree = new GUIElementTree<Long>();
[1053]78        assertEquals(0, tree.remove(10l));
79    }
[1005]80
[1053]81    @Test
82    public void testGetGUIModel() {
[1085]83        GUIElementTree<Long> tree = new GUIElementTree<Long>();
[1053]84        assertNotNull(tree.getGUIModel());
85    }
[1005]86}
Note: See TracBrowser for help on using the repository browser.