summaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-05-13 14:46:58 +0300
committerLeif Åstrand <leif@vaadin.com>2013-05-13 14:46:58 +0300
commitdca728c134756f5a4e9296ab7ac95198675a69db (patch)
tree7ab2327b635ea0564d4687d4f1cfb4c6f0dca24c /uitest/src
parent55ea6dce33bec44140984633a6d3aee7910b89da (diff)
downloadvaadin-framework-dca728c134756f5a4e9296ab7ac95198675a69db.tar.gz
vaadin-framework-dca728c134756f5a4e9296ab7ac95198675a69db.zip
Warn if using old widgetset (#11836)
Change-Id: Id7332da3468572f4df55aa7b3fed39ef811fe09d
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/com/vaadin/tests/components/AbstractTestUI.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java
index a044b52f18..45809e3270 100644
--- a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java
+++ b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java
@@ -1,10 +1,16 @@
package com.vaadin.tests.components;
+import java.io.File;
+
+import com.vaadin.annotations.Widgetset;
import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinServlet;
import com.vaadin.server.WebBrowser;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.Notification.Type;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@@ -27,9 +33,67 @@ public abstract class AbstractTestUI extends UI {
rootLayout.addComponent(layout);
((VerticalLayout) getContent()).setExpandRatio(layout, 1);
+ warnIfWidgetsetMaybeNotCompiled();
+
setup(request);
}
+ protected void warnIfWidgetsetMaybeNotCompiled() {
+ // Ignore if using debug mode
+ if (getPage().getLocation().getQuery().matches(".*[&?]gwt\\.codesvr.*")) {
+ return;
+ }
+
+ // Find out the widgetset of this UI based on @Widgetset annotation
+ Class<?> currentType = getClass();
+ String usedWidgetset = VaadinServlet.DEFAULT_WIDGETSET;
+ while (currentType != Object.class) {
+ Widgetset annotation = currentType.getAnnotation(Widgetset.class);
+ if (annotation != null) {
+ usedWidgetset = annotation.value();
+ break;
+ } else {
+ currentType = currentType.getSuperclass();
+ }
+ }
+
+ // Assuming the same folder structure as in git repo
+ // Assuming project root is the working dir of this process
+ File widgetsetsFolder = new File("WebContent/VAADIN/widgetsets");
+ if (!widgetsetsFolder.isDirectory()) {
+ return;
+ }
+
+ // Find the most newly compiled widgetset
+ long newestWidgetsetTimestamp = -1;
+ String newestWidgetsetName = null;
+ File[] children = widgetsetsFolder.listFiles();
+ for (File child : children) {
+ if (!child.isDirectory() || child.getName().equals("WEB-INF")) {
+ continue;
+ }
+ long lastModified = child.lastModified();
+ if (lastModified > newestWidgetsetTimestamp) {
+ newestWidgetsetTimestamp = lastModified;
+ newestWidgetsetName = child.getName();
+ }
+ }
+
+ // Compare to currently used widgetset, with a 30 minute grace period
+ File currentWidgetsetFolder = new File(widgetsetsFolder, usedWidgetset);
+ long currentWidgetsetTimestamp = currentWidgetsetFolder.lastModified();
+ int halfHour = 30 * 60 * 1000;
+ if (currentWidgetsetTimestamp + halfHour < newestWidgetsetTimestamp) {
+ Notification
+ .show("The currently used widgetset ("
+ + usedWidgetset
+ + ") was compiled long before the most recently compiled one ("
+ + newestWidgetsetName
+ + "). Are you sure you have compiled the right widgetset?",
+ Type.WARNING_MESSAGE);
+ }
+ }
+
private VerticalLayout layout;
protected VerticalLayout getLayout() {