Search in sources :

Example 46 with WLabel

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);
}
Also used : WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 47 with WLabel

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);
}
Also used : WMultiDropdown(com.github.bordertech.wcomponents.WMultiDropdown) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 48 with WLabel

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);
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WContainer(com.github.bordertech.wcomponents.WContainer) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 49 with WLabel

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);
}
Also used : BorderLayout(com.github.bordertech.wcomponents.layout.BorderLayout) WPanel(com.github.bordertech.wcomponents.WPanel) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Example 50 with WLabel

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);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WLabel(com.github.bordertech.wcomponents.WLabel) Test(org.junit.Test)

Aggregations

WLabel (com.github.bordertech.wcomponents.WLabel)99 Test (org.junit.Test)57 WHeading (com.github.bordertech.wcomponents.WHeading)13 WTextField (com.github.bordertech.wcomponents.WTextField)10 WButton (com.github.bordertech.wcomponents.WButton)9 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)9 WComponent (com.github.bordertech.wcomponents.WComponent)8 WRadioButtonSelect (com.github.bordertech.wcomponents.WRadioButtonSelect)8 WPanel (com.github.bordertech.wcomponents.WPanel)7 UIContext (com.github.bordertech.wcomponents.UIContext)6 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)6 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)5 UIContextImpl (com.github.bordertech.wcomponents.UIContextImpl)5 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)5 WComponentGroup (com.github.bordertech.wcomponents.WComponentGroup)5 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)5 Action (com.github.bordertech.wcomponents.Action)4 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)4 WApplication (com.github.bordertech.wcomponents.WApplication)4 WContainer (com.github.bordertech.wcomponents.WContainer)4