use of com.github.bordertech.wcomponents.WLabel in project wcomponents by BorderTech.
the class WLabelRenderer_Test method testWhatForInput.
@Test
public void testWhatForInput() throws IOException, SAXException, XpathException {
MyInput comp = new MyInput();
WLabel label = new WLabel("label", comp);
assertSchemaMatch(label);
assertXpathEvaluatesTo("input", "//ui:label/@what", label);
}
use of com.github.bordertech.wcomponents.WLabel in project wcomponents by BorderTech.
the class WLabelRenderer_Test method testWhatForGroup2.
@Test
public void testWhatForGroup2() throws IOException, SAXException, XpathException {
WMultiDropdown comp = new WMultiDropdown();
WLabel label = new WLabel("label", comp);
assertXpathEvaluatesTo("group", "//ui:label/@what", label);
}
use of com.github.bordertech.wcomponents.WLabel in project wcomponents by BorderTech.
the class WLabelRenderer_Test method testDoPaintAllOptions.
@Test
public void testDoPaintAllOptions() throws IOException, SAXException, XpathException {
WTextArea text = new WTextArea();
text.setText("text1");
WLabel label = new WLabel();
label.setForComponent(text);
label.setHint("hint1");
label.setAccessKey('A');
label.setText("label1");
WContainer root = new WContainer();
root.add(label);
root.add(text);
// Validate Schema
assertSchemaMatch(root);
// Check Attributes
assertXpathEvaluatesTo(label.getId(), "//ui:label/@id", label);
assertXpathEvaluatesTo(text.getId(), "//ui:label/@for", label);
assertXpathEvaluatesTo("hint1", "//ui:label/@hint", label);
assertXpathEvaluatesTo("A", "//ui:label/@accessKey", label);
assertXpathEvaluatesTo("input", "//ui:label/@what", label);
// Check Label
assertXpathEvaluatesTo("label1", "//ui:label", label);
// Add Children to Label
WTextArea text2 = new WTextArea();
text2.setText("text2");
label.add(text2);
assertSchemaMatch(root);
assertXpathEvaluatesTo("text2", "//ui:label/ui:textarea", label);
}
use of com.github.bordertech.wcomponents.WLabel in project wcomponents by BorderTech.
the class ObjectGraphDump_Test method testDump.
@Test
public void testDump() {
WPanel component = new WPanel();
component.setLayout(new BorderLayout());
component.add(new WLabel(TEST_LABEL), BorderLayout.NORTH);
ObjectGraphNode graphNode = ObjectGraphDump.dump(component);
String result = graphNode.toXml();
// ObjectGraphNode tested independently
// for the input 'component' above - the dump result must at least contain the following
// and have run without exceptions
Assert.assertTrue("", result.indexOf("type=\"com.github.bordertech.wcomponents.WPanel\"") != -1);
Assert.assertTrue("", result.indexOf("field=\"label\" type=\"com.github.bordertech.wcomponents.WLabel\"") != -1);
Assert.assertTrue("", result.indexOf("field=\"text\" value=\""" + TEST_LABEL + ""\" type=\"java.io.Serializable\"") != -1);
Assert.assertTrue("", result.indexOf("field=\"value\" type=\"com.github.bordertech.wcomponents.layout.BorderLayout$BorderLayoutConstraint\"") != -1);
}
use of com.github.bordertech.wcomponents.WLabel in project wcomponents by BorderTech.
the class ObjectGraphNode_Test method testToXml.
@Test
public void testToXml() {
WContainer component = new WContainer();
setActiveContext(createUIContext());
WLabel label = new WLabel(TEST_LABEL);
component.add(label);
final int nodeId = component.getIndexOfChild(label);
final String fieldName = label.getId();
ObjectGraphNode node = new ObjectGraphNode(nodeId, fieldName, label.getClass().getName(), label);
String xmlSummary = node.toXml();
Assert.assertTrue("should report correct ID", xmlSummary.indexOf("object id=\"0\"") != -1);
Assert.assertTrue("should report correct field name", xmlSummary.indexOf("field=\"" + fieldName + "\"") != -1);
Assert.assertTrue("should report correct class name", xmlSummary.indexOf("type=\"com.github.bordertech.wcomponents.WLabel\"") != -1);
Assert.assertTrue("should report correct size", xmlSummary.indexOf("size=\"12\"") != -1);
}
Aggregations