use of com.github.bordertech.wcomponents.WProgressBar in project wcomponents by BorderTech.
the class WProgressBarRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
BeanProvider provider = new BeanProvider() {
@Override
public Object getBean(final BeanProviderBound beanProviderBound) {
return 13;
}
};
WProgressBar progressBar = new WProgressBar(WProgressBar.ProgressBarType.NORMAL, WProgressBar.UnitType.FRACTION);
progressBar.setBeanProvider(provider);
progressBar.setMax(33);
assertXpathExists("//html:progress[@max='33']", progressBar);
progressBar = new WProgressBar(WProgressBar.ProgressBarType.SMALL, WProgressBar.UnitType.PERCENTAGE);
progressBar.setBeanProvider(provider);
progressBar.setMax(33);
assertXpathExists("//html:progress[@max='33' and contains(@class, 'wc-progressbar-type-small')]", progressBar);
}
use of com.github.bordertech.wcomponents.WProgressBar in project wcomponents by BorderTech.
the class WSkipLinksExample method buildPanel.
/**
* Creates a panel for the example.
*
* @param title the panel title.
* @return a panel for use in the example.
*/
private WPanel buildPanel(final String title) {
WPanel panel = new WPanel(WPanel.Type.CHROME);
panel.setTitleText(title);
WProgressBar progress = new WProgressBar(18);
progress.setValue(15);
panel.add(progress);
panel.add(new WHorizontalRule());
WTextField input = new WTextField();
WLabel label = new WLabel("Text input", input);
panel.add(label);
panel.add(input);
return panel;
}
use of com.github.bordertech.wcomponents.WProgressBar in project wcomponents by BorderTech.
the class WProgressBarRenderer method doRender.
/**
* Paints the given WProgressBar.
*
* @param component the WProgressBar to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WProgressBar progressBar = (WProgressBar) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("html:progress");
xml.appendAttribute("id", component.getId());
xml.appendAttribute("class", getHtmlClass(progressBar));
xml.appendOptionalAttribute("hidden", progressBar.isHidden(), "hidden");
xml.appendOptionalAttribute("title", progressBar.getToolTip());
xml.appendOptionalAttribute("aria-label", progressBar.getAccessibleText());
xml.appendAttribute("value", progressBar.getValue());
xml.appendOptionalAttribute("max", progressBar.getMax() > 0, progressBar.getMax());
xml.appendClose();
xml.appendEndTag("html:progress");
}
use of com.github.bordertech.wcomponents.WProgressBar in project wcomponents by BorderTech.
the class WProgressBarRenderer_Test method testRendererCorrectlyConfigured.
@Test
public void testRendererCorrectlyConfigured() {
WProgressBar progressBar = new WProgressBar();
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(progressBar) instanceof WProgressBarRenderer);
}
use of com.github.bordertech.wcomponents.WProgressBar in project wcomponents by BorderTech.
the class WProgressBarRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
WProgressBar progressBar = new WProgressBar(WProgressBar.ProgressBarType.NORMAL, 100);
assertSafeContent(progressBar);
progressBar.setToolTip(getMaliciousAttribute("html:progress"));
assertSafeContent(progressBar);
progressBar.setAccessibleText(getMaliciousAttribute("html:progress"));
assertSafeContent(progressBar);
}
Aggregations