Преглед на файлове

Made Valo test UI deterministic and added TB test

Change-Id: I342fad836ad0d4014748a06c8ccfed53a99e6ece
tags/7.3.0.rc1
Artur Signell преди 9 години
родител
ревизия
702f00f865

+ 21
- 0
build/ide.xml Целия файл

@@ -71,6 +71,27 @@
<antcall target="compile-theme" inheritRefs="true">
<param name="theme" value="valo" />
</antcall>
<antcall target="compile-theme" inheritRefs="true">
<param name="theme" value="tests-valo" />
</antcall>
<antcall target="compile-theme" inheritRefs="true">
<param name="theme" value="tests-valo-dark" />
</antcall>
<antcall target="compile-theme" inheritRefs="true">
<param name="theme" value="tests-valo-metro" />
</antcall>
<antcall target="compile-theme" inheritRefs="true">
<param name="theme" value="tests-valo-flat" />
</antcall>
<antcall target="compile-theme" inheritRefs="true">
<param name="theme" value="tests-valo-flatdark" />
</antcall>
<antcall target="compile-theme" inheritRefs="true">
<param name="theme" value="tests-valo-facebook" />
</antcall>
<antcall target="compile-theme" inheritRefs="true">
<param name="theme" value="tests-valo-blueprint" />
</antcall>
</parallel>
</target>


+ 0
- 1
buildhelpers/ivy.xml Целия файл

@@ -18,7 +18,6 @@
<conf name="build" />
<conf name="build-provided" />
<conf name="ide" visibility="private" />
<conf name="test" />
</configurations>
<publications>
<artifact type="jar" />

+ 103
- 32
uitest/build.xml Целия файл

@@ -11,6 +11,7 @@
<property name="module.name" value="vaadin-uitest" />
<property name="uitest.dir" location="${vaadin.basedir}/uitest" />
<property name="result.dir" value="result" />
<property name="theme.result.dir" value="${result.dir}/VAADIN/themes" />
<property name="result.war" location="${result.dir}/lib/${module.name}-${vaadin.version}.war" />

<path id="classpath.compile.custom">
@@ -91,7 +92,7 @@

</target>

<target name="war" depends="dependencies, compile, testing-widgetset">
<target name="war" depends="dependencies, compile, compile-test-themes, testing-widgetset">
<property name="result.dir" location="result" />
<property name="classes" location="${result.dir}/classes" />
<property name="WebContent.dir" location="${vaadin.basedir}/WebContent" />
@@ -121,10 +122,13 @@
<fileset refid="common.files.for.all.jars" />
<fileset dir="${result.dir}">
<include name="VAADIN/widgetsets/**/*" />
<include name="VAADIN/themes/tests-valo*/**" />
</fileset>
<fileset dir="${WebContent.dir}">
<include name="statictestfiles/**" />
<include name="VAADIN/themes/tests-*/**" />
<!-- Scss themes compiled and included above -->
<exclude name="VAADIN/themes/tests-valo*/**" />
<include name="VAADIN/themes/reindeer-tests/**" />
<include name="VAADIN/jquery.atmosphere.js" />
<include name="WEB-INF/*.xml" />
@@ -192,43 +196,43 @@
</target>

<target name="test-server" depends="clean-testbench-errors">
<property name="war.file" location="${vaadin.basedir}/result/artifacts/${vaadin.version}/vaadin-uitest/vaadin-uitest-${vaadin.version}.war" />
<parallel>
<daemons>
<ant antfile="${uitest.dir}/vaadin-server.xml" inheritall="true" inheritrefs="true" target="deploy-and-start" />
</daemons>
<sequential>
<ant antfile="${uitest.dir}/integration_tests.xml" target="integration-test-all" inheritall="false" inheritrefs="false">
<property name="demo.war" value="${war.file}" />
</ant>
</sequential>
</parallel>
<property name="war.file" location="${vaadin.basedir}/result/artifacts/${vaadin.version}/vaadin-uitest/vaadin-uitest-${vaadin.version}.war" />
<parallel>
<daemons>
<ant antfile="${uitest.dir}/vaadin-server.xml" inheritall="true" inheritrefs="true" target="deploy-and-start" />
</daemons>
<sequential>
<ant antfile="${uitest.dir}/integration_tests.xml" target="integration-test-all" inheritall="false" inheritrefs="false">
<property name="demo.war" value="${war.file}" />
</ant>
</sequential>
</parallel>
</target>

<target name="test-tb2" depends="clean-testbench-errors">
<property name="war.file" location="${vaadin.basedir}/result/artifacts/${vaadin.version}/vaadin-uitest/vaadin-uitest-${vaadin.version}.war" />
<parallel>
<daemons>
<ant antfile="${uitest.dir}/vaadin-server.xml" inheritall="true" inheritrefs="true" target="deploy-and-start" />
</daemons>
<sequential>
<ant antfile="${uitest.dir}/vaadin-server.xml" target="wait-for-startup" />
<ant antfile="${uitest.dir}/test.xml" target="tb2-tests" />
</sequential>
</parallel>
<property name="war.file" location="${vaadin.basedir}/result/artifacts/${vaadin.version}/vaadin-uitest/vaadin-uitest-${vaadin.version}.war" />
<parallel>
<daemons>
<ant antfile="${uitest.dir}/vaadin-server.xml" inheritall="true" inheritrefs="true" target="deploy-and-start" />
</daemons>
<sequential>
<ant antfile="${uitest.dir}/vaadin-server.xml" target="wait-for-startup" />
<ant antfile="${uitest.dir}/test.xml" target="tb2-tests" />
</sequential>
</parallel>
</target>

<target name="test-tb3" depends="clean-testbench-errors">
<property name="war.file" location="${vaadin.basedir}/result/artifacts/${vaadin.version}/vaadin-uitest/vaadin-uitest-${vaadin.version}.war" />
<parallel>
<daemons>
<ant antfile="${uitest.dir}/vaadin-server.xml" inheritall="true" inheritrefs="true" target="deploy-and-start" />
</daemons>
<sequential>
<ant antfile="${uitest.dir}/vaadin-server.xml" target="wait-for-startup" />
<ant antfile="${uitest.dir}/tb3test.xml" target="run-all-tb3-tests" inheritall="true" />
</sequential>
</parallel>
<property name="war.file" location="${vaadin.basedir}/result/artifacts/${vaadin.version}/vaadin-uitest/vaadin-uitest-${vaadin.version}.war" />
<parallel>
<daemons>
<ant antfile="${uitest.dir}/vaadin-server.xml" inheritall="true" inheritrefs="true" target="deploy-and-start" />
</daemons>
<sequential>
<ant antfile="${uitest.dir}/vaadin-server.xml" target="wait-for-startup" />
<ant antfile="${uitest.dir}/tb3test.xml" target="run-all-tb3-tests" inheritall="true" />
</sequential>
</parallel>
</target>

<target name="clean-testbench-errors">
@@ -241,4 +245,71 @@
</delete>
</target>

<target name="compile-test-themes">
<antcall target="compile-theme">
<param name="theme" value="tests-valo" />
</antcall>
<antcall target="compile-theme">
<param name="theme" value="tests-valo-dark" />
</antcall>
<antcall target="compile-theme">
<param name="theme" value="tests-valo-metro" />
</antcall>
<antcall target="compile-theme">
<param name="theme" value="tests-valo-flat" />
</antcall>
<antcall target="compile-theme">
<param name="theme" value="tests-valo-flatdark" />
</antcall>
<antcall target="compile-theme">
<param name="theme" value="tests-valo-facebook" />
</antcall>
<antcall target="compile-theme">
<param name="theme" value="tests-valo-blueprint" />
</antcall>

</target>
<target name="compile-theme" depends="copy-theme">
<fail unless="theme" message="You must give the theme name to compile in the 'theme' parameter" />

<ivy:resolve log="download-only" resolveid="common" conf="compile-theme" />
<ivy:cachepath pathid="classpath.compile.theme" conf="compile-theme" />
<ivy:cachepath pathid="classpath.runtime.theme" conf="build" />

<echo>Compiling ${theme}</echo>
<mkdir dir="${theme.result.dir}" />

<!-- compile the theme -->
<java classname="com.vaadin.buildhelpers.CompileTheme" classpathref="classpath.compile.theme" failonerror="yes" fork="yes" maxmemory="512m">
<arg value="--theme" />
<arg value="${theme}" />
<arg value="--theme-folder" />
<arg value="${theme.result.dir}" />
<arg value="--version" />
<arg value="${vaadin.version}" />
<jvmarg value="-Xss8M" />
<jvmarg value="-XX:MaxPermSize=256M" />
<jvmarg value="-Djava.awt.headless=true" />
</java>

</target>

<target name="copy-theme">
<fail unless="theme" message="You must give the theme name to copy n the 'theme' parameter" />
<property name="theme.source.dir" location="../WebContent/VAADIN/themes" />

<copy todir="${theme.result.dir}">
<fileset dir="${theme.source.dir}">
<include name="${theme}/**/*.scss" />
</fileset>
<filterset refid="filter-vaadin.version" />
</copy>
<copy todir="${theme.result.dir}">
<fileset dir="${theme.source.dir}">
<exclude name="${theme}/**/*.scss" />
</fileset>
</copy>
</target>


</project>

+ 8
- 0
uitest/ivy.xml Целия файл

@@ -15,6 +15,7 @@
<conf name="build-provided" visibility="private" />
<conf name="ide" visibility="private" />
<conf name="jetty-run" visibility="private" />
<conf name="compile-theme" visibility="private" />
</configurations>
<publications>
<artifact type="war" ext="war" />
@@ -99,6 +100,13 @@
<!-- This should be removed once tests have been updated to use lang3 -->
<dependency org="commons-lang" name="commons-lang"
rev="2.6" conf="build,ide -> default" />

<dependency org="com.vaadin" name="vaadin-sass-compiler"
rev="${vaadin.sass.version}" conf="compile-theme->default" />

<dependency org="com.vaadin" name="vaadin-buildhelpers"
rev="${vaadin.version}" conf="compile-theme->build" />

</dependencies>

</ivy-module>

+ 73
- 0
uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java Целия файл

@@ -18,14 +18,25 @@ package com.vaadin.tests.tb3;

import static com.vaadin.tests.tb3.TB3Runner.localWebDriverIsUsed;

import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Field;
import java.net.URL;
import java.util.Collections;
import java.util.List;

import org.apache.commons.io.IOUtils;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHttpEntityEnclosingRequest;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
@@ -42,6 +53,7 @@ import org.openqa.selenium.interactions.internal.Coordinates;
import org.openqa.selenium.internal.Locatable;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.HttpCommandExecutor;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
@@ -51,6 +63,7 @@ import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium;
import com.vaadin.server.LegacyApplication;
import com.vaadin.server.UIProvider;
import com.vaadin.testbench.TestBench;
import com.vaadin.testbench.TestBenchDriverProxy;
import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.TestBenchTestCase;
import com.vaadin.tests.components.AbstractTestUIWithLog;
@@ -1166,4 +1179,64 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
return true;
}

// FIXME: Remove this once TB4 getRemoteControlName works properly
private RemoteWebDriver getRemoteDriver() {
WebDriver d = getDriver();
if (d instanceof TestBenchDriverProxy) {
try {
Field f = TestBenchDriverProxy.class
.getDeclaredField("actualDriver");
f.setAccessible(true);
return (RemoteWebDriver) f.get(d);
} catch (Exception e) {
e.printStackTrace();
}
}

if (d instanceof RemoteWebDriver) {
return (RemoteWebDriver) d;
}

return null;

}

// FIXME: Remove this once TB4 getRemoteControlName works properly
protected String getRemoteControlName() {
try {
RemoteWebDriver d = getRemoteDriver();
if (d == null) {
return null;
}
HttpCommandExecutor ce = (HttpCommandExecutor) d
.getCommandExecutor();
String hostName = ce.getAddressOfRemoteServer().getHost();
int port = ce.getAddressOfRemoteServer().getPort();
HttpHost host = new HttpHost(hostName, port);
DefaultHttpClient client = new DefaultHttpClient();
URL sessionURL = new URL("http://" + hostName + ":" + port
+ "/grid/api/testsession?session=" + d.getSessionId());
BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest(
"POST", sessionURL.toExternalForm());
HttpResponse response = client.execute(host, r);
JSONObject object = extractObject(response);
URL myURL = new URL(object.getString("proxyId"));
if ((myURL.getHost() != null) && (myURL.getPort() != -1)) {
return myURL.getHost();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}

private static JSONObject extractObject(HttpResponse resp)
throws IOException, JSONException {
InputStream contents = resp.getEntity().getContent();
StringWriter writer = new StringWriter();
IOUtils.copy(contents, writer, "UTF8");
JSONObject objToReturn = new JSONObject(writer.toString());
return objToReturn;
}

}

+ 11
- 44
uitest/src/com/vaadin/tests/themes/valo/CalendarTest.java Целия файл

@@ -4,7 +4,6 @@ import java.text.DateFormatSymbols;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;

import com.vaadin.annotations.Theme;
@@ -51,6 +50,7 @@ import com.vaadin.ui.components.calendar.event.BasicEventProvider;
import com.vaadin.ui.components.calendar.event.CalendarEvent;
import com.vaadin.ui.components.calendar.handler.BasicDateClickHandler;
import com.vaadin.ui.components.calendar.handler.BasicWeekClickHandler;
import com.vaadin.ui.themes.ValoTheme;

/** Calendar component test application */
@Theme("valo-test")
@@ -108,7 +108,7 @@ public class CalendarTest extends GridLayout implements View {

private Button applyEventButton;

private Mode viewMode = Mode.MONTH;
private Mode viewMode = Mode.WEEK;

private BasicEventProvider dataSource;

@@ -152,52 +152,11 @@ public class CalendarTest extends GridLayout implements View {
setSpacing(true);

// handleURLParams(request.getParameterMap());
testBench = ValoThemeUI.isTestMode();

initContent();
}

private void handleURLParams(Map<String, String[]> parameters) {
testBench = parameters.containsKey("testBench")
|| parameters.containsKey("?testBench");

if (parameters.containsKey("width")) {
calendarWidth = parameters.get("width")[0];
}

if (parameters.containsKey("height")) {
calendarHeight = parameters.get("height")[0];
}

if (parameters.containsKey("firstDay")) {
firstDay = Integer.parseInt(parameters.get("firstDay")[0]);
}

if (parameters.containsKey("lastDay")) {
lastDay = Integer.parseInt(parameters.get("lastDay")[0]);
}

if (parameters.containsKey("firstHour")) {
firstHour = Integer.parseInt(parameters.get("firstHour")[0]);
}

if (parameters.containsKey("lastHour")) {
lastHour = Integer.parseInt(parameters.get("lastHour")[0]);
}

if (parameters.containsKey("locale")) {
String localeArray[] = parameters.get("locale")[0].split("_");
defaultLocale = new Locale(localeArray[0], localeArray[1]);
setLocale(defaultLocale);
}

if (parameters.containsKey(("secondsResolution"))) {
useSecondResolution = true;
}

showWeeklyView = parameters.containsKey("weekly");

}

public void initContent() {
// Set default Locale for this application
if (testBench) {
@@ -365,6 +324,9 @@ public class CalendarTest extends GridLayout implements View {
Alignment.MIDDLE_LEFT);
controlPanel.setComponentAlignment(addNewEvent, Alignment.MIDDLE_LEFT);

Label viewCaption = new Label("Calendar");
viewCaption.setStyleName(ValoTheme.LABEL_H1);
addComponent(viewCaption);
addComponent(controlPanel);
addComponent(hl);
addComponent(calendarComponent);
@@ -645,6 +607,11 @@ public class CalendarTest extends GridLayout implements View {
calendar.setTime(today);
calendarComponent.getInternalCalendar().setTime(today);

// Calendar getStartDate (and getEndDate) has some strange logic which
// returns Monday of the current internal time if no start date has been
// set
calendarComponent.setStartDate(calendarComponent.getStartDate());
calendarComponent.setEndDate(calendarComponent.getEndDate());
int rollAmount = calendar.get(GregorianCalendar.DAY_OF_MONTH) - 1;
calendar.add(GregorianCalendar.DAY_OF_MONTH, -rollAmount);
currentMonthsFirstDate = calendar.getTime();

+ 5
- 3
uitest/src/com/vaadin/tests/themes/valo/CommonParts.java Целия файл

@@ -131,9 +131,11 @@ public class CommonParts extends VerticalLayout implements View {
spinnerDesc.setCaption("Spinner");
content.addComponent(spinnerDesc);

Label spinner = new Label();
spinner.addStyleName("spinner");
content.addComponent(spinner);
if (!ValoThemeUI.isTestMode()) {
Label spinner = new Label();
spinner.addStyleName("spinner");
content.addComponent(spinner);
}

return p;
}

+ 30
- 20
uitest/src/com/vaadin/tests/themes/valo/DateFields.java Целия файл

@@ -46,16 +46,16 @@ public class DateFields extends VerticalLayout implements View {
addComponent(row);

DateField date = new DateField("Default resolution");
date.setValue(new Date());
setDate(date);
row.addComponent(date);

date = new DateField("Error");
date.setValue(new Date());
setDate(date);
date.setComponentError(new UserError("Fix it, now!"));
row.addComponent(date);

date = new DateField("Error, borderless");
date.setValue(new Date());
setDate(date);
date.setComponentError(new UserError("Fix it, now!"));
date.addStyleName("borderless");
row.addComponent(date);
@@ -77,110 +77,120 @@ public class DateFields extends VerticalLayout implements View {
group.addComponent(today);

date = new DateField("Default resolution, explicit size");
date.setValue(new Date());
setDate(date);
row.addComponent(date);
date.setWidth("260px");
date.setHeight("60px");

date = new DateField("Second resolution");
date.setValue(new Date());
setDate(date);
date.setResolution(Resolution.SECOND);
row.addComponent(date);

date = new DateField("Minute resolution");
date.setValue(new Date());
setDate(date);
date.setResolution(Resolution.MINUTE);
row.addComponent(date);

date = new DateField("Hour resolution");
date.setValue(new Date());
setDate(date);
date.setResolution(Resolution.HOUR);
row.addComponent(date);

date = new DateField("Disabled");
date.setValue(new Date());
setDate(date);
date.setResolution(Resolution.HOUR);
date.setEnabled(false);
row.addComponent(date);

date = new DateField("Day resolution");
date.setValue(new Date());
setDate(date);
date.setResolution(Resolution.DAY);
row.addComponent(date);

date = new DateField("Month resolution");
date.setValue(new Date());
setDate(date);
date.setResolution(Resolution.MONTH);
row.addComponent(date);

date = new DateField("Year resolution");
date.setValue(new Date());
setDate(date);
date.setResolution(Resolution.YEAR);
row.addComponent(date);

date = new DateField("Custom color");
date.setValue(new Date());
setDate(date);
date.setResolution(Resolution.DAY);
date.addStyleName("color1");
row.addComponent(date);

date = new DateField("Custom color");
date.setValue(new Date());
setDate(date);
date.setResolution(Resolution.DAY);
date.addStyleName("color2");
row.addComponent(date);

date = new DateField("Custom color");
date.setValue(new Date());
setDate(date);
date.setResolution(Resolution.DAY);
date.addStyleName("color3");
row.addComponent(date);

date = new DateField("Small");
date.setValue(new Date());
setDate(date);
date.setResolution(Resolution.DAY);
date.addStyleName("small");
row.addComponent(date);

date = new DateField("Large");
date.setValue(new Date());
setDate(date);
date.setResolution(Resolution.DAY);
date.addStyleName("large");
row.addComponent(date);

date = new DateField("Borderless");
date.setValue(new Date());
setDate(date);
date.setResolution(Resolution.DAY);
date.addStyleName("borderless");
row.addComponent(date);

date = new DateField("Week numbers");
date.setValue(new Date());
setDate(date);
date.setResolution(Resolution.DAY);
date.setLocale(new Locale("fi", "fi"));
date.setShowISOWeekNumbers(true);
row.addComponent(date);

date = new DateField("US locale");
date.setValue(new Date());
setDate(date);
date.setResolution(Resolution.SECOND);
date.setLocale(new Locale("en", "US"));
row.addComponent(date);

date = new DateField("Custom format");
date.setValue(new Date());
setDate(date);
date.setDateFormat("E dd/MM/yyyy");
row.addComponent(date);

date = new InlineDateField("Date picker");
setDate(date);
row.addComponent(date);

date = new InlineDateField("Date picker with week numbers");
setDate(date);
date.setLocale(new Locale("fi", "fi"));
date.setShowISOWeekNumbers(true);
row.addComponent(date);
}

private void setDate(DateField date) {
if (ValoThemeUI.isTestMode()) {
date.setValue(new Date(2014 - 1900, 5, 7));
} else {
date.setValue(new Date());
}
}

@Override
public void enter(ViewChangeEvent event) {
// TODO Auto-generated method stub

+ 1
- 1
uitest/src/com/vaadin/tests/themes/valo/Forms.java Целия файл

@@ -47,7 +47,7 @@ public class Forms extends VerticalLayout implements View {
setSpacing(true);
setMargin(true);

Label title = new Label("Form");
Label title = new Label("Forms");
title.addStyleName("h1");
addComponent(title);


+ 17
- 9
uitest/src/com/vaadin/tests/themes/valo/Sliders.java Целия файл

@@ -158,11 +158,12 @@ public class Sliders extends VerticalLayout implements View {
// pb2.setValue(0.6f);
row.addComponent(pb2);

ProgressBar pb3 = new ProgressBar();
pb3.setIndeterminate(true);
pb3.setCaption("Indeterminate");
row.addComponent(pb3);

if (!ValoThemeUI.isTestMode()) {
ProgressBar pb3 = new ProgressBar();
pb3.setIndeterminate(true);
pb3.setCaption("Indeterminate");
row.addComponent(pb3);
}
}

float progress = 0;
@@ -196,14 +197,21 @@ public class Sliders extends VerticalLayout implements View {

@Override
public void enter(ViewChangeEvent event) {
getUI().setPollInterval(1000);
update.start();
if (!ValoThemeUI.isTestMode()) {
getUI().setPollInterval(1000);
update.start();
} else {
pb.setValue(0.3f);
pb2.setValue(0.6f);
}
}

@Override
public void detach() {
getUI().setPollInterval(-1);
update.interrupt();
if (!ValoThemeUI.isTestMode()) {
getUI().setPollInterval(-1);
update.interrupt();
}
super.detach();
}


+ 13
- 1
uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java Целия файл

@@ -61,6 +61,8 @@ import com.vaadin.ui.themes.ValoTheme;
@PreserveOnRefresh
public class ValoThemeUI extends UI {

private boolean testMode = false;

private static LinkedHashMap<String, String> themeVariants = new LinkedHashMap<String, String>();
static {
themeVariants.put("tests-valo", "Default");
@@ -77,11 +79,17 @@ public class ValoThemeUI extends UI {
ComponentContainer viewDisplay = root.getContentContainer();
CssLayout menu = new CssLayout();
CssLayout menuItemsLayout = new CssLayout();
{
menu.setId("testMenu");
}
private Navigator navigator;
private LinkedHashMap<String, String> menuItems = new LinkedHashMap<String, String>();

@Override
protected void init(VaadinRequest request) {
if (request.getParameter("test") != null) {
testMode = true;
}
// Show .v-app-loading valo-menu-badge
// try {
// Thread.sleep(2000);
@@ -159,6 +167,10 @@ public class ValoThemeUI extends UI {

}

static boolean isTestMode() {
return ((ValoThemeUI) getCurrent()).testMode;
}

Component buildTestMenu() {
CssLayout menu = new CssLayout();
menu.addStyleName("large-icons");
@@ -398,7 +410,7 @@ public class ValoThemeUI extends UI {
// ((Hierarchical) container).setChildrenAllowed(id, false);
((Hierarchical) container).setParent(id, i);

for (int k = 1; k < 5; k++) {
for (int k = 1; k < 6; k++) {
String id2 = id + " -> " + k;
child = container.addItem(id2);
child.getItemProperty(CAPTION_PROPERTY).setValue(

+ 239
- 0
uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java Целия файл

@@ -0,0 +1,239 @@
/*
* 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.themes.valo;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.CssLayoutElement;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.elements.TreeElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class ValoThemeUITest extends MultiBrowserTest {

@Test
public void labels() throws Exception {
openTestURL("test");
open("Labels");
compareScreen("labels");
}

@Test
public void buttonsLinks() throws Exception {
openTestURL("test");
open("Buttons & Links", "Buttons");
compareScreen("buttonsLinks");
}

@Test
public void textFields() throws Exception {
openTestURL("test");
open("Text Fields <span class=\"valo-menu-badge\">123</span>",
"Text Fields");
compareScreen("textFields");
}

@Test
public void common() throws Exception {
openTestURL("test");
open("Common UI Elements");
compareScreen("common");
}

@Test
public void datefields() throws Exception {
openTestURL("test");
open("Date Fields");
// Note that this can look broken in IE9 because of some browser
// rendering issue... The problem seems to be in the customized
// horizontal layout in the test app
compareScreen("datefields");
}

@Test
public void comboboxes() throws Exception {
openTestURL("test");
open("Combo Boxes");
compareScreen("comboboxes");
}

@Test
public void selects() throws Exception {
openTestURL("test");
open("Selects");
compareScreen("selects");
}

@Test
public void checkboxes() throws Exception {
openTestURL("test");
open("Check Boxes & Option Groups", "Check Boxes");
compareScreen("checkboxes");
}

@Test
public void sliders() throws Exception {
openTestURL("test");
open("Sliders & Progress Bars", "Sliders");
compareScreen("sliders");
}

@Test
public void colorpickers() throws Exception {
openTestURL("test");
open("Color Pickers");
compareScreen("colorpickers");
}

@Test
public void menubars() throws Exception {
openTestURL("test");
open("Menu Bars");
compareScreen("menubars");
}

@Test
public void trees() throws Exception {
openTestURL("test");
open("Trees");
selectTreeNodeByCaption("Quid securi");
compareScreen("trees");
}

private void selectTreeNodeByCaption(String string) {
WebElement e = $(TreeElement.class).first().findElement(
By.xpath("//div[@class='v-tree-node-caption']//span[text()='"
+ string + "']"));
e.click();
}

@Test
public void tables() throws Exception {
openTestURL("test");
open("Tables");
compareScreen("tables");
}

@Test
public void dragging() throws Exception {
openTestURL("test");
open("Drag and Drop", "Dragging Components");
compareScreen("dragging");
}

@Test
public void panels() throws Exception {
openTestURL("test");
open("Panels", "Panels & Layout panels");
compareScreen("panels");
}

@Test
public void splitpanels() throws Exception {
openTestURL("test");
open("Split Panels");
compareScreen("splitpanels");
}

@Test
public void tabs() throws Exception {
openTestURL("test");
open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
compareScreen("tabs");
}

@Test
public void accordions() throws Exception {
openTestURL("test");
open("Accordions");
compareScreen("accordions");
}

@Test
public void popupviews() throws Exception {
openTestURL("test");
open("Popup Views");
scrollTo(500, 0);
compareScreen("popupviews");
}

@Test
public void calendar() throws Exception {
openTestURL("test");
scrollTo(500, 0);
open("Calendar");

compareScreen("calendar");
}

@Test
public void forms() throws Exception {
openTestURL("test");
scrollTo(500, 0);
open("Forms");
compareScreen("forms");
}

private void open(String link) {
open(link, link);
}

private void open(String link, String caption) {
open(link, caption, 10);
}

// FIXME: Remove this once click works properly on IE...
private void open(String link, String caption, int tries) {
if (tries <= 0) {
throw new RuntimeException(
"Tried many times but was not able to click the link...");
}

$(ButtonElement.class).caption(link).first().click();
CssLayoutElement content = wrap(CssLayoutElement.class,
findElement(By.className("valo-content")));
LabelElement captionElem = content.$(LabelElement.class).first();
if (!captionElem.getText().equals(caption)) {
// IE ... why you fail clicks
System.err.println("Extra click needed on '" + link
+ "' on remote " + getDesiredCapabilities() + " "
+ getRemoteControlName());

open(link, caption, tries - 1);
}
}

private void scrollTo(int top, int left) {
CssLayoutElement testMenu = $(CssLayoutElement.class).id("testMenu");

testBenchElement(testMenu).scroll(top);
testBenchElement(testMenu).scrollLeft(left);
}

@Override
protected boolean requireWindowFocusForIE() {
return true;
}

@Override
protected boolean usePersistentHoverForIE() {
return false;
}

}

Loading…
Отказ
Запис