use of com.github.bordertech.wcomponents.util.mock.MockRequest in project wcomponents by BorderTech.
the class UicProfileButton_Test method testAfterPaintButtonPressed.
@Test
public void testAfterPaintButtonPressed() {
UicProfileButton button = new UicProfileButton();
button.setLocked(true);
setActiveContext(createUIContext());
StringWriter strWriter = new StringWriter();
PrintWriter writer = new PrintWriter(strWriter);
MockRequest request = new MockRequest();
button.setPressed(true, request);
button.afterPaint(new WebXmlRenderContext(writer));
Assert.assertTrue("for button pressed afterpaint writer output should start with <br/><br/>", strWriter.toString().startsWith("<br/><br/>"));
}
use of com.github.bordertech.wcomponents.util.mock.MockRequest in project wcomponents by BorderTech.
the class UicProfileButton_Test method testDumpAll.
@Test
public void testDumpAll() {
UicProfileButton button = new UicProfileButton();
button.setLocked(true);
setActiveContext(createUIContext());
MockRequest request = new MockRequest();
button.setPressed(true, request);
String result = button.dumpAll().toString();
// result table contains class name
Assert.assertTrue("dump table should contain component class name", result.indexOf("<td>" + button.getClass().getName() + "</td>") != -1);
// result table contains component id
Assert.assertTrue("dump table should contain component id", result.indexOf("<td>" + button.getId() + "</td>") != -1);
// result table contains isSerialisable
Assert.assertTrue("dump table should contain serialisability", result.indexOf("<td>true</td>") != -1);
// result table contains size
Assert.assertTrue("dump table should contain size", result.indexOf("<td>0</td></tr>") != -1);
}
use of com.github.bordertech.wcomponents.util.mock.MockRequest in project wcomponents by BorderTech.
the class UicProfileButton_Test method testAfterPaintButtonNotPressed.
@Test
public void testAfterPaintButtonNotPressed() {
UicProfileButton button = new UicProfileButton();
button.setLocked(true);
setActiveContext(createUIContext());
StringWriter strWriter = new StringWriter();
PrintWriter writer = new PrintWriter(strWriter);
MockRequest request = new MockRequest();
button.setPressed(false, request);
button.afterPaint(new WebXmlRenderContext(writer));
Assert.assertEquals("for button not pressed afterPaint writer output should be empty", strWriter.toString(), "");
}
use of com.github.bordertech.wcomponents.util.mock.MockRequest in project wcomponents by BorderTech.
the class WAjaxControl_Test method testPreparePaintComponent.
@Test
public void testPreparePaintComponent() {
WApplication app = new WApplication();
AjaxTrigger trigger = new WButton();
AjaxTarget target = new WPanel();
WAjaxControl control = new WAjaxControl(trigger, target);
app.add(control);
app.add(trigger);
app.add(target);
app.setLocked(true);
UIContext uic = createUIContext();
uic.setUI(app);
setActiveContext(uic);
MockRequest req = new MockRequest();
control.handleRequest(req);
control.preparePaint(req);
AjaxOperation ajaxOperation = AjaxHelper.getAjaxOperation(trigger.getId());
Assert.assertNotNull("Ajax operation should have been registered", ajaxOperation);
Assert.assertEquals("Incorrect ajax operation trigger id", trigger.getId(), ajaxOperation.getTriggerId());
Assert.assertEquals("Incorrect ajax operation targets", target.getId(), ajaxOperation.getTargets().get(0));
}
use of com.github.bordertech.wcomponents.util.mock.MockRequest in project wcomponents by BorderTech.
the class WDataTable_Test method testSingleHandleSelectionRequest.
@Test
public void testSingleHandleSelectionRequest() {
WDataTable table = new WDataTable();
table.setSelectMode(WDataTable.SelectMode.SINGLE);
table.setDataModel(new SimpleTableDataModel(new String[100][1]));
table.setLocked(true);
setActiveContext(createUIContext());
MockRequest request = new MockRequest();
request.setParameter(table.getId() + "-h", "x");
request.setParameter(table.getId() + ".selected", new String[] { "5", "6", "7" });
table.handleRequest(request);
Assert.assertEquals("Should only have selected the first item after handleRequest", Arrays.asList(new Integer[] { 5 }), table.getSelectedRows());
resetContext();
Assert.assertTrue("Incorrect default selection after handleRequest", table.getSelectedRows().isEmpty());
}
Aggregations