aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/FocusTest.java
diff options
context:
space:
mode:
authorOlli Tietäväinen <ollit@vaadin.com>2018-02-12 15:14:49 +0200
committerIlia Motornyi <elmot@vaadin.com>2018-02-12 15:14:49 +0200
commitc641c7f56fcccada9268cbe0979fc66726f637d3 (patch)
tree4d177cfefb3c33f917518efb9e060a8ca9c6017f /uitest/src/test/java/com/vaadin/tests/components/FocusTest.java
parent201c4f1d77c96b2284773309a6f8c836e159a2d4 (diff)
downloadvaadin-framework-c641c7f56fcccada9268cbe0979fc66726f637d3.tar.gz
vaadin-framework-c641c7f56fcccada9268cbe0979fc66726f637d3.zip
Implement focus handing in RadioButtonGroup and CheckboxGroup (#10440)
Fixes #10429 * implement focus handing in RadioButtonGroup, fixes #10429 * Merge branch 'master' of https://github.com/vaadin/framework into radiobuttongroup-focus * merge * Merge branch 'master' of https://github.com/vaadin/framework into radiobuttongroup-focus * fix initial focus handling also on CheckBoxGroup and add tests * add license headers * Merge branch 'master' of https://github.com/vaadin/framework into radiobuttongroup-focus * changed client to use lambdas and refactored focus testing to parent class * made FocusTest abstract * Merge branch 'master' of https://github.com/vaadin/framework into radiobuttongroup-focus * don't allow focusing on disabled items & refactor focusing first item
Diffstat (limited to 'uitest/src/test/java/com/vaadin/tests/components/FocusTest.java')
-rwxr-xr-xuitest/src/test/java/com/vaadin/tests/components/FocusTest.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/components/FocusTest.java b/uitest/src/test/java/com/vaadin/tests/components/FocusTest.java
new file mode 100755
index 0000000000..ae7f5301d2
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/FocusTest.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2000-2016 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;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.testbench.TestBenchElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public abstract class FocusTest extends MultiBrowserTest {
+
+ protected boolean isFocusInsideElement(TestBenchElement element) {
+ WebElement focused = getFocusedElement();
+ assertNotNull(focused);
+ String id = focused.getAttribute("id");
+ assertTrue("Focused element should have a non-empty id",
+ id != null && !"".equals(id));
+ return element.isElementPresent(By.id(id));
+ }
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ // Focus does not move when expected with Selenium/TB and Firefox 45
+ return getBrowsersExcludingFirefox();
+ }
+
+}