@Override public IsHTMLPanel newHTMLPanel(String html) { return new StubHTMLPanel(html); }
@Override public void insert(IsWidget widget, IsElement parent, int beforeIndex, boolean domInsert) { // We can't really honor beforeIndex, because it deals with DOM order (which // depends on the contents of the ui.xml file), and we only track widgets. add(widget, parent); }
@Test public void testInsertDomInsertFalse() { StubTextBox b = new StubTextBox(); StubElement e = new StubElement(); p.insert(b, e, 0, false); assertThat(p.getIsWidget(0), is((IsWidget) b)); assertThat(p.getAddedTo(e).get(0), is((com.google.gwt.user.client.ui.IsWidget) b)); }
protected void assertHtml(HTMLPanelBuilder hb, String... html) { StubHTMLPanel p = (StubHTMLPanel) hb.toHTMLPanel(); assertThat(p.getHtml(), is(Join.join(html, ""))); }
private StubTextList errorList(String id) { return (StubTextList) html().findById(id); }
private StubTextBox tb(String id) { return (StubTextBox) html().getReplaced(id); }
@Test public void testInsertDomInsertTrue() { StubTextBox b = new StubTextBox(); StubElement e = new StubElement(); p.insert(b, e, 0, true); assertThat(p.getIsWidget(0), is((IsWidget) b)); assertThat(p.getAddedTo(e).get(0), is((com.google.gwt.user.client.ui.IsWidget) b)); }
protected void assertHtml(String... html) { assertThat(html().getHtml(), is(Join.join(html, ""))); }
private StubListBox listBox(String id) { return (StubListBox) html().findById(id); }
private StubTextList errors(String id) { return (StubTextList) html().getReplaced(id); }
@Test public void htmlOfOneTextBox() { p.add(new TextBoxFormLine(employee.firstName)); assertThat(html().getHtml(), is(Join.join(new String[] {// "<div class=\"form\">",// "<div class=\"lines\"><ol>", "<li>", "<div class=\"label\"><label for=\"p-firstName\">First Name</label></div>",// "<div class=\"value\"><div id=\"mpv-hb-1\"></div><div class=\"errors\"><div id=\"mpv-hb-2\"></div></div></div>",// "</li>", "</ol></div>", "</div>" }, ""))); }
@Override public IsHTMLPanel newHTMLPanel(String tag, String html) { return new StubHTMLPanel(tag, html); }
@Test public void customLine() { p.add(new TextBoxFormLine(employee.firstName)); p.add(new StaticFormLine() { @Override public void render(FormPresenter p, FormLayout l, HTMLPanelBuilder hb) { hb.add("some custom html"); } }); assertThat(html().getHtml(), is(Join.join(new String[] {// "<div class=\"form\">",// "<div class=\"lines\"><ol>", "<li>", "<div class=\"label\"><label for=\"p-firstName\">First Name</label></div>",// "<div class=\"value\"><div id=\"mpv-hb-3\"></div><div class=\"errors\"><div id=\"mpv-hb-4\"></div></div></div>",// "</li>some custom html", "</ol></div>", "</div>" }, ""))); }