use of com.github.bordertech.wcomponents.UIContext in project wcomponents by BorderTech.
the class ThemeUtil_Test method testGetThemeXslt.
@Test
public void testGetThemeXslt() {
String themePath = "/testGetThemeXslt";
Config.getInstance().setProperty(ConfigurationProperties.THEME_CONTENT_PATH, themePath);
String build = ThemeUtil.getThemeBuild();
String themeName = ThemeUtil.getThemeName();
String versionSuffix = "?build=" + WebUtilities.escapeForUrl(build) + "&theme=" + WebUtilities.escapeForUrl(themeName);
UIContext uic = createUIContext();
Assert.assertEquals("Incorrect theme path", themePath + "/xslt/all.xsl" + versionSuffix, ThemeUtil.getThemeXslt(uic));
// We used to fetch a different XSL file based on locale, this is no longer the case.
uic.setLocale(Locale.ENGLISH);
Assert.assertEquals("Incorrect theme path", themePath + "/xslt/all.xsl" + versionSuffix, ThemeUtil.getThemeXslt(uic));
// We used to fetch a different XSL file based on locale, this is no longer the case.
uic.setLocale(Locale.CANADA_FRENCH);
Assert.assertEquals("Incorrect theme path", themePath + "/xslt/all.xsl" + versionSuffix, ThemeUtil.getThemeXslt(uic));
}
use of com.github.bordertech.wcomponents.UIContext in project wcomponents by BorderTech.
the class TreeUtil_Test method testFindWComponent.
@Test
public void testFindWComponent() {
UIContext uic = UIContextHolder.getCurrent();
ComponentWithContext result = TreeUtil.findWComponent(root, new String[] { "WApplication" });
Assert.assertSame("Incorrect component returned for find WApplication", root, result.getComponent());
Assert.assertSame("Incorrect context returned for find WApplication", uic, result.getContext());
result = TreeUtil.findWComponent(root, new String[] { "WTextArea" });
Assert.assertSame("Incorrect component returned for find WTextArea", grandChild, result.getComponent());
Assert.assertSame("Incorrect context returned for find WTextArea", uic, result.getContext());
result = TreeUtil.findWComponent(root, new String[] { "WContainer", "WTextArea" });
Assert.assertSame("Incorrect component returned for find WContainer/WTextArea", grandChild, result.getComponent());
Assert.assertSame("Incorrect context returned for find WContainer/WTextArea", uic, result.getContext());
result = TreeUtil.findWComponent(root, new String[] { "WText[1]" });
Assert.assertSame("Incorrect component returned for find WText[1]", repeatedComponent, result.getComponent());
UIContext row2Context = repeaterChild.getRowContext("2");
Assert.assertSame("Incorrect context returned for find WText[1]", row2Context, result.getContext());
result = TreeUtil.findWComponent(root, new String[] { "WApplication", "WText[1]" });
Assert.assertSame("Incorrect component returned for find WApplication/WText[1]", repeatedComponent, result.getComponent());
row2Context = repeaterChild.getRowContext("2");
Assert.assertSame("Incorrect context returned for find WApplication/WText[1]", row2Context, result.getContext());
result = TreeUtil.findWComponent(root, new String[] { "WContainer", "WRepeater" });
Assert.assertNull("Should not have a result for an invalid path", result);
}
use of com.github.bordertech.wcomponents.UIContext in project wcomponents by BorderTech.
the class TreeUtil_Test method testGetComponentWithId.
@Test
public void testGetComponentWithId() {
Assert.assertSame("Incorrect component returned for root", root, TreeUtil.getComponentWithId(root, root.getId()));
Assert.assertSame("Incorrect component returned for containerChild", containerChild, TreeUtil.getComponentWithId(root, containerChild.getId()));
Assert.assertSame("Incorrect component returned for simpleChild", simpleChild, TreeUtil.getComponentWithId(root, simpleChild.getId()));
Assert.assertSame("Incorrect component returned for repeaterChild", repeaterChild, TreeUtil.getComponentWithId(root, repeaterChild.getId()));
Assert.assertSame("Incorrect component returned for grandChild", grandChild, TreeUtil.getComponentWithId(root, grandChild.getId()));
UIContext row2Context = repeaterChild.getRowContext("2");
setActiveContext(row2Context);
Assert.assertSame("Incorrect component returned for repeatedComponent row 2", repeatedComponent, TreeUtil.getComponentWithId(root, repeatedComponent.getId()));
}
use of com.github.bordertech.wcomponents.UIContext in project wcomponents by BorderTech.
the class TreeUtil_Test method testGetContextForId.
@Test
public void testGetContextForId() {
UIContext uic = UIContextHolder.getCurrent();
Assert.assertSame("Incorrect context returned for root", uic, TreeUtil.getContextForId(root, root.getId()));
Assert.assertSame("Incorrect context returned for containerChild", uic, TreeUtil.getContextForId(root, containerChild.getId()));
Assert.assertSame("Incorrect context returned for simpleChild", uic, TreeUtil.getContextForId(root, simpleChild.getId()));
Assert.assertSame("Incorrect context returned for repeaterChild", uic, TreeUtil.getContextForId(root, repeaterChild.getId()));
Assert.assertSame("Incorrect context returned for grandChild", uic, TreeUtil.getContextForId(root, grandChild.getId()));
UIContext row2Context = repeaterChild.getRowContext("2");
setActiveContext(row2Context);
Assert.assertSame("Incorrect context returned for repeatedComponent row 2", row2Context, TreeUtil.getContextForId(root, repeatedComponent.getId()));
}
use of com.github.bordertech.wcomponents.UIContext in project wcomponents by BorderTech.
the class DiagnosticImpl_Test method testGetDescription.
@Test
public void testGetDescription() {
final UIContext uic = new UIContextImpl();
final WTextField input = new WTextField();
final String noArgsMessage = "The field is required";
final String fieldArgMessage = "The field ''{0}'' is required";
// Test with no formatting
DiagnosticImpl diag = new DiagnosticImpl(Diagnostic.INFO, uic, input, noArgsMessage);
Assert.assertEquals("Incorrect description text", noArgsMessage, diag.getDescription());
// Test with formatting, but missing label text should default to empty String
diag = new DiagnosticImpl(Diagnostic.INFO, uic, input, fieldArgMessage, input);
Assert.assertEquals("Incorrect description text", "The field '' is required", diag.getDescription());
// Test with formatting with accessible text set
input.setAccessibleText("a");
Assert.assertEquals("Incorrect description text", "The field 'a' is required", diag.getDescription());
// Test with formatting with toolTip
input.setAccessibleText(null);
input.setToolTip("a tooltip");
Assert.assertEquals("Incorrect description text", "The field 'a tooltip' is required", diag.getDescription());
// Test with label set
WLabel label = new WLabel("bc", input);
Assert.assertEquals("Incorrect description text", "The field 'bc' is required", diag.getDescription());
// Test with label set, with a colon at the end
label.setText("def:");
Assert.assertEquals("Incorrect description text", "The field 'def' is required", diag.getDescription());
}
Aggregations