Search in sources :

Example 1 with HeadingElement

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");
}
Also used : Element(com.google.gwt.dom.client.Element) HeadingElement(com.google.gwt.dom.client.HeadingElement) HeadingElement(com.google.gwt.dom.client.HeadingElement) Test(org.junit.Test)

Example 2 with HeadingElement

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);
}
Also used : DivElement(com.google.gwt.dom.client.DivElement) User(com.willshex.blogwt.shared.api.datatype.User) HeadingElement(com.google.gwt.dom.client.HeadingElement) Tag(com.willshex.blogwt.shared.api.datatype.Tag) Document(com.google.gwt.dom.client.Document) Date(java.util.Date)

Example 3 with HeadingElement

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");
}
Also used : HeadingElement(com.google.gwt.dom.client.HeadingElement) Hyperlink(com.google.gwt.user.client.ui.Hyperlink) Test(org.junit.Test)

Example 4 with HeadingElement

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");
}
Also used : HeadingElement(com.google.gwt.dom.client.HeadingElement) RadioButton(com.google.gwt.user.client.ui.RadioButton) Test(org.junit.Test)

Example 5 with HeadingElement

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");
}
Also used : Anchor(com.google.gwt.user.client.ui.Anchor) HeadingElement(com.google.gwt.dom.client.HeadingElement) Test(org.junit.Test)

Aggregations

HeadingElement (com.google.gwt.dom.client.HeadingElement)7 Test (org.junit.Test)6 Element (com.google.gwt.dom.client.Element)2 DivElement (com.google.gwt.dom.client.DivElement)1 Document (com.google.gwt.dom.client.Document)1 Anchor (com.google.gwt.user.client.ui.Anchor)1 CheckBox (com.google.gwt.user.client.ui.CheckBox)1 Hyperlink (com.google.gwt.user.client.ui.Hyperlink)1 RadioButton (com.google.gwt.user.client.ui.RadioButton)1 Tag (com.willshex.blogwt.shared.api.datatype.Tag)1 User (com.willshex.blogwt.shared.api.datatype.User)1 Date (java.util.Date)1