use of com.github.bordertech.wcomponents.UIContext in project wcomponents by BorderTech.
the class DevToolkit_Test method setUp.
@Before
public void setUp() {
UIContext uic = new UIContextImpl();
uic.setUI(new WText("dummy"));
UIContextHolder.pushContext(uic);
Config.getInstance().setProperty(ConfigurationProperties.DEVELOPER_TOOKIT, "true");
}
use of com.github.bordertech.wcomponents.UIContext in project wcomponents by BorderTech.
the class LookupTableHelper_Test method testRegisterList.
@Test
public void testRegisterList() {
final String key = "LookupTableHelper_Test.testRegisterList.key";
UIContext uic = createUIContext();
UIContextHolder.pushContext(uic);
MockHttpSession session = new MockHttpSession();
ServletRequest request = new ServletRequest(new MockHttpServletRequest(session));
LookupTableHelper.registerList(key, request);
// Use a new request to ensure that it was stored as a session attribute
request = new ServletRequest(new MockHttpServletRequest(session));
Assert.assertSame("Incorrect context returned", uic, LookupTableHelper.getContext(key, request));
}
use of com.github.bordertech.wcomponents.UIContext in project wcomponents by BorderTech.
the class TreeUtil_Test method testGetRoot.
@Test
public void testGetRoot() {
UIContext uic = UIContextHolder.getCurrent();
Assert.assertSame("Incorrect root node returned for root", root, TreeUtil.getRoot(uic, root));
Assert.assertSame("Incorrect root node returned for containerChild", root, TreeUtil.getRoot(uic, containerChild));
Assert.assertSame("Incorrect root node returned for simpleChild", root, TreeUtil.getRoot(uic, simpleChild));
Assert.assertSame("Incorrect root node returned for repeaterChild", root, TreeUtil.getRoot(uic, repeaterChild));
Assert.assertSame("Incorrect root node returned for grandChild", root, TreeUtil.getRoot(uic, grandChild));
UIContext row2Context = repeaterChild.getRowContext("2");
Assert.assertSame("Incorrect root node returned for repeatedComponent row 2", root, TreeUtil.getRoot(row2Context, repeatedComponent));
}
use of com.github.bordertech.wcomponents.UIContext in project wcomponents by BorderTech.
the class TreeUtil_Test method testCollateVisibles.
@Test
public void testCollateVisibles() {
// Simple case - everything visible.
List<ComponentWithContext> visibles = TreeUtil.collateVisibles(root);
UIContext uic = UIContextHolder.getCurrent();
Assert.assertEquals("Incorrect number of visible components", 10, visibles.size());
Assert.assertTrue("List should contain root", isInList(visibles, root, uic));
Assert.assertTrue("List should contain containerChild", isInList(visibles, containerChild, uic));
Assert.assertTrue("List should contain simpleChild", isInList(visibles, simpleChild, uic));
Assert.assertTrue("List should contain repeaterChild", isInList(visibles, repeaterChild, uic));
Assert.assertTrue("List should contain grandChild", isInList(visibles, grandChild, uic));
Assert.assertTrue("List should contain repeatedComponent row 1", isInList(visibles, repeatedComponent, repeaterChild.getRowContext("1")));
Assert.assertTrue("List should contain repeatedComponent row 2", isInList(visibles, repeatedComponent, repeaterChild.getRowContext("2")));
Assert.assertTrue("List should contain repeatedComponent row 3", isInList(visibles, repeatedComponent, repeaterChild.getRowContext("3")));
Assert.assertTrue("List should contain card manager", isInList(visibles, cardManager, uic));
Assert.assertTrue("List should contain visible card", isInList(visibles, card1, uic));
// Make grandChild invisible - should only remove it
grandChild.setVisible(false);
visibles = TreeUtil.collateVisibles(root);
Assert.assertEquals("Incorrect number of visible components", 9, visibles.size());
Assert.assertTrue("List should contain root", isInList(visibles, root, uic));
Assert.assertTrue("List should contain containerChild", isInList(visibles, containerChild, uic));
Assert.assertTrue("List should contain simpleChild", isInList(visibles, simpleChild, uic));
Assert.assertTrue("List should contain repeaterChild", isInList(visibles, repeaterChild, uic));
Assert.assertTrue("List should contain repeatedComponent row 1", isInList(visibles, repeatedComponent, repeaterChild.getRowContext("1")));
Assert.assertTrue("List should contain repeatedComponent row 2", isInList(visibles, repeatedComponent, repeaterChild.getRowContext("2")));
Assert.assertTrue("List should contain repeatedComponent row 3", isInList(visibles, repeatedComponent, repeaterChild.getRowContext("3")));
Assert.assertTrue("List should contain card manager", isInList(visibles, cardManager, uic));
Assert.assertTrue("List should contain visible card", isInList(visibles, card1, uic));
grandChild.setVisible(true);
// Make containerChild invisible - should remove it and grandChild
containerChild.setVisible(false);
visibles = TreeUtil.collateVisibles(root);
Assert.assertEquals("Incorrect number of visible components", 8, visibles.size());
Assert.assertTrue("List should contain root", isInList(visibles, root, uic));
Assert.assertTrue("List should contain simpleChild", isInList(visibles, simpleChild, uic));
Assert.assertTrue("List should contain repeaterChild", isInList(visibles, repeaterChild, uic));
Assert.assertTrue("List should contain repeatedComponent row 1", isInList(visibles, repeatedComponent, repeaterChild.getRowContext("1")));
Assert.assertTrue("List should contain repeatedComponent row 2", isInList(visibles, repeatedComponent, repeaterChild.getRowContext("2")));
Assert.assertTrue("List should contain repeatedComponent row 3", isInList(visibles, repeatedComponent, repeaterChild.getRowContext("3")));
Assert.assertTrue("List should contain card manager", isInList(visibles, cardManager, uic));
Assert.assertTrue("List should contain visible card", isInList(visibles, card1, uic));
containerChild.setVisible(true);
// Make repeaterChild invisible - should remove it and its 3 rows
repeaterChild.setVisible(false);
visibles = TreeUtil.collateVisibles(root);
Assert.assertEquals("Incorrect number of visible components", 6, visibles.size());
Assert.assertTrue("List should contain root", isInList(visibles, root, uic));
Assert.assertTrue("List should contain containerChild", isInList(visibles, containerChild, uic));
Assert.assertTrue("List should contain simpleChild", isInList(visibles, simpleChild, uic));
Assert.assertTrue("List should contain grandChild", isInList(visibles, grandChild, uic));
Assert.assertTrue("List should contain card manager", isInList(visibles, cardManager, uic));
Assert.assertTrue("List should contain visible card", isInList(visibles, card1, uic));
repeaterChild.setVisible(true);
// Make 2nd row of repeater invisible
setActiveContext(repeaterChild.getRowContext("2"));
repeatedComponent.setVisible(false);
setActiveContext(uic);
visibles = TreeUtil.collateVisibles(root);
Assert.assertEquals("Incorrect number of visible components", 9, visibles.size());
Assert.assertTrue("List should contain root", isInList(visibles, root, uic));
Assert.assertTrue("List should contain containerChild", isInList(visibles, containerChild, uic));
Assert.assertTrue("List should contain simpleChild", isInList(visibles, simpleChild, uic));
Assert.assertTrue("List should contain repeaterChild", isInList(visibles, repeaterChild, uic));
Assert.assertTrue("List should contain grandChild", isInList(visibles, grandChild, uic));
Assert.assertTrue("List should contain repeatedComponent row 1", isInList(visibles, repeatedComponent, repeaterChild.getRowContext("1")));
Assert.assertTrue("List should contain repeatedComponent row 3", isInList(visibles, repeatedComponent, repeaterChild.getRowContext("3")));
Assert.assertTrue("List should contain card manager", isInList(visibles, cardManager, uic));
Assert.assertTrue("List should contain visible card", isInList(visibles, card1, uic));
// Switch active cards
cardManager.makeVisible(card2);
visibles = TreeUtil.collateVisibles(root);
Assert.assertEquals("Incorrect number of visible components", 9, visibles.size());
Assert.assertTrue("List should contain root", isInList(visibles, root, uic));
Assert.assertTrue("List should contain containerChild", isInList(visibles, containerChild, uic));
Assert.assertTrue("List should contain simpleChild", isInList(visibles, simpleChild, uic));
Assert.assertTrue("List should contain repeaterChild", isInList(visibles, repeaterChild, uic));
Assert.assertTrue("List should contain grandChild", isInList(visibles, grandChild, uic));
Assert.assertTrue("List should contain repeatedComponent row 1", isInList(visibles, repeatedComponent, repeaterChild.getRowContext("1")));
Assert.assertTrue("List should contain repeatedComponent row 3", isInList(visibles, repeatedComponent, repeaterChild.getRowContext("3")));
Assert.assertTrue("List should contain card manager", isInList(visibles, cardManager, uic));
Assert.assertTrue("List should contain visible card", isInList(visibles, card2, uic));
// Make root invisible - should be an empty list
root.setVisible(false);
visibles = TreeUtil.collateVisibles(root);
Assert.assertEquals("Incorrect number of visible components", 0, visibles.size());
}
use of com.github.bordertech.wcomponents.UIContext in project wcomponents by BorderTech.
the class DiagnosticImpl_Test method testGetContext.
@Test
public void testGetContext() {
final UIContext uic = new UIContextImpl();
DiagnosticImpl diag = new DiagnosticImpl(Diagnostic.INFO, uic, new WTextField(), "dummy");
Assert.assertSame("Incorrect UI context", uic, diag.getContext());
}
Aggregations