summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-01-13 12:42:22 +0200
committerArtur Signell <artur@vaadin.com>2015-01-13 19:55:46 +0200
commit8eeeb35544522b96cba07795f336a14e2737c7ea (patch)
treed1d53b93ac00457f1b64858ee78f7f0832b1826a /uitest
parent2877e42f0dbf706d5b1c79e93ee16320b7b5d8cc (diff)
downloadvaadin-framework-8eeeb35544522b96cba07795f336a14e2737c7ea.tar.gz
vaadin-framework-8eeeb35544522b96cba07795f336a14e2737c7ea.zip
Fix remaining issues for NativeSelect blur/focus events (#6847)
* Do not spam focus/blur events to the server * Receive focus blur events no matter which constructor is used * Run test on all browsers Change-Id: I7d548397e6df3a375f9263c695a53c801d9c5c4a
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java76
1 files changed, 16 insertions, 60 deletions
diff --git a/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java b/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java
index 29c8c27883..bf81ca4390 100644
--- a/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java
+++ b/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java
@@ -15,102 +15,58 @@
*/
package com.vaadin.tests.components.nativeselect;
-import java.util.Collections;
-import java.util.List;
-
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
-import org.openqa.selenium.remote.DesiredCapabilities;
+import com.vaadin.testbench.elements.NativeSelectElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
-/**
- *
- * @since
- * @author Vaadin Ltd
- */
public class NativeSelectsFocusAndBlurListenerTests extends MultiBrowserTest {
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.tb3.MultiBrowserTest#getBrowsersToTest()
- */
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- return Collections.singletonList(Browser.CHROME
- .getDesiredCapabilities());
- }
-
@Test
- public void testFocusListener() throws InterruptedException {
+ public void testFocusAndBlurListener() throws InterruptedException {
setDebug(true);
openTestURL();
- Thread.sleep(1000);
+ Thread.sleep(200);
menu("Component");
menuSub("Listeners");
menuSub("Focus listener");
-
- getDriver().findElement(By.tagName("body")).click();
-
- WebElement select = getDriver().findElement(By.tagName("select"));
- select.click();
-
- String bodytext = getDriver().findElement(By.tagName("body")).getText();
-
- Assert.assertTrue(bodytext.contains("FocusEvent"));
-
- }
-
- @Test
- public void testBlurListener() throws InterruptedException {
- setDebug(true);
- openTestURL();
- Thread.sleep(1000);
menu("Component");
menuSub("Listeners");
menuSub("Blur listener");
- getDriver().findElement(By.tagName("body")).click();
-
- WebElement select = getDriver().findElement(By.tagName("select"));
- select.click();
+ findElement(By.tagName("body")).click();
+ NativeSelectElement s = $(NativeSelectElement.class).first();
+ s.selectByText("Item 3");
getDriver().findElement(By.tagName("body")).click();
- String bodytext = getDriver().findElement(By.tagName("body")).getText();
-
- Assert.assertTrue(bodytext.contains("BlurEvent"));
+ // Somehow selectByText causes focus + blur + focus + blur on
+ // Chrome/PhantomJS
+ if (BrowserUtil.isChrome(getDesiredCapabilities())
+ || BrowserUtil.isPhantomJS(getDesiredCapabilities())) {
+ Assert.assertEquals("4. FocusEvent", getLogRow(1));
+ Assert.assertEquals("5. BlurEvent", getLogRow(0));
+ } else {
+ Assert.assertEquals("2. FocusEvent", getLogRow(1));
+ Assert.assertEquals("3. BlurEvent", getLogRow(0));
+ }
}
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.tb3.AbstractTB3Test#getUIClass()
- */
@Override
protected Class<?> getUIClass() {
return NativeSelects.class;
}
- /**
- * @since
- * @param string
- */
private void menuSub(String string) {
getDriver().findElement(By.xpath("//span[text() = '" + string + "']"))
.click();
new Actions(getDriver()).moveByOffset(100, 0).build().perform();
}
- /**
- * @since
- * @param string
- */
private void menu(String string) {
getDriver().findElement(By.xpath("//span[text() = '" + string + "']"))
.click();