Search in sources :

Example 36 with BootstrapContext

use of com.vaadin.flow.server.BootstrapHandler.BootstrapContext in project flow by vaadin.

the class BootstrapHandlerTest method head_has_ui_lang.

// #2956
@Test
public void head_has_ui_lang() throws Exception {
    initUI(testUI, createVaadinRequest());
    testUI.setLocale(Locale.FRENCH);
    Document page = BootstrapHandler.getBootstrapPage(new BootstrapContext(request, null, session, testUI));
    Element body = page.head().nextElementSibling();
    assertEquals("Expected body element", "body", body.tagName());
    assertEquals("Expected html element as parent to body element", "html", body.parent().tagName());
    assertTrue("Html tag was missing lang attribute", body.parent().hasAttr("lang"));
    assertEquals("Lang did not have UI defined language", testUI.getLocale().getLanguage(), body.parent().attr("lang"));
}
Also used : TargetElement(com.vaadin.flow.component.page.TargetElement) Element(org.jsoup.nodes.Element) BootstrapContext(com.vaadin.flow.server.BootstrapHandler.BootstrapContext) Document(org.jsoup.nodes.Document) Test(org.junit.Test)

Aggregations

BootstrapContext (com.vaadin.flow.server.BootstrapHandler.BootstrapContext)36 Test (org.junit.Test)32 Document (org.jsoup.nodes.Document)31 Elements (org.jsoup.select.Elements)21 TargetElement (com.vaadin.flow.component.page.TargetElement)13 Element (org.jsoup.nodes.Element)13 UI (com.vaadin.flow.component.UI)9 Registration (com.vaadin.flow.shared.Registration)9 Component (com.vaadin.flow.component.Component)8 Html (com.vaadin.flow.component.Html)8 Tag (com.vaadin.flow.component.Tag)8 Text (com.vaadin.flow.component.Text)8 HtmlImport (com.vaadin.flow.component.dependency.HtmlImport)8 JavaScript (com.vaadin.flow.component.dependency.JavaScript)8 StyleSheet (com.vaadin.flow.component.dependency.StyleSheet)8 BodySize (com.vaadin.flow.component.page.BodySize)8 Inline (com.vaadin.flow.component.page.Inline)8 Viewport (com.vaadin.flow.component.page.Viewport)8 PageTitle (com.vaadin.flow.router.PageTitle)8 ParentLayout (com.vaadin.flow.router.ParentLayout)8