Skip to content

Commit

Permalink
Fixed charts tests to run with correct browser versions
Browse files Browse the repository at this point in the history
vaadin/vaadin-board#61

Flow-component: vaadin-board
  • Loading branch information
rogozinds authored and DiegoCardoso committed Jun 5, 2017
1 parent 1774ba3 commit 144c952
Show file tree
Hide file tree
Showing 20 changed files with 108 additions and 98 deletions.
2 changes: 1 addition & 1 deletion integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<vaadin.widgetset.mode>local</vaadin.widgetset.mode>
<vaadin.board.version>1.0-SNAPSHOT</vaadin.board.version>
<vaadin-testbench.version>5.1-SNAPSHOT</vaadin-testbench.version>
<vaadin-testbench.version>5.0.0</vaadin-testbench.version>
<vaadin-charts.version>4.0.0</vaadin-charts.version>
<vaadin-spreadsheet.version>2.0.1</vaadin-spreadsheet.version>
</properties>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
import com.vaadin.ui.VerticalLayout;

public abstract class AbstractTestCompUI extends AbstractTestUI {
String PX1024 = "setSizeFull";
String PX0512 = (3 * 128) + "px";
public static String FULL_SIZE_BTN = "setSizeFull";
public static String MIDDLE_SIZE_BTN = "700px";
public static String SMALL_SIZE_BTN = "400px";
public static String SWITCH = "switch";
public static String ID_PREFIX = "test-component-";

Expand All @@ -26,26 +27,30 @@ protected void init(VaadinRequest request) {
int i = 0;
for (final Component component : components) {
component.setId(ID_PREFIX + i++);
component.setSizeFull();
}

final Row row = board.addRow(components);
final AbstractOrderedLayout baseLayout = new VerticalLayout();
final Button button1024 = new Button(PX1024,
final Button btnFullSize = new Button(FULL_SIZE_BTN,
(Button.ClickListener) clickEvent
-> UI.getCurrent().setSizeFull());
button1024.setSizeFull();
btnFullSize.setSizeFull();

final Button button0512 = new Button(PX0512,
final Button btnMiddleSize = new Button(MIDDLE_SIZE_BTN,
(Button.ClickListener) clickEvent
-> UI.getCurrent().setWidth((2 * 128), PIXELS));
button0512.setSizeFull();

-> UI.getCurrent().setWidth(700, PIXELS));
btnMiddleSize.setSizeFull();
btnMiddleSize.setId(MIDDLE_SIZE_BTN);
final Button btnSmallSize = new Button(SMALL_SIZE_BTN,
(Button.ClickListener) clickEvent
-> UI.getCurrent().setWidth(400, PIXELS));
btnSmallSize.setSizeFull();
btnSmallSize.setId(SMALL_SIZE_BTN);
final Button buttonSwitch = new Button(SWITCH,
(Button.ClickListener) clickEvent -> row.setCols(components[1],
(row.getCols(components[1]) > 1) ? 1 : 2));
buttonSwitch.setSizeFull();
baseLayout.addComponents(board, button1024, button0512, buttonSwitch);
baseLayout.addComponents(board, btnFullSize,btnMiddleSize, btnSmallSize, buttonSwitch);

setContent(baseLayout);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ public abstract class CompatBasicChartUI extends AbstractTestCompUI {

@Override
protected Component[] createTestedComponents() {
Component[] comps={nextChartInstance(),nextChartInstance(),nextChartInstance()};
Component[] comps={
nextChartInstance(),
nextChartInstance(),
nextChartInstance(),
nextChartInstance()
};
return comps;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.vaadin.addon.charts.Chart;
Expand All @@ -33,12 +28,9 @@
import com.vaadin.addon.charts.model.PlotOptionsColumn;
import com.vaadin.addon.charts.model.PlotOptionsPie;
import com.vaadin.addon.charts.model.PlotOptionsSeries;
import com.vaadin.addon.charts.model.PlotOptionsSolidgauge;
import com.vaadin.addon.charts.model.PlotOptionsSpline;
import com.vaadin.addon.charts.model.RangeSelector;
import com.vaadin.addon.charts.model.Series;
import com.vaadin.addon.charts.model.SeriesTooltip;
import com.vaadin.addon.charts.model.Stop;
import com.vaadin.addon.charts.model.Tooltip;
import com.vaadin.addon.charts.model.VerticalAlign;
import com.vaadin.addon.charts.model.XAxis;
Expand All @@ -48,7 +40,6 @@
import com.vaadin.addon.charts.model.style.SolidColor;
import com.vaadin.addon.charts.model.style.Style;
import com.vaadin.ui.Component;
import com.vaadin.ui.UI;

/**
*
Expand Down Expand Up @@ -280,8 +271,6 @@ protected Component nextChartInstance() {
}
}


//DASH-111
public static class GaugeUI extends CompatBasicChartUI {
@Override
protected Component nextChartInstance() {
Expand Down Expand Up @@ -320,83 +309,14 @@ protected Component nextChartInstance() {
yaxis.getTitle().setY(- 70);
yaxis.setLabels(new Labels());
yaxis.getLabels().setY(16);
Stop stop1 = new Stop(0.1f, SolidColor.GREEN);
Stop stop2 = new Stop(0.5f, SolidColor.YELLOW);
Stop stop3 = new Stop(0.9f, SolidColor.RED);
yaxis.setStops(stop1, stop2, stop3);

PlotOptionsSolidgauge plotOptions = new PlotOptionsSolidgauge();
plotOptions.setTooltip(new SeriesTooltip());
plotOptions.getTooltip().setValueSuffix(" km/h");
DataLabels labels = new DataLabels();
labels.setY(5);
labels.setBorderWidth(0);
labels.setUseHTML(true);
labels.setFormat("<div style=\"text-align:center\"><span style=\"font-size:25px;\">{y}</span><br/>"
+ " <span style=\"font-size:12pxg\">km/h</span></div>");
plotOptions.setDataLabels(labels);
configuration.setPlotOptions(plotOptions);

final ListSeries series = new ListSeries("Speed", 80);
configuration.setSeries(series);

runWhileAttached(chart, new Runnable() {
Random r = new Random(0);

@Override
public void run() {
Integer oldValue = series.getData()[0].intValue();
Integer newValue = (int) (oldValue + (r.nextDouble() - 0.5) * 20.0);
if (newValue > 200) {
newValue = 200;
} else if (newValue < 0) {
newValue = 0;
}
series.updatePoint(0, newValue);
}
}, 3000, 12000);

chart.drawChart(configuration);
return chart;
}

public static void runWhileAttached(final Component component,
final Runnable task, final int interval, final int initialPause) {
// Until reliable push available in our demo servers
UI.getCurrent().setPollInterval(interval);

final Thread thread = new Thread() {
@Override
public void run() {
try {
Thread.sleep(initialPause);
while (component.getUI() != null) {
Future<Void> future = component.getUI().access(task);
future.get();
Thread.sleep(interval);
}
} catch (InterruptedException e) {
} catch (ExecutionException e) {
Logger.getLogger(this.getClass().getName())
.log(Level.WARNING,
"Stopping repeating command due to an exception",
e);
} catch (com.vaadin.ui.UIDetachedException e) {
} catch (Exception e) {
Logger.getLogger(this.getClass().getName())
.log(Level.WARNING,
"Unexpected exception while running scheduled update",
e);
}
Logger.getLogger(this.getClass().getName()).log(Level.INFO,
"Thread stopped");
}

;
};
thread.start();
}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
@RunOnHub("tb3-hub.intra.itmill.com")
public abstract class AbstractParallelTest extends ParallelTest {

@BeforeClass
public static void setUp() throws Exception {
readTestbenchProperties();
}

public Supplier<WebElement> buttonSwitchSupplier = () -> $(ButtonElement.class)
.caption(AbstractTestCompUI.SWITCH).first();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.vaadin.addon.board.testbenchtests;

import com.vaadin.addon.board.testUI.CompatChartComponents;

public class BarIT extends CompatChartsUIIT{
@Override
protected Class<?> getUIClass() {
return CompatChartComponents.BarChartUI.class;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.vaadin.addon.board.testbenchtests;

import java.util.function.Supplier;

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

import com.vaadin.addon.board.testUI.AbstractTestCompUI;
import com.vaadin.testbench.elements.ButtonElement;

/**
*
*/
public abstract class CompatChartsUIIT extends AbstractParallelTest {

//Unfortunatelly we can not used
//Parametrized Runner, because Testbench already uses Parallel Runner
Supplier<WebElement> smallSizeButton = () -> $(ButtonElement.class)
.id(AbstractTestCompUI.SMALL_SIZE_BTN);

@Test
public void testScreenshot() throws Exception {
String chartType= getUIClass().getSimpleName();
compareScreen("initial"+chartType);

$(ButtonElement.class).id(AbstractTestCompUI.MIDDLE_SIZE_BTN).click();
compareScreen("middle"+chartType);

$(ButtonElement.class).id(AbstractTestCompUI.SMALL_SIZE_BTN).click();
compareScreen("small"+chartType);

}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.vaadin.addon.board.testbenchtests;

import org.junit.Ignore;
import org.junit.Test;

import com.vaadin.addon.board.testUI.CompatChartComponents;

public class GaugeIT extends CompatChartsUIIT{
@Override
protected Class<?> getUIClass() {
return CompatChartComponents.GaugeUI.class;
}

@Ignore
@Test
public void testScreenshot() throws Exception{
throw new Exception("Gauge chart is broken");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.vaadin.addon.board.testbenchtests;

import com.vaadin.addon.board.testUI.CompatChartComponents;

public class PieIT extends CompatChartsUIIT{
@Override
protected Class<?> getUIClass() {
return CompatChartComponents.PieChartUI.class;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.vaadin.addon.board.testbenchtests;

import com.vaadin.addon.board.testUI.CompatChartComponents;

public class TimeLineIT extends CompatChartsUIIT{
@Override
protected Class<?> getUIClass() {
return CompatChartComponents.TimeLineUI.class;
}
}
3 changes: 2 additions & 1 deletion vaadin-board-flow-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
<version>1.0-SNAPSHOT</version>
<name>vaadin-board-root</name>
<properties>
<vaadin.version>8.1.0.beta1</vaadin.version>
<!--<vaadin.version>8.1.0.beta1</vaadin.version>-->
<vaadin.version>8.1-SNAPSHOT</vaadin.version>
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
</properties>
<modules>
Expand Down

0 comments on commit 144c952

Please sign in to comment.