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

Last change on this file since 1113 was 1113, checked in by pharms, 11 years ago
  • added license statement
  • Property svn:mime-type set to text/plain
File size: 3.1 KB
Line 
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
15package de.ugoe.cs.autoquest.eventcore.guimodel;
16
17import static org.junit.Assert.*;
18
19import org.junit.Test;
20
21/**
22 * Test of {@link GUIElementTree}
23 * @author Fabian Glaser
24 *
25 */
26public class GUIElementTreeTest {
27
28    @Test
29    public void testAdd() throws Exception {
30        GUIElementTree<Long> tree = new GUIElementTree<Long>();
31        IGUIElementSpec spec = new MockGUIElementSpec();
32        tree.add(10l, null, spec);
33       
34        assertEquals(1, tree.size());
35    }
36   
37    @Test
38    public void testAddWithParent() throws Exception {
39        GUIElementTree<Long> tree = new GUIElementTree<Long>();
40        IGUIElementSpec parentspec = new MockGUIElementSpec();
41        IGUIElementSpec spec = new MockGUIElementSpec();
42        tree.add(10l, null, parentspec);
43        tree.add(20l, 10l, spec);
44       
45        assertEquals(2, tree.size());
46       
47        IGUIElement element = tree.find(20l);
48        assertEquals(parentspec, element.getParent().getSpecification());
49    }
50
51    @Test
52    public void testFindExisting() throws Exception {
53        GUIElementTree<Long> tree = new GUIElementTree<Long>();
54        IGUIElementSpec spec = new MockGUIElementSpec();
55        tree.add(10l, 0l, spec);
56       
57        IGUIElement element = tree.find(10l);
58        assertNotNull(element);
59    }
60   
61    @Test
62    public void testFindNonExisting() throws Exception {
63        GUIElementTree<Long> tree = new GUIElementTree<Long>();
64        assertEquals(tree.find(10l), null);
65    }
66
67    @Test
68    public void testRemoveSingleElement() throws Exception {
69        GUIElementTree<Long> tree = new GUIElementTree<Long>();
70        IGUIElementSpec spec = new MockGUIElementSpec();
71        tree.add(10l, null, spec);
72       
73        assertEquals(1, tree.size());
74        assertEquals(1, tree.remove(10l));
75    }
76   
77    @Test
78    public void testRemoveWithChildElement() throws Exception {
79        GUIElementTree<Long> tree = new GUIElementTree<Long>();
80        IGUIElementSpec parentspec = new MockGUIElementSpec();
81        IGUIElementSpec spec = new MockGUIElementSpec();
82        tree.add(10l, null, parentspec);
83        tree.add(20l, 10l, spec);
84       
85        assertEquals(2, tree.remove(10l));
86        assertEquals(0, tree.size());
87    }
88   
89    @Test
90    public void testRemoveNonExisting(){
91        GUIElementTree<Long> tree = new GUIElementTree<Long>();
92        assertEquals(0, tree.remove(10l));
93    }
94
95    @Test
96    public void testGetGUIModel() {
97        GUIElementTree<Long> tree = new GUIElementTree<Long>();
98        assertNotNull(tree.getGUIModel());
99    }
100}
Note: See TracBrowser for help on using the repository browser.