]> source.dussan.org Git - vaadin-framework.git/commitdiff
Converted TB2 push tests to TB3 (#12580)
authorArtur Signell <artur@vaadin.com>
Mon, 16 Sep 2013 11:44:43 +0000 (14:44 +0300)
committerVaadin Code Review <review@vaadin.com>
Wed, 25 Sep 2013 11:22:28 +0000 (11:22 +0000)
Change-Id: Ifd6286aee75946eb47c39886c08473a5a0c10545

26 files changed:
uitest/src/com/vaadin/tests/components/ui/UIAccess.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/ui/UiAccess.java [deleted file]
uitest/src/com/vaadin/tests/components/ui/UiAccessPush.html [deleted file]
uitest/src/com/vaadin/tests/push/BarInUIDL.html [deleted file]
uitest/src/com/vaadin/tests/push/BarInUIDL.java
uitest/src/com/vaadin/tests/push/BasicPush.html [deleted file]
uitest/src/com/vaadin/tests/push/BasicPush.java
uitest/src/com/vaadin/tests/push/BasicPushStreaming.java
uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java
uitest/src/com/vaadin/tests/push/PushConfiguration.html [deleted file]
uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
uitest/src/com/vaadin/tests/push/PushFromInit.html [deleted file]
uitest/src/com/vaadin/tests/push/PushFromInit.java
uitest/src/com/vaadin/tests/push/PushReattachedComponent.html [deleted file]
uitest/src/com/vaadin/tests/push/PushReattachedComponent.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/push/PushTransportAnnotation.html [deleted file]
uitest/src/com/vaadin/tests/push/StreamingPush.html [deleted file]
uitest/src/com/vaadin/tests/push/TogglePush.html [deleted file]
uitest/src/com/vaadin/tests/push/TogglePush.java
uitest/src/com/vaadin/tests/push/TogglePushInInit.html [deleted file]
uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.html [deleted file]
uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java
uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
uitest/src/com/vaadin/tests/tb3/TB3Runner.java
uitest/src/com/vaadin/tests/tb3/WebsocketTest.java [new file with mode: 0644]

diff --git a/uitest/src/com/vaadin/tests/components/ui/UIAccess.java b/uitest/src/com/vaadin/tests/components/ui/UIAccess.java
new file mode 100644 (file)
index 0000000..057dcaa
--- /dev/null
@@ -0,0 +1,392 @@
+/*
+ * Copyright 2000-2013 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.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinService;
+import com.vaadin.server.VaadinSession;
+import com.vaadin.shared.communication.PushMode;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.UI;
+import com.vaadin.util.CurrentInstance;
+
+public class UIAccess extends AbstractTestUIWithLog {
+
+    public static class UIAccessTest extends MultiBrowserTest {
+        @Override
+        protected boolean isPushEnabled() {
+            return true;
+        }
+
+        @Test
+        public void testThreadLocals() {
+            getCurrentInstanceWhenPushingButton().click();
+            waitUntil(ExpectedConditions.textToBePresentInElement(
+                    vaadinLocatorById("Log_row_0"), "1."));
+            Assert.assertEquals(
+                    "0. Current UI matches in beforeResponse? true",
+                    vaadinElementById("Log_row_1").getText());
+            Assert.assertEquals(
+                    "1. Current session matches in beforeResponse? true",
+                    vaadinElementById("Log_row_0").getText());
+
+        }
+
+        private WebElement getCurrentInstanceWhenPushingButton() {
+            return vaadinElement("/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[7]/VButton[0]");
+        }
+    }
+
+    private volatile boolean checkCurrentInstancesBeforeResponse = false;
+
+    private Future<Void> checkFromBeforeClientResponse;
+
+    private class CurrentInstanceTestType {
+        private String value;
+
+        public CurrentInstanceTestType(String value) {
+            this.value = value;
+        }
+
+        @Override
+        public String toString() {
+            return value;
+        }
+    }
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        addComponent(new Button("Access from UI thread",
+                new Button.ClickListener() {
+
+                    @Override
+                    public void buttonClick(ClickEvent event) {
+                        log.clear();
+                        // Ensure beforeClientResponse is invoked
+                        markAsDirty();
+                        checkFromBeforeClientResponse = access(new Runnable() {
+                            @Override
+                            public void run() {
+                                log("Access from UI thread is run");
+                            }
+                        });
+                        log("Access from UI thread future is done? "
+                                + checkFromBeforeClientResponse.isDone());
+                    }
+                }));
+        addComponent(new Button("Access from background thread",
+                new Button.ClickListener() {
+                    @Override
+                    public void buttonClick(ClickEvent event) {
+                        log.clear();
+                        final CountDownLatch latch = new CountDownLatch(1);
+
+                        new Thread() {
+                            @Override
+                            public void run() {
+                                final boolean threadHasCurrentResponse = VaadinService
+                                        .getCurrentResponse() != null;
+                                // session is locked by request thread at this
+                                // point
+                                final Future<Void> initialFuture = access(new Runnable() {
+                                    @Override
+                                    public void run() {
+                                        log("Initial background message");
+                                        log("Thread has current response? "
+                                                + threadHasCurrentResponse);
+                                    }
+                                });
+
+                                // Let request thread continue
+                                latch.countDown();
+
+                                // Wait until thread can be locked
+                                while (!getSession().getLockInstance()
+                                        .tryLock()) {
+                                    try {
+                                        Thread.sleep(100);
+                                    } catch (InterruptedException e) {
+                                        throw new RuntimeException(e);
+                                    }
+                                }
+                                try {
+                                    log("Thread got lock, inital future done? "
+                                            + initialFuture.isDone());
+                                    setPollInterval(-1);
+                                } finally {
+                                    getSession().unlock();
+                                }
+                            }
+                        }.start();
+
+                        // Wait for thread to do initialize before continuing
+                        try {
+                            latch.await();
+                        } catch (InterruptedException e) {
+                            throw new RuntimeException(e);
+                        }
+
+                        setPollInterval(3000);
+                    }
+                }));
+        addComponent(new Button("Access throwing exception",
+                new Button.ClickListener() {
+                    @Override
+                    public void buttonClick(ClickEvent event) {
+                        log.clear();
+                        final Future<Void> firstFuture = access(new Runnable() {
+                            @Override
+                            public void run() {
+                                log("Throwing exception in access");
+                                throw new RuntimeException(
+                                        "Catch me if you can");
+                            }
+                        });
+                        access(new Runnable() {
+                            @Override
+                            public void run() {
+                                log("firstFuture is done? "
+                                        + firstFuture.isDone());
+                                try {
+                                    firstFuture.get();
+                                    log("Should not get here");
+                                } catch (InterruptedException e) {
+                                    throw new RuntimeException(e);
+                                } catch (ExecutionException e) {
+                                    log("Got exception from firstFuture: "
+                                            + e.getMessage());
+                                }
+                            }
+                        });
+                    }
+                }));
+        addComponent(new Button("Cancel future before started",
+                new Button.ClickListener() {
+                    @Override
+                    public void buttonClick(ClickEvent event) {
+                        log.clear();
+                        Future<Void> future = access(new Runnable() {
+                            @Override
+                            public void run() {
+                                log("Should not get here");
+                            }
+                        });
+                        future.cancel(false);
+                        log("future was cancled, should not start");
+                    }
+                }));
+        addComponent(new Button("Cancel running future",
+                new Button.ClickListener() {
+                    @Override
+                    public void buttonClick(ClickEvent event) {
+                        log.clear();
+                        final ReentrantLock interruptLock = new ReentrantLock();
+
+                        final Future<Void> future = access(new Runnable() {
+                            @Override
+                            public void run() {
+                                log("Waiting for thread to start");
+                                while (!interruptLock.isLocked()) {
+                                    try {
+                                        Thread.sleep(100);
+                                    } catch (InterruptedException e) {
+                                        log("Premature interruption");
+                                        throw new RuntimeException(e);
+                                    }
+                                }
+
+                                log("Thread started, waiting for interruption");
+                                try {
+                                    interruptLock.lockInterruptibly();
+                                } catch (InterruptedException e) {
+                                    log("I was interrupted");
+                                }
+                            }
+                        });
+
+                        new Thread() {
+                            @Override
+                            public void run() {
+                                interruptLock.lock();
+                                // Wait until UI thread has started waiting for
+                                // the lock
+                                while (!interruptLock.hasQueuedThreads()) {
+                                    try {
+                                        Thread.sleep(100);
+                                    } catch (InterruptedException e) {
+                                        throw new RuntimeException(e);
+                                    }
+                                }
+
+                                future.cancel(true);
+                            }
+                        }.start();
+                    }
+                }));
+        addComponent(new Button("CurrentInstance accessSynchronously values",
+                new Button.ClickListener() {
+                    @Override
+                    public void buttonClick(ClickEvent event) {
+                        log.clear();
+                        // accessSynchronously should maintain values
+                        CurrentInstance.set(CurrentInstanceTestType.class,
+                                new CurrentInstanceTestType(
+                                        "Set before accessSynchronosly"));
+                        accessSynchronously(new Runnable() {
+                            @Override
+                            public void run() {
+                                log.log("accessSynchronously has request? "
+                                        + (VaadinService.getCurrentRequest() != null));
+                                log.log("Test value in accessSynchronously: "
+                                        + CurrentInstance
+                                                .get(CurrentInstanceTestType.class));
+                                CurrentInstance.set(
+                                        CurrentInstanceTestType.class,
+                                        new CurrentInstanceTestType(
+                                                "Set in accessSynchronosly"));
+                            }
+                        });
+                        log.log("has request after accessSynchronously? "
+                                + (VaadinService.getCurrentRequest() != null));
+                        log("Test value after accessSynchornously: "
+                                + CurrentInstance
+                                        .get(CurrentInstanceTestType.class));
+                    }
+                }));
+        addComponent(new Button("CurrentInstance access values",
+                new Button.ClickListener() {
+                    @Override
+                    public void buttonClick(ClickEvent event) {
+                        log.clear();
+                        // accessSynchronously should maintain values
+                        CurrentInstance
+                                .setInheritable(CurrentInstanceTestType.class,
+                                        new CurrentInstanceTestType(
+                                                "Set before access"));
+                        access(new Runnable() {
+                            @Override
+                            public void run() {
+                                log.log("access has request? "
+                                        + (VaadinService.getCurrentRequest() != null));
+                                log.log("Test value in access: "
+                                        + CurrentInstance
+                                                .get(CurrentInstanceTestType.class));
+                                CurrentInstance.setInheritable(
+                                        CurrentInstanceTestType.class,
+                                        new CurrentInstanceTestType(
+                                                "Set in access"));
+                            }
+                        });
+                        CurrentInstance.setInheritable(
+                                CurrentInstanceTestType.class,
+                                new CurrentInstanceTestType(
+                                        "Set before run pending"));
+
+                        getSession().getService().runPendingAccessTasks(
+                                getSession());
+
+                        log.log("has request after access? "
+                                + (VaadinService.getCurrentRequest() != null));
+                        log("Test value after access: "
+                                + CurrentInstance
+                                        .get(CurrentInstanceTestType.class));
+                    }
+                }));
+
+        addComponent(new Button("CurrentInstance when pushing",
+                new Button.ClickListener() {
+                    @Override
+                    public void buttonClick(ClickEvent event) {
+                        log.clear();
+                        if (getPushConfiguration().getPushMode() != PushMode.AUTOMATIC) {
+                            log("Can only test with automatic push enabled");
+                            return;
+                        }
+
+                        final VaadinSession session = getSession();
+                        new Thread() {
+                            @Override
+                            public void run() {
+                                // Pretend this isn't a Vaadin thread
+                                CurrentInstance.clearAll();
+
+                                /*
+                                 * Get explicit lock to ensure the (implicit)
+                                 * push does not happen during normal request
+                                 * handling.
+                                 */
+                                session.lock();
+                                try {
+                                    access(new Runnable() {
+                                        @Override
+                                        public void run() {
+                                            checkCurrentInstancesBeforeResponse = true;
+                                            // Trigger beforeClientResponse
+                                            markAsDirty();
+                                        }
+                                    });
+                                } finally {
+                                    session.unlock();
+                                }
+                            }
+                        }.start();
+                    }
+                }));
+    }
+
+    @Override
+    public void beforeClientResponse(boolean initial) {
+        if (checkFromBeforeClientResponse != null) {
+            log("beforeClientResponse future is done? "
+                    + checkFromBeforeClientResponse.isDone());
+            checkFromBeforeClientResponse = null;
+        }
+        if (checkCurrentInstancesBeforeResponse) {
+            UI currentUI = UI.getCurrent();
+            VaadinSession currentSession = VaadinSession.getCurrent();
+
+            log("Current UI matches in beforeResponse? " + (currentUI == this));
+            log("Current session matches in beforeResponse? "
+                    + (currentSession == getSession()));
+            checkCurrentInstancesBeforeResponse = false;
+        }
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "Test for various ways of using UI.access";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return Integer.valueOf(11897);
+    }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/ui/UiAccess.java b/uitest/src/com/vaadin/tests/components/ui/UiAccess.java
deleted file mode 100644 (file)
index 09f2fd8..0000000
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright 2000-2013 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.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.locks.ReentrantLock;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.server.VaadinService;
-import com.vaadin.server.VaadinSession;
-import com.vaadin.shared.communication.PushMode;
-import com.vaadin.tests.components.AbstractTestUIWithLog;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.UI;
-import com.vaadin.util.CurrentInstance;
-
-public class UiAccess extends AbstractTestUIWithLog {
-
-    private volatile boolean checkCurrentInstancesBeforeResponse = false;
-
-    private Future<Void> checkFromBeforeClientResponse;
-
-    private class CurrentInstanceTestType {
-        private String value;
-
-        public CurrentInstanceTestType(String value) {
-            this.value = value;
-        }
-
-        @Override
-        public String toString() {
-            return value;
-        }
-    }
-
-    @Override
-    protected void setup(VaadinRequest request) {
-        addComponent(new Button("Access from UI thread",
-                new Button.ClickListener() {
-
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        log.clear();
-                        // Ensure beforeClientResponse is invoked
-                        markAsDirty();
-                        checkFromBeforeClientResponse = access(new Runnable() {
-                            @Override
-                            public void run() {
-                                log("Access from UI thread is run");
-                            }
-                        });
-                        log("Access from UI thread future is done? "
-                                + checkFromBeforeClientResponse.isDone());
-                    }
-                }));
-        addComponent(new Button("Access from background thread",
-                new Button.ClickListener() {
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        log.clear();
-                        final CountDownLatch latch = new CountDownLatch(1);
-
-                        new Thread() {
-                            @Override
-                            public void run() {
-                                final boolean threadHasCurrentResponse = VaadinService
-                                        .getCurrentResponse() != null;
-                                // session is locked by request thread at this
-                                // point
-                                final Future<Void> initialFuture = access(new Runnable() {
-                                    @Override
-                                    public void run() {
-                                        log("Initial background message");
-                                        log("Thread has current response? "
-                                                + threadHasCurrentResponse);
-                                    }
-                                });
-
-                                // Let request thread continue
-                                latch.countDown();
-
-                                // Wait until thread can be locked
-                                while (!getSession().getLockInstance()
-                                        .tryLock()) {
-                                    try {
-                                        Thread.sleep(100);
-                                    } catch (InterruptedException e) {
-                                        throw new RuntimeException(e);
-                                    }
-                                }
-                                try {
-                                    log("Thread got lock, inital future done? "
-                                            + initialFuture.isDone());
-                                    setPollInterval(-1);
-                                } finally {
-                                    getSession().unlock();
-                                }
-                            }
-                        }.start();
-
-                        // Wait for thread to do initialize before continuing
-                        try {
-                            latch.await();
-                        } catch (InterruptedException e) {
-                            throw new RuntimeException(e);
-                        }
-
-                        setPollInterval(3000);
-                    }
-                }));
-        addComponent(new Button("Access throwing exception",
-                new Button.ClickListener() {
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        log.clear();
-                        final Future<Void> firstFuture = access(new Runnable() {
-                            @Override
-                            public void run() {
-                                log("Throwing exception in access");
-                                throw new RuntimeException(
-                                        "Catch me if you can");
-                            }
-                        });
-                        access(new Runnable() {
-                            @Override
-                            public void run() {
-                                log("firstFuture is done? "
-                                        + firstFuture.isDone());
-                                try {
-                                    firstFuture.get();
-                                    log("Should not get here");
-                                } catch (InterruptedException e) {
-                                    throw new RuntimeException(e);
-                                } catch (ExecutionException e) {
-                                    log("Got exception from firstFuture: "
-                                            + e.getMessage());
-                                }
-                            }
-                        });
-                    }
-                }));
-        addComponent(new Button("Cancel future before started",
-                new Button.ClickListener() {
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        log.clear();
-                        Future<Void> future = access(new Runnable() {
-                            @Override
-                            public void run() {
-                                log("Should not get here");
-                            }
-                        });
-                        future.cancel(false);
-                        log("future was cancled, should not start");
-                    }
-                }));
-        addComponent(new Button("Cancel running future",
-                new Button.ClickListener() {
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        log.clear();
-                        final ReentrantLock interruptLock = new ReentrantLock();
-
-                        final Future<Void> future = access(new Runnable() {
-                            @Override
-                            public void run() {
-                                log("Waiting for thread to start");
-                                while (!interruptLock.isLocked()) {
-                                    try {
-                                        Thread.sleep(100);
-                                    } catch (InterruptedException e) {
-                                        log("Premature interruption");
-                                        throw new RuntimeException(e);
-                                    }
-                                }
-
-                                log("Thread started, waiting for interruption");
-                                try {
-                                    interruptLock.lockInterruptibly();
-                                } catch (InterruptedException e) {
-                                    log("I was interrupted");
-                                }
-                            }
-                        });
-
-                        new Thread() {
-                            @Override
-                            public void run() {
-                                interruptLock.lock();
-                                // Wait until UI thread has started waiting for
-                                // the lock
-                                while (!interruptLock.hasQueuedThreads()) {
-                                    try {
-                                        Thread.sleep(100);
-                                    } catch (InterruptedException e) {
-                                        throw new RuntimeException(e);
-                                    }
-                                }
-
-                                future.cancel(true);
-                            }
-                        }.start();
-                    }
-                }));
-        addComponent(new Button("CurrentInstance accessSynchronously values",
-                new Button.ClickListener() {
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        log.clear();
-                        // accessSynchronously should maintain values
-                        CurrentInstance.set(CurrentInstanceTestType.class,
-                                new CurrentInstanceTestType(
-                                        "Set before accessSynchronosly"));
-                        accessSynchronously(new Runnable() {
-                            @Override
-                            public void run() {
-                                log.log("accessSynchronously has request? "
-                                        + (VaadinService.getCurrentRequest() != null));
-                                log.log("Test value in accessSynchronously: "
-                                        + CurrentInstance
-                                                .get(CurrentInstanceTestType.class));
-                                CurrentInstance.set(
-                                        CurrentInstanceTestType.class,
-                                        new CurrentInstanceTestType(
-                                                "Set in accessSynchronosly"));
-                            }
-                        });
-                        log.log("has request after accessSynchronously? "
-                                + (VaadinService.getCurrentRequest() != null));
-                        log("Test value after accessSynchornously: "
-                                + CurrentInstance
-                                        .get(CurrentInstanceTestType.class));
-                    }
-                }));
-        addComponent(new Button("CurrentInstance access values",
-                new Button.ClickListener() {
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        log.clear();
-                        // accessSynchronously should maintain values
-                        CurrentInstance
-                                .setInheritable(CurrentInstanceTestType.class,
-                                        new CurrentInstanceTestType(
-                                                "Set before access"));
-                        access(new Runnable() {
-                            @Override
-                            public void run() {
-                                log.log("access has request? "
-                                        + (VaadinService.getCurrentRequest() != null));
-                                log.log("Test value in access: "
-                                        + CurrentInstance
-                                                .get(CurrentInstanceTestType.class));
-                                CurrentInstance.setInheritable(
-                                        CurrentInstanceTestType.class,
-                                        new CurrentInstanceTestType(
-                                                "Set in access"));
-                            }
-                        });
-                        CurrentInstance.setInheritable(
-                                CurrentInstanceTestType.class,
-                                new CurrentInstanceTestType(
-                                        "Set before run pending"));
-
-                        getSession().getService().runPendingAccessTasks(
-                                getSession());
-
-                        log.log("has request after access? "
-                                + (VaadinService.getCurrentRequest() != null));
-                        log("Test value after access: "
-                                + CurrentInstance
-                                        .get(CurrentInstanceTestType.class));
-                    }
-                }));
-
-        addComponent(new Button("CurrentInstance when pushing",
-                new Button.ClickListener() {
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        log.clear();
-                        if (getPushConfiguration().getPushMode() != PushMode.AUTOMATIC) {
-                            log("Can only test with automatic push enabled");
-                            return;
-                        }
-
-                        final VaadinSession session = getSession();
-                        new Thread() {
-                            @Override
-                            public void run() {
-                                // Pretend this isn't a Vaadin thread
-                                CurrentInstance.clearAll();
-
-                                /*
-                                 * Get explicit lock to ensure the (implicit)
-                                 * push does not happen during normal request
-                                 * handling.
-                                 */
-                                session.lock();
-                                try {
-                                    access(new Runnable() {
-                                        @Override
-                                        public void run() {
-                                            checkCurrentInstancesBeforeResponse = true;
-                                            // Trigger beforeClientResponse
-                                            markAsDirty();
-                                        }
-                                    });
-                                } finally {
-                                    session.unlock();
-                                }
-                            }
-                        }.start();
-                    }
-                }));
-    }
-
-    @Override
-    public void beforeClientResponse(boolean initial) {
-        if (checkFromBeforeClientResponse != null) {
-            log("beforeClientResponse future is done? "
-                    + checkFromBeforeClientResponse.isDone());
-            checkFromBeforeClientResponse = null;
-        }
-        if (checkCurrentInstancesBeforeResponse) {
-            UI currentUI = UI.getCurrent();
-            VaadinSession currentSession = VaadinSession.getCurrent();
-
-            log("Current UI matches in beforeResponse? " + (currentUI == this));
-            log("Current session matches in beforeResponse? "
-                    + (currentSession == getSession()));
-            checkCurrentInstancesBeforeResponse = false;
-        }
-    }
-
-    @Override
-    protected String getTestDescription() {
-        return "Test for various ways of using UI.access";
-    }
-
-    @Override
-    protected Integer getTicketNumber() {
-        return Integer.valueOf(11897);
-    }
-
-}
diff --git a/uitest/src/com/vaadin/tests/components/ui/UiAccessPush.html b/uitest/src/com/vaadin/tests/components/ui/UiAccessPush.html
deleted file mode 100644 (file)
index bc29534..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="" />
-<title>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
-       <td>open</td>
-       <td>/run/com.vaadin.tests.components.ui.UiAccess?restartApplication&amp;transport=websocket</td>
-       <td></td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[7]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>waitForNotText</td>
-       <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td>
-       <td>exact:1. Current session matches in beforeResponse? true</td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1</td>
-       <td>exact:0. Current UI matches in beforeResponse? true</td>
-</tr>
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/push/BarInUIDL.html b/uitest/src/com/vaadin/tests/push/BarInUIDL.html
deleted file mode 100644 (file)
index 66f0315..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="http://localhost:8888/" />
-<title>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
-       <td>open</td>
-       <td>/run-push/com.vaadin.tests.push.BarInUIDL?restartApplication</td>
-       <td></td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</td>
-       <td>Thank you for clicking | bar</td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VLabel[0]</td>
-       <td>Thank you for clicking | bar</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
index 7e414cc89d6bc15ec89749c43b6dd4626c972066..ef2568bebebe917e318957629aed19e864d773eb 100644 (file)
 
 package com.vaadin.tests.push;
 
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.annotations.Push;
 import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.ui.Transport;
 import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.tb3.MultiBrowserTest;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
 import com.vaadin.ui.Label;
 
+@Push(transport = Transport.STREAMING)
 public class BarInUIDL extends AbstractTestUI {
 
+    public static class BarInUIDLTest extends MultiBrowserTest {
+        @Test
+        public void sendBarInUIDL() {
+            getButton().click();
+            Assert.assertEquals(
+                    "Thank you for clicking | bar",
+                    vaadinElement(
+                            "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]")
+                            .getText());
+            getButton().click();
+            Assert.assertEquals(
+                    "Thank you for clicking | bar",
+                    vaadinElement(
+                            "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VLabel[0]")
+                            .getText());
+        }
+
+        private WebElement getButton() {
+            return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]");
+        }
+    }
+
     /*
      * (non-Javadoc)
      * 
diff --git a/uitest/src/com/vaadin/tests/push/BasicPush.html b/uitest/src/com/vaadin/tests/push/BasicPush.html
deleted file mode 100644 (file)
index 173ec90..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="http://localhost:8888/" />
-<title>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
-       <td>open</td>
-       <td>/run-push/com.vaadin.tests.push.BasicPush?restartApplication&amp;debug</td>
-       <td></td>
-</tr>
-<!--Test client initiated push -->
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</td>
-       <td>0</td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</td>
-       <td>1</td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</td>
-       <td>4</td>
-</tr>
-<!--Test server initiated push-->
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td>
-       <td>0</td>
-</tr>
-<tr>
-       <td>pause</td>
-       <td>3000</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td>
-       <td>1</td>
-</tr>
-<tr>
-       <td>pause</td>
-       <td>3000</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td>
-       <td>2</td>
-</tr>
-</tbody></table>
-</body>
-</html>
index b80d287a1de4e950115da610541c28f5c3cfde3a..1f184863f76e9dc9935052b56915cb1efcc33d76 100644 (file)
+/*
+ * Copyright 2000-2013 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.push;
 
-import java.util.Date;
 import java.util.Timer;
 import java.util.TimerTask;
 
-import com.vaadin.annotations.Widgetset;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.annotations.Push;
 import com.vaadin.data.util.ObjectProperty;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.shared.ui.label.ContentMode;
 import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.tests.widgetset.TestingWidgetSet;
+import com.vaadin.tests.tb3.MultiBrowserTest;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
 import com.vaadin.ui.Label;
 
-@Widgetset(TestingWidgetSet.NAME)
+@Push
 public class BasicPush extends AbstractTestUI {
 
+    public static abstract class BasicPushTest extends MultiBrowserTest {
+
+        @Test
+        public void testPush() {
+            // Test client initiated push
+            Assert.assertEquals(0, getClientCounter());
+            getIncrementButton().click();
+            Assert.assertEquals(
+                    "Client counter not incremented by button click", 1,
+                    getClientCounter());
+            getIncrementButton().click();
+            getIncrementButton().click();
+            getIncrementButton().click();
+            Assert.assertEquals(
+                    "Four clicks should have incremented counter to 4", 4,
+                    getClientCounter());
+
+            // Test server initiated push
+            getServerCounterStartButton().click();
+            try {
+                Assert.assertEquals(0, getServerCounter());
+                sleep(3000);
+                int serverCounter = getServerCounter();
+                if (serverCounter < 1) {
+                    // No push has happened
+                    Assert.fail("No push has occured within 3s");
+                }
+                sleep(3000);
+                if (getServerCounter() <= serverCounter) {
+                    // No push has happened
+                    Assert.fail("Only one push took place within 6s");
+
+                }
+            } finally {
+                // Avoid triggering push assertions
+                getServerCounterStopButton().click();
+            }
+        }
+
+        private int getServerCounter() {
+            return Integer.parseInt(getServerCounterElement().getText());
+        }
+
+        private int getClientCounter() {
+            return Integer.parseInt(getClientCounterElement().getText());
+        }
+
+        private WebElement getServerCounterElement() {
+            return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]");
+        }
+
+        private WebElement getServerCounterStartButton() {
+            return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]");
+        }
+
+        private WebElement getServerCounterStopButton() {
+            return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]");
+        }
+
+        private WebElement getIncrementButton() {
+            return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]");
+        }
+
+        private WebElement getClientCounterElement() {
+            return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]");
+        }
+    }
+
     private ObjectProperty<Integer> counter = new ObjectProperty<Integer>(0);
 
     private ObjectProperty<Integer> counter2 = new ObjectProperty<Integer>(0);
 
     private final Timer timer = new Timer(true);
 
-    private final TimerTask task = new TimerTask() {
-
-        @Override
-        public void run() {
-            access(new Runnable() {
-                @Override
-                public void run() {
-                    counter2.setValue(counter2.getValue() + 1);
-                }
-            });
-        }
-    };
+    private TimerTask task;
 
     @Override
     protected void setup(VaadinRequest request) {
@@ -65,11 +140,37 @@ public class BasicPush extends AbstractTestUI {
         lbl.setCaption("Server counter (updates each 3s by server thread) :");
         addComponent(lbl);
 
-        addComponent(new Button("Reset", new Button.ClickListener() {
+        addComponent(new Button("Start timer", new Button.ClickListener() {
 
             @Override
             public void buttonClick(ClickEvent event) {
                 counter2.setValue(0);
+                if (task != null) {
+                    task.cancel();
+                }
+                task = new TimerTask() {
+
+                    @Override
+                    public void run() {
+                        access(new Runnable() {
+                            @Override
+                            public void run() {
+                                counter2.setValue(counter2.getValue() + 1);
+                            }
+                        });
+                    }
+                };
+                timer.scheduleAtFixedRate(task, 3000, 3000);
+            }
+        }));
+
+        addComponent(new Button("Stop timer", new Button.ClickListener() {
+            @Override
+            public void buttonClick(ClickEvent event) {
+                if (task != null) {
+                    task.cancel();
+                    task = null;
+                }
             }
         }));
     }
@@ -94,7 +195,6 @@ public class BasicPush extends AbstractTestUI {
     @Override
     public void attach() {
         super.attach();
-        timer.scheduleAtFixedRate(task, new Date(), 3000);
     }
 
     @Override
index 37a8afd8194d889e5acc7073c668e6cf4091caea..29534e1f5c0929bdb095a47378f62dd441b2df3c 100644 (file)
@@ -1,12 +1,42 @@
+/*
+ * Copyright 2000-2013 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.push;
 
+import org.junit.Test;
+
 import com.vaadin.annotations.Push;
+import com.vaadin.server.VaadinRequest;
 import com.vaadin.shared.ui.ui.Transport;
 
 @Push(transport = Transport.STREAMING)
 public class BasicPushStreaming extends BasicPush {
     @Override
-    protected void setup(com.vaadin.server.VaadinRequest request) {
-        addComponent(new PushConfigurator(this));
+    public void init(VaadinRequest request) {
+        super.init(request);
+        // Don't use fallback so we can easier detect if streaming fails
+        getPushConfiguration().setFallbackTransport(Transport.STREAMING);
+
     }
+
+    public static class BasicPushStreamingTest extends BasicPushTest {
+        @Override
+        @Test
+        public void testPush() {
+            super.testPush();
+        }
+    }
+
 }
index 6fc27e8974f317c3a816083440b478ef1d4c1094..4765183fca72a894f0345589d45043e564cd0cbd 100644 (file)
@@ -1,8 +1,44 @@
+/*
+ * Copyright 2000-2013 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.push;
 
+import java.util.Collection;
+
+import org.openqa.selenium.remote.DesiredCapabilities;
+
 import com.vaadin.annotations.Push;
+import com.vaadin.server.VaadinRequest;
 import com.vaadin.shared.ui.ui.Transport;
+import com.vaadin.tests.tb3.WebsocketTest;
 
 @Push(transport = Transport.WEBSOCKET)
 public class BasicPushWebsocket extends BasicPush {
+
+    @Override
+    public void init(VaadinRequest request) {
+        super.init(request);
+        // Don't use fallback so we can easier detect if websocket fails
+        getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET);
+    }
+
+    public static class BasicPushWebsocketTest extends BasicPushTest {
+        @Override
+        public Collection<DesiredCapabilities> getBrowsersToTest() {
+            return WebsocketTest.getWebsocketBrowsers();
+        }
+    }
+
 }
diff --git a/uitest/src/com/vaadin/tests/push/PushConfiguration.html b/uitest/src/com/vaadin/tests/push/PushConfiguration.html
deleted file mode 100644 (file)
index c3786b1..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="http://localhost:8888/" />
-<title>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<!--Websocket-->
-<tr>
-       <td>open</td>
-       <td>/run/com.vaadin.tests.push.PushConfigurationTest?debug&amp;restartApplication</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertNotText</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
-       <td>4</td>
-</tr>
-<tr>
-       <td>select</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]</td>
-       <td>label=WEBSOCKET</td>
-</tr>
-<tr>
-       <td>assertNotText</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
-       <td>4</td>
-</tr>
-<tr>
-       <td>select</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td>
-       <td>label=AUTOMATIC</td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]</td>
-       <td>*fallbackTransport: streaming*transport: websocket*</td>
-</tr>
-<tr>
-       <td>assertNotText</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
-       <td>4</td>
-</tr>
-<tr>
-       <td>waitForText</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
-       <td>4</td>
-</tr>
-<!--Use debug console to verify we used the correct transport type-->
-<tr>
-       <td>assertTextPresent</td>
-       <td>Push connection established using websocket</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertTextNotPresent</td>
-       <td>Push connection established using streaming</td>
-       <td>Push connection established using streaming</td>
-</tr>
-<tr>
-       <td>select</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td>
-       <td>label=DISABLED</td>
-</tr>
-<!--Streaming-->
-<tr>
-       <td>open</td>
-       <td>/run/com.vaadin.tests.push.PushConfigurationTest?debug&amp;restartApplication</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertNotText</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
-       <td>4</td>
-</tr>
-<tr>
-       <td>select</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]</td>
-       <td>label=STREAMING</td>
-</tr>
-<tr>
-       <td>assertNotText</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
-       <td>4</td>
-</tr>
-<tr>
-       <td>select</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td>
-       <td>label=AUTOMATIC</td>
-</tr>
-<tr>
-       <td>assertNotText</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
-       <td>4</td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]</td>
-       <td>*fallbackTransport: streaming*transport: streaming*</td>
-</tr>
-<tr>
-       <td>waitForText</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td>
-       <td>4</td>
-</tr>
-<!--Use debug console to verify we used the correct transport type-->
-<tr>
-       <td>assertTextNotPresent</td>
-       <td>Push connection established using websocket</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertTextPresent</td>
-       <td>Push connection established using streaming</td>
-       <td></td>
-</tr>
-<tr>
-       <td>select</td>
-       <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td>
-       <td>label=DISABLED</td>
-</tr>
-</tbody></table>
-</body>
-</html>
index b57e9732cc50475ff482e53f33cd3d0dc0ff6198..f4a537392d7a49f90838285e51c100c83f199d2c 100644 (file)
+/*
+ * Copyright 2000-2013 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.push;
 
 import java.util.Date;
 import java.util.Timer;
 import java.util.TimerTask;
 
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.Select;
+
 import com.vaadin.data.util.ObjectProperty;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.shared.ui.label.ContentMode;
 import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.tb3.WebsocketTest;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
 import com.vaadin.ui.Label;
 
 public class PushConfigurationTest extends AbstractTestUI {
 
+    public static class PushConfigurationWebsocket extends WebsocketTest {
+
+        @Override
+        protected boolean isDebug() {
+            return true;
+        }
+
+        @Test
+        public void testWebsocketAndStreaming() {
+            // Websocket
+            Assert.assertEquals(1, getServerCounter());
+            new Select(getTransportSelect()).selectByVisibleText("WEBSOCKET");
+            new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC");
+            Assert.assertTrue(vaadinElement(
+                    "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]")
+                    .getText()
+                    .matches(
+                            "^[\\s\\S]*fallbackTransport: streaming[\\s\\S]*transport: websocket[\\s\\S]*$"));
+            int counter = getServerCounter();
+
+            for (int second = 0;; second++) {
+                if (second >= 5) {
+                    Assert.fail("timeout");
+                }
+                if (getServerCounter() >= (counter + 2)) {
+                    break;
+                }
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException e) {
+                }
+            }
+
+            // Use debug console to verify we used the correct transport type
+            Assert.assertTrue(driver.getPageSource().contains(
+                    "Push connection established using websocket"));
+            Assert.assertFalse(driver.getPageSource().contains(
+                    "Push connection established using streaming"));
+
+            new Select(getPushModeSelect()).selectByVisibleText("DISABLED");
+
+            // Streaming
+            driver.get(getTestUrl());
+            Assert.assertEquals(1, getServerCounter());
+
+            new Select(getTransportSelect()).selectByVisibleText("STREAMING");
+            new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC");
+            Assert.assertTrue(vaadinElement(
+                    "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]")
+                    .getText()
+                    .matches(
+                            "^[\\s\\S]*fallbackTransport: streaming[\\s\\S]*transport: streaming[\\s\\S]*$"));
+
+            counter = getServerCounter();
+            for (int second = 0;; second++) {
+                if (second >= 5) {
+                    Assert.fail("timeout");
+                }
+                if (getServerCounter() >= (counter + 2)) {
+                    break;
+                }
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException e) {
+                }
+            }
+
+            // Use debug console to verify we used the correct transport type
+            Assert.assertFalse(driver.getPageSource().contains(
+                    "Push connection established using websocket"));
+            Assert.assertTrue(driver.getPageSource().contains(
+                    "Push connection established using streaming"));
+
+        }
+
+        private WebElement getPushModeSelect() {
+            return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]");
+        }
+
+        private WebElement getTransportSelect() {
+            return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]");
+        }
+
+        private int getServerCounter() {
+            return Integer.parseInt(getServerCounterElement().getText());
+        }
+
+        private WebElement getServerCounterElement() {
+            return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]");
+        }
+    }
+
     private ObjectProperty<Integer> counter = new ObjectProperty<Integer>(0);
 
     private ObjectProperty<Integer> counter2 = new ObjectProperty<Integer>(0);
diff --git a/uitest/src/com/vaadin/tests/push/PushFromInit.html b/uitest/src/com/vaadin/tests/push/PushFromInit.html
deleted file mode 100644 (file)
index d009eb3..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="" />
-<title>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
-       <td>open</td>
-       <td>/run-push/com.vaadin.tests.push.PushFromInit?debug&amp;restartApplication</td>
-       <td></td>
-</tr>
-<tr>
-       <td>waitForText</td>
-       <td>vaadin=runpushcomvaadintestspushPushFromInit::PID_SLog_row_1</td>
-       <td>1. Logged in init</td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushPushFromInit::PID_SLog_row_0</td>
-       <td>2. Logged from background thread started in init</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
index 4b442de499e33754a65f17a949489e44ebb05c43..000d5c0bcea792928451393017b2acfb64591d7e 100644 (file)
@@ -1,11 +1,57 @@
+/*
+ * Copyright 2000-2013 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.push;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.tests.tb3.MultiBrowserTest;
 import com.vaadin.ui.Button;
 
 public class PushFromInit extends AbstractTestUIWithLog {
 
+    public static class PushFromInitTB3 extends MultiBrowserTest {
+        @Test
+        public void testPushFromInit() {
+            for (int second = 0;; second++) {
+                if (second >= 30) {
+                    Assert.fail("timeout");
+                }
+                try {
+                    if ("1. Logged in init".equals(vaadinElementById(
+                            "Log_row_1").getText())) {
+                        break;
+                    }
+                } catch (Exception e) {
+                }
+                try {
+                    Thread.sleep(200);
+                } catch (InterruptedException e) {
+                }
+            }
+
+            Assert.assertEquals(
+                    "2. Logged from background thread started in init",
+                    vaadinElementById("Log_row_0").getText());
+
+        }
+    }
+
     @Override
     protected void setup(VaadinRequest request) {
         new Thread() {
diff --git a/uitest/src/com/vaadin/tests/push/PushReattachedComponent.html b/uitest/src/com/vaadin/tests/push/PushReattachedComponent.html
deleted file mode 100644 (file)
index e1f6a5f..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="http://192.168.2.162:8888/" />
-<title>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
-       <td>open</td>
-       <td>/run-push/com.vaadin.tests.components.panel.PanelChangeContents?restartApplication</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
-       <td>stats</td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
-       <td>companies</td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
-       <td>stats</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java b/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java
new file mode 100644 (file)
index 0000000..3593427
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2000-2013 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.push;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.tests.components.panel.PanelChangeContents;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class PushReattachedComponent extends MultiBrowserTest {
+
+    @Override
+    protected boolean isPushEnabled() {
+        return true;
+    }
+
+    @Override
+    protected Class<?> getUIClass() {
+        return PanelChangeContents.class;
+    }
+
+    @Test
+    public void testReattachComponentUsingPush() {
+        Assert.assertEquals(
+                "stats",
+                vaadinElement(
+                        "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+                        .getText());
+        vaadinElement(
+                "/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]")
+                .click();
+        Assert.assertEquals(
+                "companies",
+                vaadinElement(
+                        "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+                        .getText());
+        vaadinElement(
+                "/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]")
+                .click();
+        Assert.assertEquals(
+                "stats",
+                vaadinElement(
+                        "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+                        .getText());
+
+    }
+}
diff --git a/uitest/src/com/vaadin/tests/push/PushTransportAnnotation.html b/uitest/src/com/vaadin/tests/push/PushTransportAnnotation.html
deleted file mode 100644 (file)
index 854dd45..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="http://localhost:8888/" />
-<title>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
-       <td>open</td>
-       <td>/run/com.vaadin.tests.push.BasicPushStreaming?debug&amp;restartApplication</td>
-       <td></td>
-</tr>
-<tr>
-       <td>waitForTextPresent</td>
-       <td>Push connection established using streaming</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertTextNotPresent</td>
-       <td>Push connection established using websocket</td>
-       <td></td>
-</tr>
-<tr>
-       <td>open</td>
-       <td>/run/com.vaadin.tests.push.BasicPushWebsocket?debug&amp;restartApplication</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertTextNotPresent</td>
-       <td>Push connection established using streaming</td>
-       <td></td>
-</tr>
-<tr>
-       <td>waitForTextPresent</td>
-       <td>Push connection established using websocket</td>
-       <td></td>
-</tr>
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/push/StreamingPush.html b/uitest/src/com/vaadin/tests/push/StreamingPush.html
deleted file mode 100644 (file)
index cf94a09..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="http://localhost:8888/" />
-<title>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
-       <td>open</td>
-       <td>/run-push/com.vaadin.tests.push.BasicPush?restartApplication&amp;debug&amp;transport=streaming</td>
-       <td></td>
-</tr>
-<!--Test client initiated push -->
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</td>
-       <td>0</td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</td>
-       <td>1</td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</td>
-       <td>4</td>
-</tr>
-<!--Test server initiated push-->
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td>
-       <td>0</td>
-</tr>
-<tr>
-       <td>pause</td>
-       <td>3000</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td>
-       <td>1</td>
-</tr>
-<tr>
-       <td>pause</td>
-       <td>3000</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td>
-       <td>2</td>
-</tr>
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/push/TogglePush.html b/uitest/src/com/vaadin/tests/push/TogglePush.html
deleted file mode 100644 (file)
index b752d21..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="" />
-<title>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
-       <td>open</td>
-       <td>/run-push/com.vaadin.tests.push.TogglePush?restartApplication</td>
-       <td></td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>pause</td>
-       <td>2000</td>
-       <td></td>
-</tr>
-<!--Push is enabled, so text gets updated-->
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
-       <td>Counter has been updated 1 times</td>
-</tr>
-<tr>
-       <td>mouseClick</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td>
-       <td>61,6</td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>pause</td>
-       <td>2000</td>
-       <td></td>
-</tr>
-<!--Push is disabled, so text is not updated-->
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
-       <td>Counter has been updated 1 times</td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<!--Direct update is visible, and includes previous update-->
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
-       <td>Counter has been updated 3 times</td>
-</tr>
-<tr>
-       <td>mouseClick</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td>
-       <td>61,3</td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>pause</td>
-       <td>2000</td>
-       <td></td>
-</tr>
-<!--Push is enabled again, so text gets updated-->
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
-       <td>Counter has been updated 4 times</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
index c0bdc54ee00a2add8b2deb7b390aa6edf328ac36..f59ef83fe72930645d82ee49d7eb59bf897e76ff 100644 (file)
+/*
+ * Copyright 2000-2013 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.push;
 
 import java.util.Timer;
 import java.util.TimerTask;
 
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
 import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.shared.communication.PushMode;
 import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.tests.tb3.MultiBrowserTest;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
 import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.Label;
 
 public class TogglePush extends AbstractTestUI {
+    public static class TogglePushInInitTB3 extends MultiBrowserTest {
+        @Override
+        protected boolean isPushEnabled() {
+            return true;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see com.vaadin.tests.tb3.AbstractTB3Test#getTestUrl()
+         */
+        @Override
+        protected String getTestUrl() {
+            return null;
+        }
+
+        @Test
+        public void togglePushInInit() {
+            String baseUrl = getBaseURL();
+            if (baseUrl.endsWith("/")) {
+                baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
+            }
+
+            String url = baseUrl + getDeploymentPath();
+
+            // Open with push disabled
+            driver.get(addParameter(url, "push=disabled"));
+
+            Assert.assertFalse(getPushToggle().isSelected());
+
+            getDelayedCounterUpdateButton().click();
+            sleep(2000);
+            Assert.assertEquals("Counter has been updated 0 times",
+                    getCounterText());
+
+            // Open with push enabled
+            driver.get(addParameter(url, "push=enabled"));
+            Assert.assertTrue(getPushToggle().isSelected());
+
+            getDelayedCounterUpdateButton().click();
+            sleep(2000);
+            Assert.assertEquals("Counter has been updated 1 times",
+                    getCounterText());
+
+        }
+
+        /**
+         * @since
+         * @param url
+         * @param string
+         * @return
+         */
+        private String addParameter(String url, String queryParameter) {
+            if (url.contains("?")) {
+                return url + "&" + queryParameter;
+            } else {
+                return url + "?" + queryParameter;
+            }
+        }
+
+        private String getCounterText() {
+            return vaadinElement(
+                    "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+                    .getText();
+        }
+
+        private WebElement getPushToggle() {
+            return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]");
+        }
+
+        private WebElement getDelayedCounterUpdateButton() {
+            return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]");
+        }
+
+    }
+
+    public static class TogglePushTB3 extends MultiBrowserTest {
+
+        @Override
+        protected boolean isPushEnabled() {
+            return true;
+        }
+
+        @Test
+        public void togglePush() {
+            getDelayedCounterUpdateButton().click();
+            sleep(2000);
+
+            // Push is enabled, so text gets updated
+            Assert.assertEquals("Counter has been updated 1 times",
+                    getCounterText());
+
+            // Disable push
+            getPushToggle().click();
+            getDelayedCounterUpdateButton().click();
+            sleep(2000);
+            // Push is disabled, so text is not updated
+            Assert.assertEquals("Counter has been updated 1 times",
+                    getCounterText());
+
+            getDirectCounterUpdateButton().click();
+            // Direct update is visible, and includes previous update
+            Assert.assertEquals("Counter has been updated 3 times",
+                    getCounterText());
+
+            // Re-enable push
+            getPushToggle().click();
+            getDelayedCounterUpdateButton().click();
+            sleep(2000);
+
+            // Push is enabled again, so text gets updated
+            Assert.assertEquals("Counter has been updated 4 times",
+                    getCounterText());
+        }
+
+        private WebElement getDirectCounterUpdateButton() {
+            return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]");
+        }
+
+        private WebElement getPushToggle() {
+            return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]");
+        }
+
+        private String getCounterText() {
+            return vaadinElement(
+                    "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+                    .getText();
+        }
+
+        private WebElement getDelayedCounterUpdateButton() {
+            return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]");
+        }
+    }
+
     private final Label counterLabel = new Label();
     private int counter = 0;
 
diff --git a/uitest/src/com/vaadin/tests/push/TogglePushInInit.html b/uitest/src/com/vaadin/tests/push/TogglePushInInit.html
deleted file mode 100644 (file)
index c735f22..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="http://localhost:8071/" />
-<title>TogglePushInInit</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">TogglePushInInit</td></tr>
-</thead><tbody>
-<!--Open with push disabled-->
-<tr>
-       <td>open</td>
-       <td>/run-push/com.vaadin.tests.push.TogglePush?restartApplication&push=disabled</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertValue</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td>
-       <td>off</td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>pause</td>
-       <td>2000</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
-       <td>Counter has been updated 0 times</td>
-</tr>
-<!--Open with push enabled-->
-<tr>
-       <td>open</td>
-       <td>/run-push/com.vaadin.tests.push.TogglePush?restartApplication&amp;push=enabled</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertValue</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td>
-       <td>on</td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>pause</td>
-       <td>2000</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
-       <td>Counter has been updated 1 times</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.html b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.html
deleted file mode 100644 (file)
index 89dd7d4..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="http://192.168.2.162:8888/" />
-<title>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
-       <td>open</td>
-       <td>/run/com.vaadin.tests.push.TrackMessageSizeUnitTests?restartApplication</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runcomvaadintestspushTrackMessageSizeUnitTests::PID_SLog_row_0</td>
-       <td>1. All tests run</td>
-</tr>
-</tbody></table>
-</body>
-</html>
index 062698edf5ebef9bc140e649b85483364a478323..d7459f83ab143a61cc5d4c44e73e1fffbf47bf46 100644 (file)
@@ -25,18 +25,29 @@ import javax.servlet.ServletContext;
 import org.apache.commons.io.IOUtils;
 import org.json.JSONArray;
 import org.json.JSONException;
+import org.junit.Assert;
+import org.junit.Test;
 
 import com.vaadin.annotations.JavaScript;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.server.VaadinService;
 import com.vaadin.server.VaadinServletService;
 import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.tests.tb3.MultiBrowserTest;
 import com.vaadin.ui.JavaScriptFunction;
 
 // Load vaadinPush.js so that jQueryVaadin is defined 
 @JavaScript("vaadin://vaadinPush.js")
 public class TrackMessageSizeUnitTests extends AbstractTestUIWithLog {
 
+    public static class TrackMessageSizeUnitTestsTB3 extends MultiBrowserTest {
+        @Test
+        public void runTests() {
+            Assert.assertEquals("1. All tests run",
+                    vaadinElementById("Log_row_0").getText());
+        }
+    }
+
     private String testMethod = "function testSequence(expected, data) {\n"
             + "    var request = {trackMessageLength: true, messageDelimiter: '|'};\n"
             + "    var response = {partialMessage: ''};\n"
index 63819e5f07bc32bc6e29f36145d36471bbaf40cc..189772836655f6aeaf9fa9bb876d6bf0d2248580 100644 (file)
 package com.vaadin.tests.tb3;
 
 import java.net.URL;
+import java.util.Collection;
+import java.util.Collections;
 
 import org.junit.After;
 import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.openqa.selenium.By;
 import org.openqa.selenium.Platform;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.remote.BrowserType;
 import org.openqa.selenium.remote.DesiredCapabilities;
 import org.openqa.selenium.remote.RemoteWebDriver;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
 import com.vaadin.server.LegacyApplication;
-import com.vaadin.testbench.By;
 import com.vaadin.testbench.TestBench;
 import com.vaadin.testbench.TestBenchTestCase;
 import com.vaadin.ui.UI;
@@ -50,6 +56,7 @@ import com.vaadin.ui.UI;
  * 
  * @author Vaadin Ltd
  */
+@RunWith(value = TB3Runner.class)
 public abstract class AbstractTB3Test extends TestBenchTestCase {
     /**
      * Height of the screenshots we want to capture
@@ -153,6 +160,24 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
      */
     protected abstract String getDeploymentHostname();
 
+    /**
+     * Produces a collection of browsers to run the test on. This method is
+     * executed by the test runner when determining how many test methods to
+     * invoke and with what parameters. For each returned value a test method is
+     * ran and before running that,
+     * {@link #setDesiredCapabilities(DesiredCapabilities)} is invoked with the
+     * value returned by this method.
+     * 
+     * This method is not static to allow overriding it in sub classes. By
+     * default runs the test only on Firefox
+     * 
+     * @return The browsers to run the test on
+     */
+    public Collection<DesiredCapabilities> getBrowsersToTest() {
+        return Collections.singleton(BrowserUtil.firefox(17));
+
+    }
+
     /**
      * Used to determine which capabilities should be used when setting up a
      * {@link WebDriver} for this test. Typically set by a test runner or left
@@ -189,9 +214,8 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
     }
 
     /**
-     * Finds a Vaadin element based on the part of a TB3 style locator following
-     * the :: (e.g.
-     * vaadin=runLabelModes::PID_Scheckboxaction-Enabled/domChild[0] ->
+     * Finds an element based on the part of a TB2 style locator following the
+     * :: (e.g. vaadin=runLabelModes::PID_Scheckboxaction-Enabled/domChild[0] ->
      * PID_Scheckboxaction-Enabled/domChild[0]).
      * 
      * @param vaadinLocator
@@ -199,11 +223,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
      * @return
      */
     protected WebElement vaadinElement(String vaadinLocator) {
-        String base = getApplicationId(getDeploymentPath());
-
-        base += "::";
-
-        return driver.findElement(By.vaadin(base + vaadinLocator));
+        return driver.findElement(vaadinLocator(vaadinLocator));
     }
 
     /**
@@ -214,7 +234,58 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
      * @return
      */
     public WebElement vaadinElementById(String id) {
-        return vaadinElement("PID_S" + id);
+        return driver.findElement(vaadinLocatorById(id));
+    }
+
+    /**
+     * Finds a {@link By} locator based on the part of a TB2 style locator
+     * following the :: (e.g.
+     * vaadin=runLabelModes::PID_Scheckboxaction-Enabled/domChild[0] ->
+     * PID_Scheckboxaction-Enabled/domChild[0]).
+     * 
+     * @param vaadinLocator
+     *            The part following :: of the vaadin locator string
+     * @return
+     */
+    public org.openqa.selenium.By vaadinLocator(String vaadinLocator) {
+        String base = getApplicationId(getDeploymentPath());
+
+        base += "::";
+        return com.vaadin.testbench.By.vaadin(base + vaadinLocator);
+    }
+
+    /**
+     * Constructs a {@link By} locator for the id given using Component.setId
+     * 
+     * @param id
+     *            The id to locate
+     * @return a locator for the given id
+     */
+    public By vaadinLocatorById(String id) {
+        return vaadinLocator("PID_S" + id);
+    }
+
+    /**
+     * Waits a short while for the given condition to become true. Use e.g. as
+     * {@link #waitUntil(ExpectedConditions.textToBePresentInElement(by, text))}
+     * 
+     * @param condition
+     *            the condition to wait for to become true
+     */
+    protected void waitUntil(ExpectedCondition<Boolean> condition) {
+        new WebDriverWait(driver, 10).until(condition);
+    }
+
+    /**
+     * Waits a short while for the given condition to become false. Use e.g. as
+     * {@link #waitUntilNot(ExpectedConditions.textToBePresentInElement(by,
+     * text))}
+     * 
+     * @param condition
+     *            the condition to wait for to become false
+     */
+    protected void waitUntilNot(ExpectedCondition<Boolean> condition) {
+        new WebDriverWait(driver, 10).until(ExpectedConditions.not(condition));
     }
 
     /**
index e24218eeb4e6fa1861bac508bffbfa42c5836e39..3553954ec07e57e8c7c0a41c21ab8ce600bd827c 100644 (file)
@@ -18,11 +18,8 @@ package com.vaadin.tests.tb3;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized.Parameters;
 import org.openqa.selenium.remote.DesiredCapabilities;
 
 /**
@@ -41,11 +38,9 @@ import org.openqa.selenium.remote.DesiredCapabilities;
  * 
  * @author Vaadin Ltd
  */
-@RunWith(value = TB3Runner.class)
 public abstract class MultiBrowserTest extends PrivateTB3Configuration {
 
-    private static List<DesiredCapabilities> allBrowsers = new ArrayList<DesiredCapabilities>();
-    private static List<DesiredCapabilities> websocketBrowsers = new ArrayList<DesiredCapabilities>();
+    static List<DesiredCapabilities> allBrowsers = new ArrayList<DesiredCapabilities>();
     static {
         allBrowsers.add(BrowserUtil.ie(8));
         allBrowsers.add(BrowserUtil.ie(9));
@@ -57,26 +52,18 @@ public abstract class MultiBrowserTest extends PrivateTB3Configuration {
         allBrowsers.add(BrowserUtil.chrome(29));
         allBrowsers.add(BrowserUtil.opera(12));
 
-        websocketBrowsers.addAll(allBrowsers);
-        websocketBrowsers.remove(BrowserUtil.ie(8));
-        websocketBrowsers.remove(BrowserUtil.ie(9));
-    }
-
-    @Parameters
-    public static Collection<DesiredCapabilities> getBrowsersForTest() {
-        return getAllBrowsers();
-    }
-
-    public static Collection<DesiredCapabilities> getAllBrowsers() {
-        return Collections.unmodifiableCollection(allBrowsers);
     }
 
     /**
-     * @return A subset of {@link #getAllBrowsers()} including only those which
-     *         support websockets
+     * @return all supported browsers which are actively tested
      */
-    public static Collection<DesiredCapabilities> getWebsocketBrowsers() {
-        return Collections.unmodifiableCollection(websocketBrowsers);
+    public static List<DesiredCapabilities> getAllBrowsers() {
+        return allBrowsers;
+    }
+
+    @Override
+    public Collection<DesiredCapabilities> getBrowsersToTest() {
+        return allBrowsers;
     }
 
 }
index 510d200ffaa0476e4ebc5b673b1d2b43dd643341..5860ac42c0dd7a79f886e8fbde70d9d3c1ad7bee 100644 (file)
 package com.vaadin.tests.tb3;
 
 import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 
 import org.junit.Test;
 import org.junit.runners.BlockJUnit4ClassRunner;
 import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
 import org.junit.runners.model.FrameworkMethod;
 import org.junit.runners.model.InitializationError;
 import org.junit.runners.model.Statement;
@@ -53,49 +49,26 @@ public class TB3Runner extends BlockJUnit4ClassRunner {
     protected List<FrameworkMethod> computeTestMethods() {
         List<FrameworkMethod> tests = new LinkedList<FrameworkMethod>();
 
-        // Find all methods in our test class marked with @Parameters.
-        for (FrameworkMethod method : getTestClass().getAnnotatedMethods(
-                Parameters.class)) {
-            // Make sure the Parameters method is static
-            if (!Modifier.isStatic(method.getMethod().getModifiers())) {
-                throw new IllegalArgumentException("@Parameters " + method
-                        + " must be static.");
-            }
-
-            // Execute the method (statically)
-            Object params;
-            try {
-                params = method.getMethod().invoke(
-                        getTestClass().getJavaClass());
-            } catch (Throwable t) {
-                throw new RuntimeException("Could not run test factory method "
-                        + method.getName(), t);
-            }
-
-            // Did the factory return an array? If so, make it a list.
-            if (params.getClass().isArray()) {
-                params = Arrays.asList((Object[]) params);
-            }
+        if (!AbstractTB3Test.class.isAssignableFrom(getTestClass()
+                .getJavaClass())) {
+            throw new RuntimeException(getClass().getName() + " only supports "
+                    + AbstractTB3Test.class.getName());
+        }
 
-            // Did the factory return a scalar object? If so, put it in a list.
-            if (!(params instanceof Iterable<?>)) {
-                params = Collections.singletonList(params);
-            }
+        try {
+            AbstractTB3Test testClassInstance = (AbstractTB3Test) getTestClass()
+                    .getOnlyConstructor().newInstance();
+            for (DesiredCapabilities capabilities : testClassInstance
+                    .getBrowsersToTest()) {
 
-            // For each object returned by the factory.
-            for (Object param : (Iterable<?>) params) {
-                if (!(param instanceof DesiredCapabilities)) {
-                    throw new RuntimeException("Unexpected parameter type "
-                            + param.getClass().getName()
-                            + " when expecting DesiredCapabilities");
-                }
-                DesiredCapabilities capabilities = (DesiredCapabilities) param;
                 // Find any methods marked with @Test.
                 for (FrameworkMethod m : getTestClass().getAnnotatedMethods(
                         Test.class)) {
                     tests.add(new TB3Method(m.getMethod(), capabilities));
                 }
             }
+        } catch (Exception e) {
+            throw new RuntimeException("Error retrieving browsers to run on", e);
         }
 
         return tests;
diff --git a/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java b/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java
new file mode 100644 (file)
index 0000000..5c6ea32
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2000-2013 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.tb3;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+/**
+ * A {@link MultiBrowserTest} which restricts the tests to the browsers which
+ * support websocket
+ * 
+ * @author Vaadin Ltd
+ */
+public abstract class WebsocketTest extends PrivateTB3Configuration {
+    private static List<DesiredCapabilities> websocketBrowsers = new ArrayList<DesiredCapabilities>();
+    static {
+        websocketBrowsers.addAll(MultiBrowserTest.getAllBrowsers());
+        websocketBrowsers.remove(BrowserUtil.ie(8));
+        websocketBrowsers.remove(BrowserUtil.ie(9));
+    }
+
+    /**
+     * @return All supported browsers which are actively tested and support
+     *         websockets
+     */
+    public static Collection<DesiredCapabilities> getWebsocketBrowsers() {
+        return Collections.unmodifiableCollection(websocketBrowsers);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.vaadin.tests.tb3.AbstractTB3Test#getBrowserToRunOn()
+     */
+    @Override
+    public Collection<DesiredCapabilities> getBrowsersToTest() {
+        return getWebsocketBrowsers();
+    }
+}