use of com.github.bordertech.wcomponents.WPanel in project wcomponents by BorderTech.
the class BorderLayoutRenderer_Test method testDoRender.
@Test
public void testDoRender() throws IOException, SAXException, XpathException {
final String northText = "BorderRenderer_Test.testPaint.northText";
final String westText = "BorderRenderer_Test.testPaint.westText";
final String southText = "BorderRenderer_Test.testPaint.southText";
final String eastText = "BorderRenderer_Test.testPaint.eastText";
final String centerText = "BorderRenderer_Test.testPaint.centerText";
WPanel container = new WPanel();
container.setLayout(new BorderLayout(GAP, BIG_GAP));
assertSchemaMatch(container);
assertXpathEvaluatesTo(GAP.toString(), "//ui:panel/ui:borderlayout/@hgap", container);
assertXpathEvaluatesTo(BIG_GAP.toString(), "//ui:panel/ui:borderlayout/@vgap", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:north", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:south", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:east", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:west", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:center", container);
container.add(new WText(northText), BorderLayout.NORTH);
container.add(new WText(westText), BorderLayout.WEST);
assertXpathEvaluatesTo(northText, "normalize-space(//ui:panel/ui:borderlayout/ui:north)", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:south", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:east", container);
assertXpathEvaluatesTo(westText, "normalize-space(//ui:panel/ui:borderlayout/ui:west)", container);
assertXpathNotExists("//ui:panel/ui:borderlayout/ui:center", container);
container.add(new WText(southText), BorderLayout.SOUTH);
container.add(new WText(eastText), BorderLayout.EAST);
container.add(new WText(centerText));
assertXpathEvaluatesTo(northText, "normalize-space(//ui:panel/ui:borderlayout/ui:north)", container);
assertXpathEvaluatesTo(westText, "normalize-space(//ui:panel/ui:borderlayout/ui:west)", container);
assertXpathEvaluatesTo(southText, "normalize-space(//ui:panel/ui:borderlayout/ui:south)", container);
assertXpathEvaluatesTo(eastText, "normalize-space(//ui:panel/ui:borderlayout/ui:east)", container);
assertXpathEvaluatesTo(centerText, "normalize-space(//ui:panel/ui:borderlayout/ui:center)", container);
}
use of com.github.bordertech.wcomponents.WPanel in project wcomponents by BorderTech.
the class ColumnLayoutRenderer_Test method testDoRender.
@Test
public void testDoRender() throws IOException, SAXException, XpathException {
final int[] cols = new int[] { 1, 100 };
final Alignment[] aligns = new Alignment[] { Alignment.RIGHT, Alignment.CENTER };
final String text1 = "ColumnRenderer_Test.testPaint.text1";
final String text2 = "ColumnRenderer_Test.testPaint.text2";
WPanel container = new WPanel();
container.setLayout(new ColumnLayout(cols));
// One element -> 1 row, 2 cols (one empty)
container.add(new WText(text1));
assertSchemaMatch(container);
assertXpathEvaluatesTo("1", "count(//ui:panel/ui:columnlayout)", container);
assertXpathEvaluatesTo(String.valueOf(cols.length), "count(//ui:panel/ui:columnlayout/ui:column)", container);
assertXpathEvaluatesTo(text1, "normalize-space(//ui:panel/ui:columnlayout/ui:cell[1])", container);
assertXpathEvaluatesTo("", "normalize-space(//ui:panel/ui:columnlayout/ui:cell[2])", container);
// Two elements -> 1 row, 2 cols
container.add(new WText(text2));
assertSchemaMatch(container);
assertXpathEvaluatesTo("1", "count(//ui:panel/ui:columnlayout)", container);
assertXpathEvaluatesTo(String.valueOf(cols.length), "count(//ui:panel/ui:columnlayout/ui:column)", container);
assertXpathEvaluatesTo(String.valueOf(cols[0]), "//ui:panel/ui:columnlayout/ui:column[1]/@width", container);
assertXpathEvaluatesTo(String.valueOf(cols[1]), "//ui:panel/ui:columnlayout/ui:column[2]/@width", container);
assertXpathEvaluatesTo(text1, "normalize-space(//ui:panel/ui:columnlayout/ui:cell[1])", container);
assertXpathEvaluatesTo(text2, "normalize-space(//ui:panel/ui:columnlayout/ui:cell[2])", container);
assertXpathEvaluatesTo("", "//ui:panel/ui:columnlayout/@hgap", container);
assertXpathEvaluatesTo("", "//ui:panel/ui:columnlayout/@vgap", container);
// Test hgap, vgap
container.setLayout(new ColumnLayout(cols, GAP, BIG_GAP));
assertSchemaMatch(container);
assertXpathEvaluatesTo(GAP.toString(), "//ui:panel/ui:columnlayout/@hgap", container);
assertXpathEvaluatesTo(BIG_GAP.toString(), "//ui:panel/ui:columnlayout/@vgap", container);
// Test Alignment
container.setLayout(new ColumnLayout(cols, aligns));
assertSchemaMatch(container);
assertXpathEvaluatesTo("", "//ui:panel/ui:columnlayout/@hgap", container);
assertXpathEvaluatesTo("", "//ui:panel/ui:columnlayout/@vgap", container);
assertXpathEvaluatesTo("right", "//ui:panel/ui:columnlayout/ui:column[1]/@align", container);
assertXpathEvaluatesTo("center", "//ui:panel/ui:columnlayout/ui:column[2]/@align", container);
// Test Alignment, hgap, vgap
container.setLayout(new ColumnLayout(cols, aligns, GAP, BIG_GAP));
assertSchemaMatch(container);
assertXpathEvaluatesTo(GAP.toString(), "//ui:panel/ui:columnlayout/@hgap", container);
assertXpathEvaluatesTo(BIG_GAP.toString(), "//ui:panel/ui:columnlayout/@vgap", container);
assertXpathEvaluatesTo("right", "//ui:panel/ui:columnlayout/ui:column[1]/@align", container);
assertXpathEvaluatesTo("center", "//ui:panel/ui:columnlayout/ui:column[2]/@align", container);
}
use of com.github.bordertech.wcomponents.WPanel in project wcomponents by BorderTech.
the class FlowLayoutRenderer_Test method testDoRenderWhenEmpty.
// The expected render of the default constructor.
@Test
public void testDoRenderWhenEmpty() throws IOException, SAXException, XpathException {
WPanel panel = new WPanel();
panel.setLayout(new FlowLayout());
assertSchemaMatch(panel);
assertXpathExists("//ui:panel/ui:flowlayout", panel);
assertXpathEvaluatesTo("center", "//ui:panel/ui:flowlayout/@align", panel);
assertXpathNotExists("//ui:panel/ui:flowlayout/ui:cell", panel);
assertXpathNotExists("//ui:panel/ui:flowlayout/@gap", panel);
assertXpathNotExists("//ui:panel/ui:flowlayout/@valign", panel);
}
use of com.github.bordertech.wcomponents.WPanel in project wcomponents by BorderTech.
the class FlowLayoutRenderer_Test method testRenderContentAlignment.
@Test
public void testRenderContentAlignment() throws IOException, SAXException, XpathException {
WPanel panel = new WPanel();
String expected;
for (FlowLayout.Alignment a : FlowLayout.Alignment.values()) {
for (FlowLayout.ContentAlignment c : FlowLayout.ContentAlignment.values()) {
panel.setLayout(new FlowLayout(a, c));
assertSchemaMatch(panel);
assertXpathExists("//ui:panel/ui:flowlayout", panel);
expected = a.toString().toLowerCase();
assertXpathEvaluatesTo(expected, "//ui:panel/ui:flowlayout/@align", panel);
if (a == FlowLayout.VERTICAL) {
assertXpathNotExists("//ui:panel/ui:flowlayout/@valign", panel);
} else {
expected = c.toString().toLowerCase();
assertXpathEvaluatesTo(expected, "//ui:panel/ui:flowlayout/@valign", panel);
}
}
}
}
use of com.github.bordertech.wcomponents.WPanel in project wcomponents by BorderTech.
the class FlowLayoutRenderer_Test method testHVGaps.
// Test that use of deprecated two-gap constructors output the expected gap
@Test
public void testHVGaps() throws IOException, SAXException, XpathException {
WPanel panel = new WPanel();
String expected;
for (FlowLayout.Alignment a : FlowLayout.Alignment.values()) {
panel.setLayout(new FlowLayout(a, 3, 16));
assertSchemaMatch(panel);
expected = a == FlowLayout.VERTICAL ? BIG_GAP.toString() : GAP.toString();
assertXpathEvaluatesTo(expected, "//ui:panel/ui:flowlayout/@gap", panel);
}
}
Aggregations