/*- Add classnames;
* .v-app
* .v-app-loading
- * .v-app-<simpleName for app class>
*- Additionally added from javascript:
* <themeName, remove non-alphanum>
*/
mainDiv.attr("id", context.getAppId());
mainDiv.addClass("v-app");
mainDiv.addClass(context.getThemeName());
+ mainDiv.addClass(context.getUIClass().getSimpleName()
+ .toLowerCase(Locale.ENGLISH));
if (style != null && style.length() != 0) {
mainDiv.attr("style", style);
}
builder.append("//<![CDATA[\n");
builder.append("if (!window.vaadin) alert("
+ JsonUtil.quote("Failed to load the bootstrap javascript: "
- + bootstrapLocation) + ");\n");
+ + bootstrapLocation) + ");\n");
appendMainScriptTagContents(context, builder);
if (systemMessages.getAuthenticationErrorURL() == null) {
authErrMsg.put("url", Json.createNull());
} else {
- authErrMsg.put("url", systemMessages.getAuthenticationErrorURL());
+ authErrMsg.put("url",
+ systemMessages.getAuthenticationErrorURL());
}
appConfig.put("authErrMsg", authErrMsg);
--- /dev/null
+/*
+ * 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.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+
+/**
+ * Empty test ui to check auto-generated style name for UI.
+ *
+ * @author Vaadin Ltd
+ */
+public class UIAutoGeneratedStyleName extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Add UI specific autogenerated style name to ui div element"
+ + " and overlays container";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14670;
+ }
+
+}
--- /dev/null
+/*
+ * 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 java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.phantomjs.PhantomJSDriver;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.testbench.TestBench;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test to check auto-generated style name for UI div and overlays div.
+ *
+ * @author Vaadin Ltd
+ */
+public class UIAutoGeneratedStyleNameTest extends MultiBrowserTest {
+
+ @Test
+ public void testUiStyleName() {
+ openTestURL();
+
+ Assert.assertTrue(
+ "UI div element doesn't contain autogenerated style name",
+ containsStyle(getDriver().findElement(By.className("v-app")),
+ UIAutoGeneratedStyleName.class.getSimpleName()
+ .toLowerCase(Locale.ENGLISH)));
+
+ Assert.assertTrue(
+ "Overlays div element doesn't contain autogenerated style name",
+ containsStyle(
+ getDriver().findElement(
+ By.className("v-overlay-container")),
+ UIAutoGeneratedStyleName.class.getSimpleName()
+ .toLowerCase(Locale.ENGLISH)));
+ }
+
+ private boolean containsStyle(WebElement element, String style) {
+ return element.getAttribute("class").contains(style);
+ }
+
+ @Override
+ protected void setupDriver() throws Exception {
+ System.setProperty("phantomjs.binary.path",
+ "C:\\tmp\\phantom\\phantomjs.exe");
+ WebDriver dr = TestBench.createDriver(new PhantomJSDriver());
+ setDriver(dr);
+ }
+
+ @Override
+ protected String getScreenshotDirectory() {
+ return "C:\\tmp\\a";
+ }
+
+ @Override
+ protected void openTestURL() {
+ driver.get("http://localhost:8080/vaadin/run/UIAutoGeneratedStyleName");
+ }
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ return Collections.singletonList(Browser.FIREFOX
+ .getDesiredCapabilities());
+ }
+
+}