use of com.vaadin.flow.server.BootstrapHandler.BootstrapContext in project flow by vaadin.
the class BootstrapHandlerTest method force_wrapping_of_file.
// 3010
@Test
public void force_wrapping_of_file() throws InvalidRouteConfigurationException {
initUI(testUI, createVaadinRequest(), Collections.singleton(ForcedWrapping.class));
Document page = BootstrapHandler.getBootstrapPage(new BootstrapContext(request, null, session, testUI));
Elements allElements = page.head().getAllElements();
assertStringEquals("File css should have been prepended to body element", "<style type=\"text/css\">window.messages = window.messages || [];\n" + "window.messages.push(\"inline.js\");</style>", allElements.get(allElements.size() - 1).toString());
}
use of com.vaadin.flow.server.BootstrapHandler.BootstrapContext in project flow by vaadin.
the class BootstrapHandlerTest method theme_contents_are_appended_to_head_for_alias_route.
// 3333
@Test
public void theme_contents_are_appended_to_head_for_alias_route() throws InvalidRouteConfigurationException {
HttpServletRequest request = createRequest();
Mockito.doAnswer(invocation -> "/alias").when(request).getPathInfo();
VaadinServletRequest aliasRequest = new VaadinServletRequest(request, service);
initUI(testUI, aliasRequest, Collections.singleton(MyAliasThemeTest.class));
Document page = BootstrapHandler.getBootstrapPage(new BootstrapContext(aliasRequest, null, session, testUI));
Elements allElements = page.head().getAllElements();
Assert.assertTrue("Custom style should have been added to head.", allElements.stream().map(Object::toString).anyMatch(element -> element.equals("<link rel=\"import\" href=\"./frontend/bower_components/vaadin-lumo-styles/color.html\">")));
allElements = page.body().getAllElements();
// Note element 0 is the full head element.
assertStringEquals("Custom style should have been added to head.", "<custom-style><style include=\"lumo-typography\"></style></custom-style>", allElements.get(2).toString());
Assert.assertTrue("Style should have been wrapped in custom style", page.body().toString().contains("<custom-style><style include=\"lumo-typography\"></style></custom-style>"));
}
use of com.vaadin.flow.server.BootstrapHandler.BootstrapContext in project flow by vaadin.
the class BootstrapHandlerTest method page_configurator_adds_meta_tags.
// 3036
@Test
public void page_configurator_adds_meta_tags() throws InvalidRouteConfigurationException {
initUI(testUI, createVaadinRequest(), Collections.singleton(InitialPageConfiguratorMetaTag.class));
Document page = BootstrapHandler.getBootstrapPage(new BootstrapContext(request, null, session, testUI));
Elements allElements = page.head().getAllElements();
Assert.assertEquals("<meta name=\"theme-color\" content=\"#227aef\">", allElements.get(1).toString());
}
use of com.vaadin.flow.server.BootstrapHandler.BootstrapContext in project flow by vaadin.
the class BootstrapHandlerTest method page_configurator_adds_styles_for_body.
// 2344
@Test
public void page_configurator_adds_styles_for_body() throws InvalidRouteConfigurationException {
initUI(testUI, createVaadinRequest(), Collections.singleton(InitialPageConfiguratorBodyStyle.class));
Document page = BootstrapHandler.getBootstrapPage(new BootstrapContext(request, null, session, testUI));
Elements allElements = page.head().getAllElements();
Assert.assertEquals("<style type=\"text/css\">body {width: 100vw; height:100vh; margin:0;}</style>", allElements.get(allElements.size() - 1).toString());
}
use of com.vaadin.flow.server.BootstrapHandler.BootstrapContext in project flow by vaadin.
the class BootstrapHandlerTest method use_inline_to_prepend_files_to_head.
// 3010
@Test
public void use_inline_to_prepend_files_to_head() throws InvalidRouteConfigurationException {
initUI(testUI, createVaadinRequest(), Collections.singleton(PrependInlineAnnotations.class));
Document page = BootstrapHandler.getBootstrapPage(new BootstrapContext(request, null, session, testUI));
Elements allElements = page.head().getAllElements();
// Note element 0 is the full head element.
assertStringEquals("File javascript should have been prepended to head element", "<script type=\"text/javascript\">window.messages = window.messages || [];\n" + "window.messages.push(\"inline.js\");</script>", allElements.get(1).toString());
assertStringEquals("File html should have been prepended to head element", "<script type=\"text/javascript\">\n" + " // document.body might not yet be accessible, so just leave a message\n" + " window.messages = window.messages || [];\n" + " window.messages.push(\"inline.html\");\n" + "</script>", allElements.get(2).toString());
assertStringEquals("File css should have been prepended to head element", "<style type=\"text/css\">/* inline.css */\n" + "\n" + "#preloadedDiv {\n" + " color: rgba(255, 255, 0, 1);\n" + "}\n" + "\n" + "#inlineCssTestDiv {\n" + " color: rgba(255, 255, 0, 1);\n" + "}</style>", allElements.get(3).toString());
}
Aggregations