diff options
author | Leif Åstrand <leif@vaadin.com> | 2015-01-10 22:19:36 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2015-01-12 14:25:23 +0000 |
commit | e20f6fd54ae4b350ea654807b98fe442e546d1a8 (patch) | |
tree | 1c0ac2492469c7dba4b7a2ce5dde216d989316af /uitest/src/com | |
parent | 2bc4f17916e919d7b92dcf03877c7bf2ff0f51c8 (diff) | |
download | vaadin-framework-e20f6fd54ae4b350ea654807b98fe442e546d1a8.tar.gz vaadin-framework-e20f6fd54ae4b350ea654807b98fe442e546d1a8.zip |
Include UI class @JavaScript and @StyleSheet in bootstrap html (#9045)
Change-Id: I9d4243fa6f91ba5bc3449d0a3ec24f209e6360e6
Diffstat (limited to 'uitest/src/com')
3 files changed, 99 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtml.java b/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtml.java new file mode 100644 index 0000000000..96210b2027 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtml.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.ui; + +import com.vaadin.annotations.JavaScript; +import com.vaadin.annotations.StyleSheet; +import com.vaadin.annotations.Theme; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Label; + +@JavaScript("uiDependency.js") +@StyleSheet("theme://uiDependency.css") +@Theme("tests-valo") +public class UiDependenciesInHtml extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Label statusBox = new Label("Status box"); + statusBox.setId("statusBox"); + addComponent(statusBox); + + getPage().getJavaScript().execute("window.reportUiDependencyStatus();"); + } +} diff --git a/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtmlTest.java b/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtmlTest.java new file mode 100644 index 0000000000..188a0aea3e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtmlTest.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.ui; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class UiDependenciesInHtmlTest extends SingleBrowserTest { + + @Test + public void testUiDependencisInHtml() { + openTestURL(); + + String statusText = findElement(By.id("statusBox")).getText(); + + Assert.assertEquals( + "Script loaded before vaadinBootstrap.js: true\nStyle tag before vaadin theme: true", + statusText); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/ui/uiDependency.js b/uitest/src/com/vaadin/tests/components/ui/uiDependency.js new file mode 100644 index 0000000000..4a5775c57f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/uiDependency.js @@ -0,0 +1,24 @@ +(function() { + var loadedBeforeVaadin = (window.vaadin === undefined); + + window.reportUiDependencyStatus = function() { + var styleIndex = 1000; + var themeIndex = -1; + + var stylesheets = document.querySelectorAll("link[rel=stylesheet]"); + for(var i = 0; i < stylesheets.length; i++) { + var stylesheet = stylesheets[i]; + var href = stylesheet.getAttribute("href"); + if (href.indexOf("uiDependency.css") > -1) { + styleIndex = i; + } else if (href.indexOf("styles.css" > -1)) { + themeIndex = i; + } + } + + var status = "Script loaded before vaadinBootstrap.js: " + loadedBeforeVaadin; + status += "<br />Style tag before vaadin theme: " + (styleIndex < themeIndex); + + document.getElementById("statusBox").innerHTML = status; + } +})();
\ No newline at end of file |