My favorites | Sign in
Project Home Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/**
*
*/
package org.openiaml.model.tests.codegen.model0_5_3;

import java.util.ArrayList;
import java.util.List;

import net.sourceforge.jwebunit.api.IElement;

import org.openiaml.model.model.visual.InputForm;
import org.openiaml.model.tests.codegen.DatabaseCodegenHelper;
import org.openiaml.model.tests.codegen.DatabaseCodegenTest;
import org.openiaml.model.tests.codegen.model0_5.MapsCodegenTestCase;

/**
* Tests all of the visual elements in IAML; that is,
* all {@model VisibleThing}s. This can therefore be useful for screenshots etc.
*
* @example VisibleThing,InputForm,InputTextField,Label,Map,MapPoint,IteratorList
* An example model to render all {@model VisibleThing}s in the
* IAML metamodel.
*
*/
public class IamlVisualElements extends MapsCodegenTestCase implements DatabaseCodegenTest {

private DatabaseCodegenHelper helper;

@Override
protected void setUp() throws Exception {
super.setUp();
root = loadAndCodegen(getClass());

// need to initialise the database as well
helper = new DatabaseCodegenHelper(this, this);
helper.initialiseDatabase();
}

/**
* Tests {@model Frame}.
*/
public void testFrame() throws Exception {
beginAtSitemapThenPage("Frame");
assertNoProblem();
}

/**
* Tests {@model InputForm}.
*/
public void testInputForm() throws Exception {
beginAtSitemapThenPage("Frame");
assertNoProblem();

assertHasInputForm("Input Form");

}

/**
* Tests {@model InputTextField}.
*/
public void testInputTextField() throws Exception {
beginAtSitemapThenPage("Frame");
assertNoProblem();

{
String target = getLabelIDForText("Input Text Field");
assertLabeledFieldEquals(target, "");
}

}

/**
* Tests {@model Button}.
*/
public void testButton() throws Exception {
beginAtSitemapThenPage("Frame");
assertNoProblem();

assertButtonPresentWithText("Button");

}

/**
* Tests {@model Map}.
*/
public void testMap() throws Exception {
beginAtSitemapThenPage("Frame");
assertNoProblem();

assertHasMap("Map");

}

/**
* Tests {@model MapPoint}.
*/
public void testMapPoint() throws Exception {
beginAtSitemapThenPage("Frame");
assertNoProblem();

IElement map = assertHasMap("Map");
assertHasMapPoint(map, "Map Point");

// TODO no way to check the location of the map point?
}

/**
* Tests visible {@model Label}.
*/
public void testLabel() throws Exception {
beginAtSitemapThenPage("Frame");
assertNoProblem();

assertLabelTextExactlyPresent("Label");
}

/**
* Tests hidden {@model Label}s.
*/
public void testHidden() throws Exception {
beginAtSitemapThenPage("Frame");
assertNoProblem();

// Hidden things aren't visible!
assertLabelTextNotPresent("Hidden");
}

/**
* Tests {@model IteratorList}.
*/
public void testIteratorList() throws Exception {
beginAtSitemapThenPage("Frame");
assertNoProblem();

assertLabelTextExactlyPresent("Scope");
assertLabelTextExactlyPresent("Frame");
assertLabelTextExactlyPresent("Visible Thing");
assertLabelTextExactlyPresent("Input Form");
assertLabelTextExactlyPresent("Label");
}

/**
* Assert that a named input form - that is, a form with a contained H2
* element with the given name - exists.
*
* @see InputForm
* @param string the form title to search for
*/
private void assertHasInputForm(String string) {
IElement found = null;
StringBuffer foundStrings = new StringBuffer();

List<IElement> h2s = getElementsByXPath("//form/h2");
for (IElement h2 : h2s) {
foundStrings.append(h2.getTextContent()).append(", ");
if (string.equals(h2.getTextContent())) {
// found it
assertNull("Found a duplicate form for title '" + string + "': " + found, found);
found = h2;
}
}

assertNotNull("Found no forms for title '" + string + "', forms found: " + foundStrings, found);
}

/* (non-Javadoc)
* @see org.openiaml.model.tests.codegen.DatabaseCodegenTest#getDatabaseInitialisers1()
*/
@Override
public List<String> getDatabaseInitialisers1() {
List<String> s = new ArrayList<String>();
s.add("CREATE TABLE Iterator_List_contents (generated_primary_key INTEGER PRIMARY KEY AUTOINCREMENT, key VARCHAR(64), value VARCHAR(64))");
s.add("INSERT INTO Iterator_List_contents (generated_primary_key, key, value) VALUES (12, 'Frame', 'Scope')");
s.add("INSERT INTO Iterator_List_contents (generated_primary_key, key, value) VALUES (23, 'Input Form', 'Visible Thing')");
s.add("INSERT INTO Iterator_List_contents (generated_primary_key, key, value) VALUES (45, 'Label', 'Visible Thing')");
return s;
}


}

Change log

r3068 by soundasleep on Aug 8, 2011   Diff
improving modeldoc documentation across
inference rules, codegen templates, ecore,
and additional documentation includes
Go to: 
Project members, sign in to write a code review

Older revisions

r2556 by soundasleep on Jan 17, 2011   Diff
writing IamlVisualElements test case
to check for the various VisibleThings
of IAML
refactoring database tests to instead
use a DatabaseCodegenHelper (still
...
All revisions of this file

File info

Size: 4771 bytes, 180 lines
Powered by Google Project Hosting