forked from vaadin/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separates a rpc for handling the client event order in DateTimeField (v…
…aadin#11574) * Using @delayed annotation for DateField Rpc * Separate a rpc for handling the time change in DateTimeField * Add test case for wrong event order
- Loading branch information
Showing
6 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
uitest/src/main/java/com/vaadin/tests/components/datefield/DateTimeFieldEventOrder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.vaadin.tests.components.datefield; | ||
|
||
import com.vaadin.annotations.Widgetset; | ||
import com.vaadin.server.VaadinRequest; | ||
import com.vaadin.shared.ui.ValueChangeMode; | ||
import com.vaadin.shared.ui.datefield.DateTimeResolution; | ||
import com.vaadin.tests.components.AbstractTestUIWithLog; | ||
import com.vaadin.tests.widgetset.TestingWidgetSet; | ||
import com.vaadin.ui.Button; | ||
import com.vaadin.ui.DateTimeField; | ||
import com.vaadin.ui.HorizontalLayout; | ||
import com.vaadin.ui.TextField; | ||
import com.vaadin.v7.shared.ui.datefield.Resolution; | ||
import com.vaadin.v7.ui.DateField; | ||
|
||
@Widgetset(TestingWidgetSet.NAME) | ||
public class DateTimeFieldEventOrder extends AbstractTestUIWithLog { | ||
|
||
@Override | ||
protected void setup(VaadinRequest request) { | ||
|
||
HorizontalLayout horizontalLayout = new HorizontalLayout(); | ||
|
||
DateTimeField dateField = new DateTimeField(); | ||
dateField.setResolution(DateTimeResolution.SECOND); | ||
dateField.setId("test-field"); | ||
dateField.addValueChangeListener( | ||
event -> log("DateTimeField value change event")); | ||
|
||
Button button = new Button("test"); | ||
button.setId("test-button"); | ||
button.addClickListener(ev -> { | ||
log("Button Click Event"); | ||
}); | ||
|
||
TextField tf = new TextField("test"); | ||
tf.setValueChangeMode(ValueChangeMode.BLUR); | ||
tf.addValueChangeListener(event -> log("TextField value change event")); | ||
|
||
DateField df = new DateField(); | ||
df.setResolution(Resolution.SECOND); | ||
df.addValueChangeListener(event -> { | ||
log("DateTimeField V7 value change event"); | ||
}); | ||
|
||
horizontalLayout.addComponents(dateField, button, tf, df); | ||
addComponent(horizontalLayout); | ||
} | ||
|
||
@Override | ||
protected Integer getTicketNumber() { | ||
return 11316; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldEventOrderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.vaadin.tests.components.datefield; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.ui.Select; | ||
|
||
import com.vaadin.testbench.By; | ||
import com.vaadin.testbench.elements.DateTimeFieldElement; | ||
import com.vaadin.tests.tb3.SingleBrowserTest; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class DateTimeFieldEventOrderTest extends SingleBrowserTest { | ||
|
||
@Test | ||
public void testEventOrderIsCorrect() { | ||
openTestURL(); | ||
|
||
DateTimeFieldElement field = $(DateTimeFieldElement.class).first(); | ||
|
||
field.openPopup(); | ||
|
||
List<WebElement> timeSelects = findElement( | ||
By.className("v-datefield-calendarpanel-time")) | ||
.findElements(By.tagName("select")); | ||
|
||
new Select(timeSelects.get(0)).selectByValue("09"); | ||
|
||
findElement(By.id("test-button")).click(); | ||
|
||
assertEquals("The button click event should come second.", | ||
"2. Button Click Event", getLogRow(0)); | ||
assertEquals("The value change event of DTF should come firstly.", | ||
"1. DateTimeField value change event", getLogRow(1)); | ||
|
||
} | ||
} |