From 257d49fc06f152df292704e8ae6c3bc9a5541a8f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Mon, 7 May 2012 13:20:18 +0000 Subject: [PATCH] Prevent setting mainWindow from a TestBase svn changeset:23685/svn branch:6.8 --- .../tests/application/PaintableIdsShouldBeUnique.java | 6 +++--- .../testbench/com/vaadin/tests/components/TestBase.java | 9 +++++++++ .../tests/components/table/ScrollCausesRequestLoop.java | 6 +++--- .../components/table/ScrollDetachSynchronization.java | 6 +++--- .../table/TableClickValueChangeInteraction.java | 6 +++--- .../window/ReplacingComponentsInHandleParameters.java | 6 +++--- .../tests/containers/TableWithFileSystemContainer.java | 6 +++--- .../com/vaadin/tests/layouts/GridLayoutCaptions.java | 6 +++--- .../tests/layouts/GridLayoutExpandRatioModification.java | 8 ++++---- .../layouts/VerticalLayoutExpandRatioModification.java | 8 ++++---- tests/testbench/com/vaadin/tests/tickets/Ticket6002.java | 6 +++--- .../vaadin/tests/validation/RequiredErrorMessage.java | 6 +++--- 12 files changed, 44 insertions(+), 35 deletions(-) diff --git a/tests/testbench/com/vaadin/tests/application/PaintableIdsShouldBeUnique.java b/tests/testbench/com/vaadin/tests/application/PaintableIdsShouldBeUnique.java index 95760c11a8..a7c9fe4a4f 100644 --- a/tests/testbench/com/vaadin/tests/application/PaintableIdsShouldBeUnique.java +++ b/tests/testbench/com/vaadin/tests/application/PaintableIdsShouldBeUnique.java @@ -1,16 +1,16 @@ package com.vaadin.tests.application; import com.vaadin.terminal.ExternalResource; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.Window; -public class PaintableIdsShouldBeUnique extends TestBase { +public class PaintableIdsShouldBeUnique extends AbstractTestCase { @Override - protected void setup() { + public void init() { setMainWindow(new MyWindow()); } diff --git a/tests/testbench/com/vaadin/tests/components/TestBase.java b/tests/testbench/com/vaadin/tests/components/TestBase.java index c7380d3d7c..4d34fb2c8d 100644 --- a/tests/testbench/com/vaadin/tests/components/TestBase.java +++ b/tests/testbench/com/vaadin/tests/components/TestBase.java @@ -24,6 +24,15 @@ public abstract class TestBase extends AbstractTestCase { setup(); } + @Override + public void setMainWindow(Window mainWindow) { + if (mainWindow != window) { + throw new IllegalStateException( + "You should not set your own main window when using TestBase. If you need to use a custom Window as the main window, use AbstractTestCase instead."); + } + super.setMainWindow(mainWindow); + } + private Window window; private VerticalLayout layout; diff --git a/tests/testbench/com/vaadin/tests/components/table/ScrollCausesRequestLoop.java b/tests/testbench/com/vaadin/tests/components/table/ScrollCausesRequestLoop.java index 1916dcd0d7..b4c46a2ca6 100644 --- a/tests/testbench/com/vaadin/tests/components/table/ScrollCausesRequestLoop.java +++ b/tests/testbench/com/vaadin/tests/components/table/ScrollCausesRequestLoop.java @@ -4,16 +4,16 @@ import java.util.ArrayList; import java.util.List; import com.vaadin.data.util.BeanItemContainer; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.tests.util.Person; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Table; import com.vaadin.ui.Window; -public class ScrollCausesRequestLoop extends TestBase { +public class ScrollCausesRequestLoop extends AbstractTestCase { @Override - protected void setup() { + public void init() { setMainWindow(new Window("", new TestView())); } diff --git a/tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java b/tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java index fe99cfaf2a..07a2974052 100644 --- a/tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java +++ b/tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java @@ -1,6 +1,6 @@ package com.vaadin.tests.components.table; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; @@ -9,10 +9,10 @@ import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -public class ScrollDetachSynchronization extends TestBase { +public class ScrollDetachSynchronization extends AbstractTestCase { @Override - public void setup() { + public void init() { Window mainWindow = new Window("Synctest Application"); mainWindow.setContent(buildLayout()); setMainWindow(mainWindow); diff --git a/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java b/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java index 47216033e9..63c6c753ca 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java +++ b/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java @@ -4,7 +4,7 @@ import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.event.ItemClickEvent; import com.vaadin.event.ItemClickEvent.ItemClickListener; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Component; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; @@ -13,12 +13,12 @@ import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -public class TableClickValueChangeInteraction extends TestBase { +public class TableClickValueChangeInteraction extends AbstractTestCase { final Window mainWindow = new Window(); @Override - public void setup() { + public void init() { setMainWindow(mainWindow); GridLayout layout = new GridLayout(4, 4); diff --git a/tests/testbench/com/vaadin/tests/components/window/ReplacingComponentsInHandleParameters.java b/tests/testbench/com/vaadin/tests/components/window/ReplacingComponentsInHandleParameters.java index d6fe10601f..1f87c3c563 100644 --- a/tests/testbench/com/vaadin/tests/components/window/ReplacingComponentsInHandleParameters.java +++ b/tests/testbench/com/vaadin/tests/components/window/ReplacingComponentsInHandleParameters.java @@ -2,14 +2,14 @@ package com.vaadin.tests.components.window; import java.util.Map; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.Window; -public class ReplacingComponentsInHandleParameters extends TestBase { +public class ReplacingComponentsInHandleParameters extends AbstractTestCase { @Override protected String getDescription() { @@ -22,7 +22,7 @@ public class ReplacingComponentsInHandleParameters extends TestBase { } @Override - protected void setup() { + public void init() { final ClickListener clickListener = new ClickListener() { public void buttonClick(ClickEvent event) { event.getButton().setCaption("Clicked!"); diff --git a/tests/testbench/com/vaadin/tests/containers/TableWithFileSystemContainer.java b/tests/testbench/com/vaadin/tests/containers/TableWithFileSystemContainer.java index 20567e70af..bedb2a735e 100644 --- a/tests/testbench/com/vaadin/tests/containers/TableWithFileSystemContainer.java +++ b/tests/testbench/com/vaadin/tests/containers/TableWithFileSystemContainer.java @@ -3,16 +3,16 @@ package com.vaadin.tests.containers; import java.io.File; import com.vaadin.data.util.FilesystemContainer; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Table; import com.vaadin.ui.Window; -public class TableWithFileSystemContainer extends TestBase { +public class TableWithFileSystemContainer extends AbstractTestCase { private String testPath = "C:/temp/img"; @Override - public void setup() { + public void init() { setMainWindow(new Window("")); Table table = new Table("Documents", new FilesystemContainer(new File( testPath))); diff --git a/tests/testbench/com/vaadin/tests/layouts/GridLayoutCaptions.java b/tests/testbench/com/vaadin/tests/layouts/GridLayoutCaptions.java index 08df953e66..d851e9326f 100644 --- a/tests/testbench/com/vaadin/tests/layouts/GridLayoutCaptions.java +++ b/tests/testbench/com/vaadin/tests/layouts/GridLayoutCaptions.java @@ -3,7 +3,7 @@ package com.vaadin.tests.layouts; import com.vaadin.data.Item; import com.vaadin.data.Validator; import com.vaadin.data.util.BeanItem; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; @@ -18,7 +18,7 @@ import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -public class GridLayoutCaptions extends TestBase { +public class GridLayoutCaptions extends AbstractTestCase { class CustomForm extends Form { private com.vaadin.ui.GridLayout layout; @@ -173,7 +173,7 @@ public class GridLayoutCaptions extends TestBase { } @Override - protected void setup() { + public void init() { Window mainWindow = new Window("Formlayoutcaptionboom Application"); Label label = new Label("Hello Vaadin user"); mainWindow.addComponent(label); diff --git a/tests/testbench/com/vaadin/tests/layouts/GridLayoutExpandRatioModification.java b/tests/testbench/com/vaadin/tests/layouts/GridLayoutExpandRatioModification.java index e9d206009a..fa44345dfe 100644 --- a/tests/testbench/com/vaadin/tests/layouts/GridLayoutExpandRatioModification.java +++ b/tests/testbench/com/vaadin/tests/layouts/GridLayoutExpandRatioModification.java @@ -1,6 +1,6 @@ package com.vaadin.tests.layouts; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; @@ -10,8 +10,8 @@ import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -public class GridLayoutExpandRatioModification extends TestBase implements - ClickListener { +public class GridLayoutExpandRatioModification extends AbstractTestCase + implements ClickListener { private boolean isVisible = false; private GridLayout mainLayout; @@ -20,7 +20,7 @@ public class GridLayoutExpandRatioModification extends TestBase implements private Button button; @Override - public void setup() { + public void init() { Window main = new Window("The Main Window"); mainLayout = new GridLayout(3, 3); main.setContent(mainLayout); diff --git a/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java b/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java index e2c02a629b..5b1c7a5888 100644 --- a/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java +++ b/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java @@ -1,6 +1,6 @@ package com.vaadin.tests.layouts; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; @@ -9,8 +9,8 @@ import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -public class VerticalLayoutExpandRatioModification extends TestBase implements - ClickListener { +public class VerticalLayoutExpandRatioModification extends AbstractTestCase + implements ClickListener { private boolean isVisible = false; private VerticalLayout mainLayout; @@ -19,7 +19,7 @@ public class VerticalLayoutExpandRatioModification extends TestBase implements private Button button; @Override - public void setup() { + public void init() { Window main = new Window("The Main Window"); mainLayout = new VerticalLayout(); main.setContent(mainLayout); diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket6002.java b/tests/testbench/com/vaadin/tests/tickets/Ticket6002.java index bd6a8e2b7c..ad3b01ae78 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket6002.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket6002.java @@ -3,16 +3,16 @@ package com.vaadin.tests.tickets; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.util.ObjectProperty; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Label; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -public class Ticket6002 extends TestBase { +public class Ticket6002 extends AbstractTestCase { @Override - public void setup() { + public void init() { Window main = new Window("The Main Window"); setMainWindow(main); diff --git a/tests/testbench/com/vaadin/tests/validation/RequiredErrorMessage.java b/tests/testbench/com/vaadin/tests/validation/RequiredErrorMessage.java index 7f5048bd80..81c737cd17 100644 --- a/tests/testbench/com/vaadin/tests/validation/RequiredErrorMessage.java +++ b/tests/testbench/com/vaadin/tests/validation/RequiredErrorMessage.java @@ -1,12 +1,12 @@ package com.vaadin.tests.validation; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Form; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -public class RequiredErrorMessage extends TestBase { +public class RequiredErrorMessage extends AbstractTestCase { @Override protected Integer getTicketNumber() { @@ -19,7 +19,7 @@ public class RequiredErrorMessage extends TestBase { } @Override - public void setup() { + public void init() { final Window main = new Window(getClass().getName()); setMainWindow(main); -- 2.39.5