use of com.google.gwt.dom.client.HeadingElement in project gwt-test-utils by gwt-test-utils.
the class GridTest method html.
@Test
public void html() {
// Given
Grid g = new Grid(1, 1);
// When
g.setHTML(0, 0, "<h1>test</h1>");
// Then
assertThat(g.getHTML(0, 0)).isEqualTo("<h1>test</h1>");
Element e = g.getCellFormatter().getElement(0, 0);
assertThat(e.getChildCount()).isEqualTo(1);
HeadingElement h1 = e.getChild(0).cast();
assertThat(h1.getTagName()).isEqualTo("H1");
assertThat(h1.getInnerText()).isEqualTo("test");
}
use of com.google.gwt.dom.client.HeadingElement in project blogwt by billy1380.
the class EditPostPage method updatePreview.
private void updatePreview() {
pnlPreview.getElement().removeAllChildren();
Document d = Document.get();
HeadingElement title = d.createHElement(1);
title.setInnerHTML(PostHelper.makeHeading(txtTitle.getValue()));
pnlPreview.getElement().appendChild(title);
User user = SessionController.get().user();
DivElement elDate = d.createDivElement();
if (post != null) {
if (post.published == null) {
elDate.setInnerSafeHtml(PostSummaryCell.Templates.INSTANCE.notPublished(DateTimeHelper.ago(post.created)));
} else {
elDate.setInnerSafeHtml(PostSummaryCell.Templates.INSTANCE.publishedDate(DateTimeHelper.ago(post.published)));
}
} else {
elDate.setInnerSafeHtml(PostSummaryCell.Templates.INSTANCE.notPublished(DateTimeHelper.ago(new Date())));
}
pnlPreview.getElement().appendChild(elDate);
DivElement elAuthor = d.createDivElement();
if (PropertyController.get().booleanProperty(PropertyHelper.POST_SHOW_AUTHOR, false)) {
elAuthor.setInnerSafeHtml(PostSummaryCell.Templates.INSTANCE.author(UriUtils.fromString((post != null ? post.author.avatar : user.avatar) + "?s=" + UserHelper.AVATAR_HEADER_SIZE + "&default=retro"), UserHelper.handle((post != null ? post.author : user))));
}
pnlPreview.getElement().appendChild(elAuthor);
tagList.getList().clear();
List<String> tags = TagHelper.convertToTagList(txtTags.getValue());
if (tags != null) {
for (String tag : tags) {
tagList.getList().add(new Tag().name(tag));
}
}
DivElement summary = d.createDivElement();
summary.setInnerHTML(markup(txtSummary));
pnlPreview.getElement().appendChild(summary);
DivElement content = d.createDivElement();
content.setInnerHTML(markup(txtContent));
pnlPreview.getElement().appendChild(content);
}
use of com.google.gwt.dom.client.HeadingElement in project gwt-test-utils by gwt-test-utils.
the class HyperlinkTest method html.
@Test
public void html() {
// Given
Hyperlink link = new Hyperlink();
// When
link.setHTML("<h1>test</h1>");
// Then
assertThat(link.getHTML()).isEqualTo("<h1>test</h1>");
assertThat(link.getElement().getChild(0).getChildCount()).isEqualTo(1);
HeadingElement h1 = link.getElement().getChild(0).getChild(0).cast();
assertThat(h1.getTagName()).isEqualTo("H1");
assertThat(h1.getInnerText()).isEqualTo("test");
}
use of com.google.gwt.dom.client.HeadingElement in project gwt-test-utils by gwt-test-utils.
the class RadioButtonTest method html.
@Test
public void html() {
// Given
RadioButton rb = new RadioButton("myRadioGroup", "<h1>foo</h1>", true);
// Preconditions
assertThat(rb.getHTML()).isEqualTo("<h1>foo</h1>");
// When
rb.setHTML("<h1>test</h1>");
// Then
assertThat(rb.getHTML()).isEqualTo("<h1>test</h1>");
assertThat(rb.getElement().getChild(1).getChildCount()).isEqualTo(1);
HeadingElement h1 = rb.getElement().getChild(1).getChild(0).cast();
assertThat(h1.getTagName()).isEqualTo("H1");
assertThat(h1.getInnerText()).isEqualTo("test");
}
use of com.google.gwt.dom.client.HeadingElement in project gwt-test-utils by gwt-test-utils.
the class AnchorTest method html.
@Test
public void html() {
// Given
Anchor a = new Anchor("<h1>foo</h1>", true);
assertThat(a.getHTML()).isEqualTo("<h1>foo</h1>");
// When
a.setHTML("<h1>test</h1>");
// Then
assertThat(a.getHTML()).isEqualTo("<h1>test</h1>");
assertThat(a.getElement().getChildCount()).isEqualTo(1);
HeadingElement h1 = a.getElement().getChild(0).cast();
assertThat(h1.getTagName()).isEqualTo("H1");
assertThat(h1.getInnerText()).isEqualTo("test");
}
Aggregations