summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2016-08-10 11:26:01 +0300
committerHenri Sara <hesara@vaadin.com>2016-08-11 15:34:22 +0300
commitc726ae1b276049282286db3b0934e90ac8d8a2ce (patch)
tree86cdf6ac65acd3bd6c2908652178b99c9dc6c1ae /uitest
parent81b849c1af199be481e00c86ca324cfaffe8a7a0 (diff)
downloadvaadin-framework-c726ae1b276049282286db3b0934e90ac8d8a2ce.tar.gz
vaadin-framework-c726ae1b276049282286db3b0934e90ac8d8a2ce.zip
Make immediate mode the default
Change-Id: I0a1fc0bf6f3de1b7d6975cd87cb7bb65c38dba4e
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/application/ResynchronizeAfterAsyncRemoval.java3
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/OutOfSync.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledParentLayout.java16
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsWaiAria.java6
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/textfield/AutomaticImmediate.java147
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/textfield/AutomaticImmediateTest.java109
6 files changed, 24 insertions, 261 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/application/ResynchronizeAfterAsyncRemoval.java b/uitest/src/main/java/com/vaadin/tests/application/ResynchronizeAfterAsyncRemoval.java
index d8f7fface3..bc6ef22c9a 100644
--- a/uitest/src/main/java/com/vaadin/tests/application/ResynchronizeAfterAsyncRemoval.java
+++ b/uitest/src/main/java/com/vaadin/tests/application/ResynchronizeAfterAsyncRemoval.java
@@ -16,6 +16,9 @@ public class ResynchronizeAfterAsyncRemoval extends AbstractTestUIWithLog {
@Override
public void setup(VaadinRequest vaadinRequest) {
final Window window = new Window("Asynchronously removed window");
+ // without this, the size info sent in the background removes the
+ // window immediately after showing it, making the test fail
+ setImmediate(false);
window.center();
// The window will enqueue a non-immediate message reporting its current
diff --git a/uitest/src/main/java/com/vaadin/tests/components/OutOfSync.java b/uitest/src/main/java/com/vaadin/tests/components/OutOfSync.java
index 8cefffc9d1..a4f80c4cc1 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/OutOfSync.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/OutOfSync.java
@@ -10,6 +10,10 @@ public class OutOfSync extends AbstractTestUI {
@Override
protected void setup(VaadinRequest request) {
+ // Without this, there is an extra request from the UI that changes the
+ // request sequence compared to what the test expects
+ setImmediate(false);
+
Button b = new Button("Click me after 1s to be out of sync");
b.addClickListener(new ClickListener() {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledParentLayout.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledParentLayout.java
index 49d88630a8..5ba158aef8 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledParentLayout.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledParentLayout.java
@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -22,7 +22,7 @@ import com.vaadin.ui.DateField;
import com.vaadin.ui.VerticalLayout;
/**
- *
+ *
* @author Vaadin Ltd
*/
public class DisabledParentLayout extends AbstractTestUI {
@@ -35,7 +35,13 @@ public class DisabledParentLayout extends AbstractTestUI {
content.setMargin(true);
final VerticalLayout pane = new VerticalLayout();
- pane.addComponent(new DateField());
+ DateField dateField = new DateField();
+ // If the field is immediate, the UI behaves differently (the value is
+ // updated and an error is indicated earlier instead of showing the date
+ // selector on the first click as the test expects. Keeping as
+ // non-immediate to test the old expected behavior.
+ dateField.setImmediate(false);
+ pane.addComponent(dateField);
content.addComponent(pane);
diff --git a/uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsWaiAria.java b/uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsWaiAria.java
index e85d60d7c2..fd0a6caf8e 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsWaiAria.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsWaiAria.java
@@ -38,10 +38,15 @@ public class NotificationsWaiAria extends AbstractTestUI {
@Override
protected void setup(VaadinRequest request) {
prefix = new TextField("Prefix", "Info");
+ // The text fields need to be non-immediate to avoid an extra event that
+ // hides the notification while the test is still trying to read its
+ // contents.
+ prefix.setImmediate(false);
addComponent(prefix);
postfix = new TextField("Postfix",
" - closes automatically after 10 seconds");
+ postfix.setImmediate(false);
addComponent(postfix);
role = new NativeSelect("NotificationRole");
@@ -51,6 +56,7 @@ public class NotificationsWaiAria extends AbstractTestUI {
addComponent(role);
tf = new TextArea("Text", "Hello world");
+ tf.setImmediate(false);
tf.setRows(10);
addComponent(tf);
type = new ComboBox();
diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/AutomaticImmediate.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/AutomaticImmediate.java
deleted file mode 100644
index ac51b5fc87..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/textfield/AutomaticImmediate.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.textfield;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractTestUIWithLog;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.TextField;
-
-/**
- * Test to verify fields become implicitly "immediate" when adding value change
- * listener to them.
- *
- * @since 7.2
- * @author Vaadin Ltd
- */
-public class AutomaticImmediate extends AbstractTestUIWithLog {
-
- /**
- *
- */
- static final String BUTTON = "button";
- /**
- *
- */
- static final String EXPLICIT_FALSE = "explicit-false";
- /**
- *
- */
- static final String FIELD = "field";
- /**
- *
- */
- static final String LISTENER_TOGGLE = "listener-toggle";
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
- * VaadinRequest)
- */
- @Override
- protected void setup(VaadinRequest request) {
-
- final TextField textField = new TextField() {
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.ui.AbstractField#fireValueChange(boolean)
- */
- @Override
- protected void fireValueChange(boolean repaintIsNotNeeded) {
- log("fireValueChange");
- super.fireValueChange(repaintIsNotNeeded);
- }
- };
- textField.setId(FIELD);
-
- final ValueChangeListener listener = new ValueChangeListener() {
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- log("Value changed: " + event.getProperty().getValue());
- }
- };
-
- final CheckBox checkBox = new CheckBox("Toggle listener");
- checkBox.addValueChangeListener(new ValueChangeListener() {
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- if (checkBox.getValue()) {
- textField.addValueChangeListener(listener);
- } else {
- textField.removeValueChangeListener(listener);
- }
- }
- });
- checkBox.setId(LISTENER_TOGGLE);
-
- Button b = new Button(
- "setImmediate(false), sets explicitly false and causes server roundtrip",
- new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- textField.setImmediate(false);
- }
- });
- b.setId(EXPLICIT_FALSE);
-
- Button b2 = new Button("Hit server, causes server roundtrip",
- new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- }
- });
- b2.setId(BUTTON);
-
- addComponent(textField);
- addComponent(checkBox);
- addComponent(b);
- addComponent(b2);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
- */
- @Override
- protected String getTestDescription() {
- return "Field should be immediate automatically if it has value change listener";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
- */
- @Override
- protected Integer getTicketNumber() {
- return 8029;
- }
-
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/textfield/AutomaticImmediateTest.java b/uitest/src/test/java/com/vaadin/tests/components/textfield/AutomaticImmediateTest.java
deleted file mode 100644
index 4d750d183f..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/textfield/AutomaticImmediateTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.textfield;
-
-import org.apache.commons.lang.RandomStringUtils;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.Keys;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-public class AutomaticImmediateTest extends MultiBrowserTest {
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.tb3.AbstractTB3Test#getUIClass()
- */
- @Override
- protected Class<?> getUIClass() {
- return AutomaticImmediate.class;
- }
-
- @Test
- public void test() {
- openTestURL();
-
- WebElement field = getDriver().findElement(
- By.id(AutomaticImmediate.FIELD));
-
- WebElement toggle = getDriver().findElement(
- By.xpath("//input[@type = 'checkbox']"));
-
- WebElement explicitFalseButton = getDriver().findElement(
- By.id(AutomaticImmediate.EXPLICIT_FALSE));
-
- WebElement hitServerButton = getDriver().findElement(
- By.id(AutomaticImmediate.BUTTON));
-
- String string = getRandomString();
- field.sendKeys(string + Keys.ENTER);
-
- // Non immediate, just the initial server side valuechange
- assertLastLog("1. fireValueChange");
-
- hitServerButton.click();
-
- // No value change, but value sent to server
- assertLastLog("2. fireValueChange");
-
- // listener on -> immediate on
- toggle.click();
-
- string = getRandomString();
- String delSequence = "" + Keys.BACK_SPACE + Keys.BACK_SPACE;
- field.sendKeys(delSequence + string + Keys.ENTER);
- assertLastLog("4. Value changed: " + string);
-
- // listener off -> immediate off
- String lastvalue = string;
- toggle.click();
- string = getRandomString();
- field.sendKeys(delSequence + string + Keys.ENTER);
- // No new value change should happen...
- assertLastLog("4. Value changed: " + lastvalue);
- hitServerButton.click();
- // ... but server should receive value with roundtrip
- assertLastLog("5. fireValueChange");
-
- // explicitly non immediate, but with listener
- explicitFalseButton.click();
- toggle.click();
-
- string = getRandomString();
- field.sendKeys(delSequence + string + Keys.ENTER);
- // non immediate, no change...
- assertLastLog("5. fireValueChange");
- // ... until server round trip
- hitServerButton.click();
- assertLastLog("7. Value changed: " + string);
-
- }
-
- private String getRandomString() {
- String string = RandomStringUtils.randomAlphanumeric(2);
- return string;
- }
-
- private void assertLastLog(String string) {
- String text = getDriver().findElement(By.id("Log_row_0")).getText();
- Assert.assertEquals(string, text);
- }
-
-}