From 5edc32fa0ba7a7c29190f57697b4398a78d05dd2 Mon Sep 17 00:00:00 2001 From: Guillermo Alvarez Date: Mon, 11 Aug 2014 10:56:58 +0300 Subject: Correctly display an item which is too long for the textfield. (#13477) New JSNI function allows direction parameter in setSelectionRange. This allows setting selection backward and fixes the issue in FF. Change-Id: I1e34b70983e3f525b7009668877038f108d286a7 --- client/src/com/vaadin/client/Util.java | 34 +++++++++++++++++++++- client/src/com/vaadin/client/ui/VFilterSelect.java | 31 ++++++++++++++++---- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/client/src/com/vaadin/client/Util.java b/client/src/com/vaadin/client/Util.java index 49c862006b..e37b044826 100644 --- a/client/src/com/vaadin/client/Util.java +++ b/client/src/com/vaadin/client/Util.java @@ -1419,6 +1419,37 @@ public class Util { } } + /** + * Sets the selection range of an input element. + * + * We need this JSNI function to set selection range so that we can use the + * optional direction attribute to set the anchor to the end and the focus + * to the start. This makes Firefox work the same way as other browsers + * (#13477) + * + * @param elem + * the html input element. + * @param pos + * the index of the first selected character. + * @param length + * the selection length. + * @param direction + * a string indicating the direction in which the selection was + * performed. This may be "forward" or "backward", or "none" if + * the direction is unknown or irrelevant. + * + * @since + */ + public native static void setSelectionRange(Element elem, int pos, + int length, String direction) + /*-{ + try { + elem.setSelectionRange(pos, pos + length, direction); + } catch (e) { + // Firefox throws exception if TextBox is not visible, even if attached + } + }-*/; + /** * Wrap a css size value and its unit and translate back and forth to the * string representation.
@@ -1571,7 +1602,8 @@ public class Util { * @return true if the two sizes are equals, otherwise false. */ public static boolean equals(String cssSize1, String cssSize2) { - return CssSize.fromString(cssSize1).equals(CssSize.fromString(cssSize2)); + return CssSize.fromString(cssSize1).equals( + CssSize.fromString(cssSize2)); } } diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java index 6ba0785acc..516fe5e9b3 100644 --- a/client/src/com/vaadin/client/ui/VFilterSelect.java +++ b/client/src/com/vaadin/client/ui/VFilterSelect.java @@ -1057,11 +1057,33 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, @Override public void setSelectionRange(int pos, int length) { if (textInputEnabled) { - super.setSelectionRange(pos, length); + /* + * set selection range with a backwards direction: anchor at the + * back, focus at the front. This means that items that are too + * long to display will display from the start and not the end + * even on Firefox. + * + * We need the JSNI function to set selection range so that we + * can use the optional direction attribute to set the anchor to + * the end and the focus to the start. This makes Firefox work + * the same way as other browsers (#13477) + */ + Util.setSelectionRange(getElement(), pos, length, "backward"); + } else { - super.setSelectionRange(0, getValue().length()); + /* + * Setting the selectionrange for an uneditable textbox leads to + * unwanted behaviour when the width of the textbox is narrower + * than the width of the entry: the end of the entry is shown + * instead of the beginning. (see #13477) + * + * To avoid this, we set the caret to the beginning of the line. + */ + + super.setSelectionRange(0, 0); } } + } @Deprecated @@ -1456,9 +1478,8 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, private void setText(final String text) { /** - * To leave caret in the beginning of the line. - * SetSelectionRange wouldn't work on IE - * (see #13477) + * To leave caret in the beginning of the line. SetSelectionRange + * wouldn't work on IE (see #13477) */ Direction previousDirection = tb.getDirection(); tb.setDirection(Direction.RTL); -- cgit v1.2.3 From 7a49a096ab82a2f9a745c16c089cba85e8fa5c13 Mon Sep 17 00:00:00 2001 From: Guillermo Alvarez Date: Wed, 6 Aug 2014 17:25:09 +0300 Subject: Pressing [down]+[enter] on a combobox now closes the popup. (#14379) Pressing down to open the popup menu and then pressing enter to select the same item as is already selected will now cause the same behavior as pressing the escape key when there are suggestions. Change-Id: I6052608cc5916d306a981aa0f98b0ae822da5eb4 --- client/src/com/vaadin/client/ui/VFilterSelect.java | 20 ++++--- .../combobox/ComboBoxSuggestionPopupClose.java | 29 ++++++++++ .../combobox/ComboBoxSuggestionPopupCloseTest.java | 65 ++++++++++++++++++++++ 3 files changed, 106 insertions(+), 8 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupClose.java create mode 100644 uitest/src/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupCloseTest.java diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java index 516fe5e9b3..230c9e6639 100644 --- a/client/src/com/vaadin/client/ui/VFilterSelect.java +++ b/client/src/com/vaadin/client/ui/VFilterSelect.java @@ -254,7 +254,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, /** * Shows the popup where the user can see the filtered options - * + * * @param currentSuggestions * The filtered suggestions * @param currentPage @@ -345,7 +345,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, /** * Should the next page button be visible to the user? - * + * * @param active */ private void setNextButtonActive(boolean active) { @@ -365,7 +365,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, /** * Should the previous page button be visible to the user - * + * * @param active */ private void setPrevButtonActive(boolean active) { @@ -554,7 +554,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, * amount of items are visible at a time and a scrollbar or buttons are * visible to change page. If paging is turned of then all options are * rendered into the popup menu. - * + * * @param paging * Should the paging be turned on? */ @@ -679,7 +679,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, /** * Was the popup just closed? - * + * * @return true if popup was just closed */ public boolean isJustClosed() { @@ -708,7 +708,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, /** * Updates style names in suggestion popup to help theme building. - * + * * @param uidl * UIDL for the whole combo box * @param componentState @@ -799,7 +799,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, /** * Sets the suggestions rendered in the menu - * + * * @param suggestions * The suggestions to be rendered in the menu */ @@ -1784,10 +1784,14 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, if (!allowNewItem) { /* * New items are not allowed: If there is only one - * suggestion, select that. Otherwise do nothing. + * suggestion, select that. If there is more than one + * suggestion Enter key should work as Escape key. Otherwise + * do nothing. */ if (currentSuggestions.size() == 1) { onSuggestionSelected(currentSuggestions.get(0)); + } else if (currentSuggestions.size() > 1) { + reset(); } } else { // Handle addition of new items. diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupClose.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupClose.java new file mode 100644 index 0000000000..253d6a0d1e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupClose.java @@ -0,0 +1,29 @@ +package com.vaadin.tests.components.combobox; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.ComboBox; + +public class ComboBoxSuggestionPopupClose extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final ComboBox select = new ComboBox("ComboBox"); + select.addItem("one"); + select.addItem("two"); + select.addItem("three"); + addComponent(select); + } + + @Override + protected String getTestDescription() { + return "Closing the suggestion popup using Enter key is " + + "broken in combobox when opening popup using Enter " + + "key and not changin the selection using arrows"; + } + + @Override + protected Integer getTicketNumber() { + return 14379; + } +} diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupCloseTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupCloseTest.java new file mode 100644 index 0000000000..5e9e076cac --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupCloseTest.java @@ -0,0 +1,65 @@ +/* + * 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.combobox; + +import static org.junit.Assert.assertFalse; +import static org.openqa.selenium.Keys.ARROW_DOWN; +import static org.openqa.selenium.Keys.ENTER; + +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ComboBoxElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * @author Vaadin Ltd + */ +public class ComboBoxSuggestionPopupCloseTest extends MultiBrowserTest { + + private WebElement selectTextbox; + + @Test + public void closeSuggestionPopupTest() throws Exception { + openTestURL(); + + waitForElementVisible(By.className("v-filterselect")); + + selectTextbox = $(ComboBoxElement.class).first().findElement( + By.vaadin("#textbox")); + selectTextbox.click(); + + // open popup and select first element + sendKeys(new Keys[] { ARROW_DOWN, ARROW_DOWN, ENTER }); + + // open popup and hit enter to close it + sendKeys(new Keys[] { ARROW_DOWN, ENTER }); + + assertFalse(isElementPresent(By.className("v-filterselect-suggestmenu"))); + + } + + private void sendKeys(Keys[] keys) throws Exception { + for (Keys key : keys) { + selectTextbox.sendKeys(key); + // wait a while between the key presses, at least PhantomJS fails if + // they are sent too fast + sleep(10); + } + } +}; -- cgit v1.2.3 From 223670ca8b6f8a89af59b0088bad97fddf2d956a Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 12 Aug 2014 17:19:33 +0300 Subject: Make test more reliable Change-Id: I16a0000ae506b5aef4f4d44cf0ee7235da14a21a --- .../tests/components/datefield/DateFieldChangeResolutionTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldChangeResolutionTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldChangeResolutionTest.java index 6820410059..e3c85224c0 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/DateFieldChangeResolutionTest.java +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldChangeResolutionTest.java @@ -99,7 +99,10 @@ public class DateFieldChangeResolutionTest extends MultiBrowserTest { } private void checkHeaderAndBody(Resolution resolution, - boolean textFieldIsEmpty) { + boolean textFieldIsEmpty) throws Exception { + // Popup date field has all kinds of strange timers on the + // client side + sleep(100); // Open the popup calendar, perform checks and close the popup. openPopupDateField(); if (resolution.getCalendarField() >= Resolution.MONTH -- cgit v1.2.3 From fba69ae5d8cd617424e324c62b14225decf0315e Mon Sep 17 00:00:00 2001 From: Jonatan Kronqvist Date: Tue, 12 Aug 2014 13:52:09 +0300 Subject: Allow for multiple license keys in a single license file #14408 License files can now contain multiple keys to support different versions of a product. The keys are identified by the major version number followed by an equals sign and the key for that version, e.g. 1 = foo-bar-baz 2 = baz-foo-bar The license file can also contain a "default" license key, which is used for all versions except for the explicitly defined ones, e.g. foo-bar-baz 3 = baz-bar-foo 4 = bar-baz-baz Change-Id: Id07d22e9fdc44189c4298b634006cf0df128bfd9 --- .../src/com/vaadin/tools/CvalChecker.java | 20 ++- .../src/com/vaadin/tools/CvalCheckerTest.java | 147 +++++++++++++++++++-- 2 files changed, 158 insertions(+), 9 deletions(-) diff --git a/client-compiler/src/com/vaadin/tools/CvalChecker.java b/client-compiler/src/com/vaadin/tools/CvalChecker.java index 2de7e10faa..e426c5c4e6 100644 --- a/client-compiler/src/com/vaadin/tools/CvalChecker.java +++ b/client-compiler/src/com/vaadin/tools/CvalChecker.java @@ -26,6 +26,7 @@ import java.net.URLConnection; import java.text.MessageFormat; import java.util.Arrays; import java.util.Date; +import java.util.List; import java.util.Locale; import java.util.ResourceBundle; import java.util.prefs.Preferences; @@ -465,7 +466,8 @@ public final class CvalChecker { if (url != null) { try { - key = IOUtils.toString(url.openStream()); + key = readKeyFromFile(url, + computeMajorVersion(productVersion)); if (key != null && !(key = key.trim()).isEmpty()) { return key; } @@ -480,6 +482,22 @@ public final class CvalChecker { productTitle, null, null); } + String readKeyFromFile(URL url, int majorVersion) throws IOException { + String majorVersionStr = String.valueOf(majorVersion); + List lines = IOUtils.readLines(url.openStream()); + String defaultKey = null; + for (String line : lines) { + String[] parts = line.split("\\s*=\\s*"); + if (parts.length < 2) { + defaultKey = parts[0].trim(); + } + if (parts[0].equals(majorVersionStr)) { + return parts[1].trim(); + } + } + return defaultKey; + } + static String getErrorMessage(String key, Object... pars) { Locale loc = Locale.getDefault(); ResourceBundle res = ResourceBundle.getBundle( diff --git a/client-compiler/tests/src/com/vaadin/tools/CvalCheckerTest.java b/client-compiler/tests/src/com/vaadin/tools/CvalCheckerTest.java index 51b12f4c7e..2985f61631 100644 --- a/client-compiler/tests/src/com/vaadin/tools/CvalCheckerTest.java +++ b/client-compiler/tests/src/com/vaadin/tools/CvalCheckerTest.java @@ -24,13 +24,17 @@ import static com.vaadin.tools.CvalChecker.GRACE_DAYS_MSECS; import static com.vaadin.tools.CvalChecker.cacheLicenseInfo; import static com.vaadin.tools.CvalChecker.deleteCache; import static com.vaadin.tools.CvalChecker.parseJson; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileDescriptor; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; +import java.io.PrintWriter; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; @@ -147,7 +151,7 @@ public class CvalCheckerTest { productTitleCval); Assert.fail(); } catch (InvalidCvalException expected) { - Assert.assertEquals(productNameCval, expected.name); + assertEquals(productNameCval, expected.name); } Assert.assertFalse(cacheExists(productNameCval)); @@ -158,7 +162,7 @@ public class CvalCheckerTest { productTitleCval); Assert.fail(); } catch (InvalidCvalException expected) { - Assert.assertEquals(productNameCval, expected.name); + assertEquals(productNameCval, expected.name); } Assert.assertFalse(cacheExists(productNameCval)); @@ -169,7 +173,7 @@ public class CvalCheckerTest { productTitleCval); Assert.fail(); } catch (InvalidCvalException expected) { - Assert.assertEquals(productNameCval, expected.name); + assertEquals(productNameCval, expected.name); } Assert.assertFalse(cacheExists(productNameCval)); @@ -180,7 +184,7 @@ public class CvalCheckerTest { productTitleCval); Assert.fail(); } catch (InvalidCvalException expected) { - Assert.assertEquals(productNameCval, expected.name); + assertEquals(productNameCval, expected.name); } Assert.assertFalse(cacheExists(productNameCval)); @@ -207,7 +211,7 @@ public class CvalCheckerTest { } catch (InvalidCvalException expected) { Assert.fail(); } catch (UnreachableCvalServerException expected) { - Assert.assertEquals(productNameCval, expected.name); + assertEquals(productNameCval, expected.name); } Assert.assertFalse(cacheExists(productNameCval)); @@ -221,7 +225,7 @@ public class CvalCheckerTest { } catch (InvalidCvalException expected) { Assert.fail(); } catch (UnreachableCvalServerException expected) { - Assert.assertEquals(productNameCval, expected.name); + assertEquals(productNameCval, expected.name); } Assert.assertFalse(cacheExists(productNameCval)); @@ -234,7 +238,7 @@ public class CvalCheckerTest { productTitleCval); Assert.fail(); } catch (InvalidCvalException expected) { - Assert.assertEquals(productNameCval, expected.name); + assertEquals(productNameCval, expected.name); // Check that we use server customized message if it comes Assert.assertTrue(expected.getMessage().contains("Custom")); } @@ -255,7 +259,7 @@ public class CvalCheckerTest { productTitleCval); Assert.fail(); } catch (InvalidCvalException expected) { - Assert.assertEquals(productNameCval, expected.name); + assertEquals(productNameCval, expected.name); } Assert.assertTrue(cacheExists(productNameCval)); } @@ -339,4 +343,131 @@ public class CvalCheckerTest { static void restoreSystemOut() { System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); } + + @Test(expected = FileNotFoundException.class) + public void testReadKeyFromFile_NonexistingLicenseFile() throws Exception { + licenseChecker.readKeyFromFile(new URL("file:///foobar.baz"), 4); + } + + @Test + public void testReadKeyFromFile_LicenseFileEmpty() throws Exception { + File tmpLicenseFile = File.createTempFile("license", "lic"); + + assertNull(licenseChecker.readKeyFromFile(tmpLicenseFile.toURI() + .toURL(), 4)); + + tmpLicenseFile.delete(); + } + + @Test + public void testReadKeyFromFile_LicenseFileHasSingleUnidentifiedKey() + throws Exception { + File tmpLicenseFile = File.createTempFile("license", "lic"); + PrintWriter out = new PrintWriter(tmpLicenseFile); + out.println("this-is-a-license"); + out.close(); + + assertEquals("this-is-a-license", licenseChecker.readKeyFromFile( + tmpLicenseFile.toURI().toURL(), 4)); + + tmpLicenseFile.delete(); + } + + @Test + public void testReadKeyFromFile_LicenseFileHasSingleIdentifiedKey() + throws Exception { + File tmpLicenseFile = File.createTempFile("license", "lic"); + PrintWriter out = new PrintWriter(tmpLicenseFile); + out.println("4=this-is-a-license"); + out.close(); + + assertEquals("this-is-a-license", licenseChecker.readKeyFromFile( + tmpLicenseFile.toURI().toURL(), 4)); + + tmpLicenseFile.delete(); + } + + @Test + public void testReadKeyFromFile_LicenseFileHasMultipleKeys() + throws Exception { + File tmpLicenseFile = File.createTempFile("license", "lic"); + PrintWriter out = new PrintWriter(tmpLicenseFile); + out.println("4=this-is-a-license"); + out.println("5=this-is-another-license"); + out.close(); + + assertEquals("this-is-a-license", licenseChecker.readKeyFromFile( + tmpLicenseFile.toURI().toURL(), 4)); + assertEquals("this-is-another-license", licenseChecker.readKeyFromFile( + tmpLicenseFile.toURI().toURL(), 5)); + + tmpLicenseFile.delete(); + } + + @Test + public void testReadKeyFromFile_LicenseFileHasMultipleKeysWithWhitespace() + throws Exception { + File tmpLicenseFile = File.createTempFile("license", "lic"); + PrintWriter out = new PrintWriter(tmpLicenseFile); + out.println("4 = this-is-a-license"); + out.println("5 = this-is-another-license"); + out.close(); + + assertEquals("this-is-a-license", licenseChecker.readKeyFromFile( + tmpLicenseFile.toURI().toURL(), 4)); + assertEquals("this-is-another-license", licenseChecker.readKeyFromFile( + tmpLicenseFile.toURI().toURL(), 5)); + + tmpLicenseFile.delete(); + } + + @Test + public void testReadKeyFromFile_RequestedVersionMissing() throws Exception { + File tmpLicenseFile = File.createTempFile("license", "lic"); + PrintWriter out = new PrintWriter(tmpLicenseFile); + out.println("4 = this-is-a-license"); + out.println("5 = this-is-another-license"); + out.close(); + + assertNull(licenseChecker.readKeyFromFile(tmpLicenseFile.toURI() + .toURL(), 3)); + + tmpLicenseFile.delete(); + } + + @Test + public void testReadKeyFromFile_FallbackToDefaultKey() throws Exception { + File tmpLicenseFile = File.createTempFile("license", "lic"); + PrintWriter out = new PrintWriter(tmpLicenseFile); + out.println("this-is-a-license"); + out.println("5 = this-is-another-license"); + out.close(); + + assertEquals("this-is-a-license", licenseChecker.readKeyFromFile(tmpLicenseFile.toURI() + .toURL(), 3)); + assertEquals("this-is-a-license", licenseChecker.readKeyFromFile(tmpLicenseFile.toURI() + .toURL(), 4)); + assertEquals("this-is-another-license", licenseChecker.readKeyFromFile( + tmpLicenseFile.toURI().toURL(), 5)); + + tmpLicenseFile.delete(); + } + + @Test + public void testReadKeyFromFile_FallbackToDefaultKeyReversed() throws Exception { + File tmpLicenseFile = File.createTempFile("license", "lic"); + PrintWriter out = new PrintWriter(tmpLicenseFile); + out.println("5 = this-is-another-license"); + out.println("this-is-a-license"); + out.close(); + + assertEquals("this-is-a-license", licenseChecker.readKeyFromFile(tmpLicenseFile.toURI() + .toURL(), 3)); + assertEquals("this-is-a-license", licenseChecker.readKeyFromFile(tmpLicenseFile.toURI() + .toURL(), 4)); + assertEquals("this-is-another-license", licenseChecker.readKeyFromFile( + tmpLicenseFile.toURI().toURL(), 5)); + + tmpLicenseFile.delete(); + } } -- cgit v1.2.3 From c5c6a78787dd1d86c511b50361efc9acedee6684 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 13 Aug 2014 20:00:17 +0300 Subject: Workaround for super dev mode line offset issue (#14051) Change-Id: I29f59fce90b7060a97787d3c3ce12f890af40079 --- client/src/com/vaadin/DefaultWidgetSet.gwt.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/src/com/vaadin/DefaultWidgetSet.gwt.xml b/client/src/com/vaadin/DefaultWidgetSet.gwt.xml index 2719493853..461bd5ed1b 100755 --- a/client/src/com/vaadin/DefaultWidgetSet.gwt.xml +++ b/client/src/com/vaadin/DefaultWidgetSet.gwt.xml @@ -14,4 +14,8 @@ file. Speeds up compilation and does not make the Javascript significantly larger. --> + + + + -- cgit v1.2.3 From 52b98ccd173682355af9396ce216ce5a98993194 Mon Sep 17 00:00:00 2001 From: Bogdan Udrescu Date: Mon, 11 Aug 2014 13:08:39 +0300 Subject: Prevent browser to scroll when space it pressed on a TabSheet (#14320) Browser page scroll by default when space key is pressed. The TabSheet uses the space key (32) to select the tab when navigating using left/right keys. So when the space is pressed the default browser page scroll behavior is now prevented. Change-Id: I8c3c7c4904109018d2f91447235e30dbd29eec5d --- client/src/com/vaadin/client/ui/VTabsheet.java | 16 +++++- .../components/tabsheet/TabSpaceNotScroll.java | 67 ++++++++++++++++++++++ .../components/tabsheet/TabSpaceNotScrollTest.java | 54 +++++++++++++++++ 3 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 uitest/src/com/vaadin/tests/components/tabsheet/TabSpaceNotScroll.java create mode 100644 uitest/src/com/vaadin/tests/components/tabsheet/TabSpaceNotScrollTest.java diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index 15d9c83c49..35fdebf353 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -1280,6 +1280,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, if (event.getSource() instanceof Tab) { int keycode = event.getNativeEvent().getKeyCode(); + // Scroll throw the tabs. if (!event.isAnyModifierKeyDown()) { if (keycode == getPreviousTabKey()) { selectPreviousTab(); @@ -1294,6 +1295,10 @@ public class VTabsheet extends VTabsheetBase implements Focusable, } } else if (keycode == getSelectTabKey()) { loadTabSheet(focusedTabIndex); + + // Prevent the page from scrolling when hitting space + // (select key) to select the current tab. + event.preventDefault(); } } } @@ -1307,8 +1312,17 @@ public class VTabsheet extends VTabsheetBase implements Focusable, return KeyCodes.KEY_LEFT; } + /** + * Gets the key to activate the selected tab when navigating using + * previous/next (left/right) keys. + * + * @return the key to activate the selected tab. + * + * @see #getNextTabKey() + * @see #getPreviousTabKey() + */ protected int getSelectTabKey() { - return 32; // Space key + return KeyCodes.KEY_SPACE; } /** diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSpaceNotScroll.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSpaceNotScroll.java new file mode 100644 index 0000000000..3a5be51e47 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSpaceNotScroll.java @@ -0,0 +1,67 @@ +/* + * 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.tabsheet; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Component; +import com.vaadin.ui.Label; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.VerticalLayout; + +/** + * If the space is pressed on the tabs of a tabsheet the browser default scroll + * behavior must be prevented. + * + * @since + * @author Vaadin Ltd + */ +public class TabSpaceNotScroll extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + TabSheet tabSheet = new TabSheet(); + + for (int i = 0; i < 5; i++) { + String caption = "Tab " + i; + Component c = new Label(caption); + tabSheet.addTab(c, caption); + } + + addComponent(tabSheet); + + Label dontShowThis = new Label("Page scroll. This is bad."); + + VerticalLayout panel = new VerticalLayout(); + panel.setHeight("2000px"); + panel.addComponent(dontShowThis); + panel.setComponentAlignment(dontShowThis, Alignment.MIDDLE_CENTER); + + addComponent(panel); + } + + @Override + protected String getTestDescription() { + return "Pressing space on the tab should not scroll."; + } + + @Override + protected Integer getTicketNumber() { + return 14320; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSpaceNotScrollTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSpaceNotScrollTest.java new file mode 100644 index 0000000000..c35248c1f4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSpaceNotScrollTest.java @@ -0,0 +1,54 @@ +/* + * 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.tabsheet; + +import java.io.IOException; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.Point; + +import com.vaadin.testbench.TestBenchElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test if the page scroll when press space on a tabsheet's tab. + * + * @since + * @author Vaadin Ltd + */ +public class TabSpaceNotScrollTest extends MultiBrowserTest { + + @Test + public void testScroll() throws InterruptedException, IOException { + openTestURL(); + + TestBenchElement tab = (TestBenchElement) getDriver().findElement( + By.className("v-tabsheet-tabitemcell")); + tab.click(10, 10); + + Point oldLocation = tab.getLocation(); + + tab.sendKeys(Keys.SPACE); + + Point newLocation = tab.getLocation(); + + Assert.assertEquals(oldLocation, newLocation); + } + +} -- cgit v1.2.3 From c8e6c343483c4b4eaaa5b2a20b8c174c3b6c5f84 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 11 Aug 2014 13:43:53 +0300 Subject: Support setting persistent hover and require window focus parameters Change-Id: I0b2bb3fba1a8a854799fd087601ba54988ec423b --- .../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index e463f666d9..6c37e7b950 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -233,6 +233,15 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { */ private void setupRemoteDriver(DesiredCapabilities capabilities) throws Exception { + if (BrowserUtil.isIE(capabilities)) { + capabilities.setCapability( + InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, + requireWindowFocusForIE()); + capabilities.setCapability( + InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, + usePersistentHoverForIE()); + } + for (int i = 1; i <= BROWSER_INIT_ATTEMPTS; i++) { try { WebDriver dr = TestBench.createDriver(new RemoteWebDriver( @@ -1128,4 +1137,33 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { return findElement(By.xpath("//button[@title='Debug message log']")); } + /** + * Should the "require window focus" be enabled for Internet Explorer. + * RequireWindowFocus makes tests more stable but seems to be broken with + * certain commands such as sendKeys. Therefore it is not enabled by default + * for all tests + * + * @return true, to use the "require window focus" feature, false otherwise + */ + protected boolean requireWindowFocusForIE() { + return false; + } + + /** + * Should the "enable persistent hover" be enabled for Internet Explorer. + * + * Persistent hovering causes continuous firing of mouse over events at the + * last location the mouse cursor has been moved to. This is to avoid + * problems where the real mouse cursor is inside the browser window and + * Internet Explorer uses that location for some undefined operation + * (http:// + * jimevansmusic.blogspot.fi/2012/06/whats-wrong-with-internet-explorer + * .html) + * + * @return true, to use the "persistent hover" feature, false otherwise + */ + protected boolean usePersistentHoverForIE() { + return true; + } + } -- cgit v1.2.3 From 702f00f86534ec35cecd9f28bdce3d262d95e818 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 11 Aug 2014 22:27:35 +0300 Subject: Made Valo test UI deterministic and added TB test Change-Id: I342fad836ad0d4014748a06c8ccfed53a99e6ece --- build/ide.xml | 21 ++ buildhelpers/ivy.xml | 1 - uitest/build.xml | 135 +++++++++--- uitest/ivy.xml | 8 + .../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 73 +++++++ .../com/vaadin/tests/themes/valo/CalendarTest.java | 55 +---- .../com/vaadin/tests/themes/valo/CommonParts.java | 8 +- .../com/vaadin/tests/themes/valo/DateFields.java | 50 +++-- uitest/src/com/vaadin/tests/themes/valo/Forms.java | 2 +- .../src/com/vaadin/tests/themes/valo/Sliders.java | 26 ++- .../com/vaadin/tests/themes/valo/ValoThemeUI.java | 14 +- .../vaadin/tests/themes/valo/ValoThemeUITest.java | 239 +++++++++++++++++++++ 12 files changed, 521 insertions(+), 111 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java diff --git a/build/ide.xml b/build/ide.xml index fa8b85ee23..c7183077a9 100755 --- a/build/ide.xml +++ b/build/ide.xml @@ -71,6 +71,27 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/buildhelpers/ivy.xml b/buildhelpers/ivy.xml index 9117721444..cf04bfdc5d 100644 --- a/buildhelpers/ivy.xml +++ b/buildhelpers/ivy.xml @@ -18,7 +18,6 @@ - diff --git a/uitest/build.xml b/uitest/build.xml index 84f44a2d72..e81983f1f5 100644 --- a/uitest/build.xml +++ b/uitest/build.xml @@ -11,6 +11,7 @@ + @@ -91,7 +92,7 @@ - + @@ -121,10 +122,13 @@ + + + @@ -192,43 +196,43 @@ - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + @@ -241,4 +245,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Compiling ${theme} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/uitest/ivy.xml b/uitest/ivy.xml index 020543c53f..9af209662c 100644 --- a/uitest/ivy.xml +++ b/uitest/ivy.xml @@ -15,6 +15,7 @@ + @@ -99,6 +100,13 @@ + + + + + diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 6c37e7b950..7e22537032 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -18,14 +18,25 @@ package com.vaadin.tests.tb3; import static com.vaadin.tests.tb3.TB3Runner.localWebDriverIsUsed; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import java.lang.reflect.Field; import java.net.URL; import java.util.Collections; import java.util.List; +import org.apache.commons.io.IOUtils; +import org.apache.http.HttpHost; +import org.apache.http.HttpResponse; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.message.BasicHttpEntityEnclosingRequest; +import org.json.JSONException; +import org.json.JSONObject; import org.junit.After; import org.junit.Before; import org.junit.runner.RunWith; @@ -42,6 +53,7 @@ import org.openqa.selenium.interactions.internal.Coordinates; import org.openqa.selenium.internal.Locatable; import org.openqa.selenium.remote.BrowserType; import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.HttpCommandExecutor; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.ExpectedConditions; @@ -51,6 +63,7 @@ import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium; import com.vaadin.server.LegacyApplication; import com.vaadin.server.UIProvider; import com.vaadin.testbench.TestBench; +import com.vaadin.testbench.TestBenchDriverProxy; import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.TestBenchTestCase; import com.vaadin.tests.components.AbstractTestUIWithLog; @@ -1166,4 +1179,64 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { return true; } + // FIXME: Remove this once TB4 getRemoteControlName works properly + private RemoteWebDriver getRemoteDriver() { + WebDriver d = getDriver(); + if (d instanceof TestBenchDriverProxy) { + try { + Field f = TestBenchDriverProxy.class + .getDeclaredField("actualDriver"); + f.setAccessible(true); + return (RemoteWebDriver) f.get(d); + } catch (Exception e) { + e.printStackTrace(); + } + } + + if (d instanceof RemoteWebDriver) { + return (RemoteWebDriver) d; + } + + return null; + + } + + // FIXME: Remove this once TB4 getRemoteControlName works properly + protected String getRemoteControlName() { + try { + RemoteWebDriver d = getRemoteDriver(); + if (d == null) { + return null; + } + HttpCommandExecutor ce = (HttpCommandExecutor) d + .getCommandExecutor(); + String hostName = ce.getAddressOfRemoteServer().getHost(); + int port = ce.getAddressOfRemoteServer().getPort(); + HttpHost host = new HttpHost(hostName, port); + DefaultHttpClient client = new DefaultHttpClient(); + URL sessionURL = new URL("http://" + hostName + ":" + port + + "/grid/api/testsession?session=" + d.getSessionId()); + BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest( + "POST", sessionURL.toExternalForm()); + HttpResponse response = client.execute(host, r); + JSONObject object = extractObject(response); + URL myURL = new URL(object.getString("proxyId")); + if ((myURL.getHost() != null) && (myURL.getPort() != -1)) { + return myURL.getHost(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + private static JSONObject extractObject(HttpResponse resp) + throws IOException, JSONException { + InputStream contents = resp.getEntity().getContent(); + StringWriter writer = new StringWriter(); + IOUtils.copy(contents, writer, "UTF8"); + JSONObject objToReturn = new JSONObject(writer.toString()); + return objToReturn; + } + } diff --git a/uitest/src/com/vaadin/tests/themes/valo/CalendarTest.java b/uitest/src/com/vaadin/tests/themes/valo/CalendarTest.java index 17dfd6cb67..280ddf98b7 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/CalendarTest.java +++ b/uitest/src/com/vaadin/tests/themes/valo/CalendarTest.java @@ -4,7 +4,6 @@ import java.text.DateFormatSymbols; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; -import java.util.Map; import java.util.TimeZone; import com.vaadin.annotations.Theme; @@ -51,6 +50,7 @@ import com.vaadin.ui.components.calendar.event.BasicEventProvider; import com.vaadin.ui.components.calendar.event.CalendarEvent; import com.vaadin.ui.components.calendar.handler.BasicDateClickHandler; import com.vaadin.ui.components.calendar.handler.BasicWeekClickHandler; +import com.vaadin.ui.themes.ValoTheme; /** Calendar component test application */ @Theme("valo-test") @@ -108,7 +108,7 @@ public class CalendarTest extends GridLayout implements View { private Button applyEventButton; - private Mode viewMode = Mode.MONTH; + private Mode viewMode = Mode.WEEK; private BasicEventProvider dataSource; @@ -152,52 +152,11 @@ public class CalendarTest extends GridLayout implements View { setSpacing(true); // handleURLParams(request.getParameterMap()); + testBench = ValoThemeUI.isTestMode(); initContent(); } - private void handleURLParams(Map parameters) { - testBench = parameters.containsKey("testBench") - || parameters.containsKey("?testBench"); - - if (parameters.containsKey("width")) { - calendarWidth = parameters.get("width")[0]; - } - - if (parameters.containsKey("height")) { - calendarHeight = parameters.get("height")[0]; - } - - if (parameters.containsKey("firstDay")) { - firstDay = Integer.parseInt(parameters.get("firstDay")[0]); - } - - if (parameters.containsKey("lastDay")) { - lastDay = Integer.parseInt(parameters.get("lastDay")[0]); - } - - if (parameters.containsKey("firstHour")) { - firstHour = Integer.parseInt(parameters.get("firstHour")[0]); - } - - if (parameters.containsKey("lastHour")) { - lastHour = Integer.parseInt(parameters.get("lastHour")[0]); - } - - if (parameters.containsKey("locale")) { - String localeArray[] = parameters.get("locale")[0].split("_"); - defaultLocale = new Locale(localeArray[0], localeArray[1]); - setLocale(defaultLocale); - } - - if (parameters.containsKey(("secondsResolution"))) { - useSecondResolution = true; - } - - showWeeklyView = parameters.containsKey("weekly"); - - } - public void initContent() { // Set default Locale for this application if (testBench) { @@ -365,6 +324,9 @@ public class CalendarTest extends GridLayout implements View { Alignment.MIDDLE_LEFT); controlPanel.setComponentAlignment(addNewEvent, Alignment.MIDDLE_LEFT); + Label viewCaption = new Label("Calendar"); + viewCaption.setStyleName(ValoTheme.LABEL_H1); + addComponent(viewCaption); addComponent(controlPanel); addComponent(hl); addComponent(calendarComponent); @@ -645,6 +607,11 @@ public class CalendarTest extends GridLayout implements View { calendar.setTime(today); calendarComponent.getInternalCalendar().setTime(today); + // Calendar getStartDate (and getEndDate) has some strange logic which + // returns Monday of the current internal time if no start date has been + // set + calendarComponent.setStartDate(calendarComponent.getStartDate()); + calendarComponent.setEndDate(calendarComponent.getEndDate()); int rollAmount = calendar.get(GregorianCalendar.DAY_OF_MONTH) - 1; calendar.add(GregorianCalendar.DAY_OF_MONTH, -rollAmount); currentMonthsFirstDate = calendar.getTime(); diff --git a/uitest/src/com/vaadin/tests/themes/valo/CommonParts.java b/uitest/src/com/vaadin/tests/themes/valo/CommonParts.java index cd378c3754..52cc43ac28 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/CommonParts.java +++ b/uitest/src/com/vaadin/tests/themes/valo/CommonParts.java @@ -131,9 +131,11 @@ public class CommonParts extends VerticalLayout implements View { spinnerDesc.setCaption("Spinner"); content.addComponent(spinnerDesc); - Label spinner = new Label(); - spinner.addStyleName("spinner"); - content.addComponent(spinner); + if (!ValoThemeUI.isTestMode()) { + Label spinner = new Label(); + spinner.addStyleName("spinner"); + content.addComponent(spinner); + } return p; } diff --git a/uitest/src/com/vaadin/tests/themes/valo/DateFields.java b/uitest/src/com/vaadin/tests/themes/valo/DateFields.java index ae520e07c2..41aa287f9f 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/DateFields.java +++ b/uitest/src/com/vaadin/tests/themes/valo/DateFields.java @@ -46,16 +46,16 @@ public class DateFields extends VerticalLayout implements View { addComponent(row); DateField date = new DateField("Default resolution"); - date.setValue(new Date()); + setDate(date); row.addComponent(date); date = new DateField("Error"); - date.setValue(new Date()); + setDate(date); date.setComponentError(new UserError("Fix it, now!")); row.addComponent(date); date = new DateField("Error, borderless"); - date.setValue(new Date()); + setDate(date); date.setComponentError(new UserError("Fix it, now!")); date.addStyleName("borderless"); row.addComponent(date); @@ -77,110 +77,120 @@ public class DateFields extends VerticalLayout implements View { group.addComponent(today); date = new DateField("Default resolution, explicit size"); - date.setValue(new Date()); + setDate(date); row.addComponent(date); date.setWidth("260px"); date.setHeight("60px"); date = new DateField("Second resolution"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.SECOND); row.addComponent(date); date = new DateField("Minute resolution"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.MINUTE); row.addComponent(date); date = new DateField("Hour resolution"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.HOUR); row.addComponent(date); date = new DateField("Disabled"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.HOUR); date.setEnabled(false); row.addComponent(date); date = new DateField("Day resolution"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.DAY); row.addComponent(date); date = new DateField("Month resolution"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.MONTH); row.addComponent(date); date = new DateField("Year resolution"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.YEAR); row.addComponent(date); date = new DateField("Custom color"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("color1"); row.addComponent(date); date = new DateField("Custom color"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("color2"); row.addComponent(date); date = new DateField("Custom color"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("color3"); row.addComponent(date); date = new DateField("Small"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("small"); row.addComponent(date); date = new DateField("Large"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("large"); row.addComponent(date); date = new DateField("Borderless"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("borderless"); row.addComponent(date); date = new DateField("Week numbers"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.DAY); date.setLocale(new Locale("fi", "fi")); date.setShowISOWeekNumbers(true); row.addComponent(date); date = new DateField("US locale"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.SECOND); date.setLocale(new Locale("en", "US")); row.addComponent(date); date = new DateField("Custom format"); - date.setValue(new Date()); + setDate(date); date.setDateFormat("E dd/MM/yyyy"); row.addComponent(date); date = new InlineDateField("Date picker"); + setDate(date); row.addComponent(date); date = new InlineDateField("Date picker with week numbers"); + setDate(date); date.setLocale(new Locale("fi", "fi")); date.setShowISOWeekNumbers(true); row.addComponent(date); } + private void setDate(DateField date) { + if (ValoThemeUI.isTestMode()) { + date.setValue(new Date(2014 - 1900, 5, 7)); + } else { + date.setValue(new Date()); + } + } + @Override public void enter(ViewChangeEvent event) { // TODO Auto-generated method stub diff --git a/uitest/src/com/vaadin/tests/themes/valo/Forms.java b/uitest/src/com/vaadin/tests/themes/valo/Forms.java index 6f1b8bbf7a..c5b08902be 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/Forms.java +++ b/uitest/src/com/vaadin/tests/themes/valo/Forms.java @@ -47,7 +47,7 @@ public class Forms extends VerticalLayout implements View { setSpacing(true); setMargin(true); - Label title = new Label("Form"); + Label title = new Label("Forms"); title.addStyleName("h1"); addComponent(title); diff --git a/uitest/src/com/vaadin/tests/themes/valo/Sliders.java b/uitest/src/com/vaadin/tests/themes/valo/Sliders.java index 363c698c32..8ed846e39f 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/Sliders.java +++ b/uitest/src/com/vaadin/tests/themes/valo/Sliders.java @@ -158,11 +158,12 @@ public class Sliders extends VerticalLayout implements View { // pb2.setValue(0.6f); row.addComponent(pb2); - ProgressBar pb3 = new ProgressBar(); - pb3.setIndeterminate(true); - pb3.setCaption("Indeterminate"); - row.addComponent(pb3); - + if (!ValoThemeUI.isTestMode()) { + ProgressBar pb3 = new ProgressBar(); + pb3.setIndeterminate(true); + pb3.setCaption("Indeterminate"); + row.addComponent(pb3); + } } float progress = 0; @@ -196,14 +197,21 @@ public class Sliders extends VerticalLayout implements View { @Override public void enter(ViewChangeEvent event) { - getUI().setPollInterval(1000); - update.start(); + if (!ValoThemeUI.isTestMode()) { + getUI().setPollInterval(1000); + update.start(); + } else { + pb.setValue(0.3f); + pb2.setValue(0.6f); + } } @Override public void detach() { - getUI().setPollInterval(-1); - update.interrupt(); + if (!ValoThemeUI.isTestMode()) { + getUI().setPollInterval(-1); + update.interrupt(); + } super.detach(); } diff --git a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java index 5f286989a0..501b5f573b 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java +++ b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java @@ -61,6 +61,8 @@ import com.vaadin.ui.themes.ValoTheme; @PreserveOnRefresh public class ValoThemeUI extends UI { + private boolean testMode = false; + private static LinkedHashMap themeVariants = new LinkedHashMap(); static { themeVariants.put("tests-valo", "Default"); @@ -77,11 +79,17 @@ public class ValoThemeUI extends UI { ComponentContainer viewDisplay = root.getContentContainer(); CssLayout menu = new CssLayout(); CssLayout menuItemsLayout = new CssLayout(); + { + menu.setId("testMenu"); + } private Navigator navigator; private LinkedHashMap menuItems = new LinkedHashMap(); @Override protected void init(VaadinRequest request) { + if (request.getParameter("test") != null) { + testMode = true; + } // Show .v-app-loading valo-menu-badge // try { // Thread.sleep(2000); @@ -159,6 +167,10 @@ public class ValoThemeUI extends UI { } + static boolean isTestMode() { + return ((ValoThemeUI) getCurrent()).testMode; + } + Component buildTestMenu() { CssLayout menu = new CssLayout(); menu.addStyleName("large-icons"); @@ -398,7 +410,7 @@ public class ValoThemeUI extends UI { // ((Hierarchical) container).setChildrenAllowed(id, false); ((Hierarchical) container).setParent(id, i); - for (int k = 1; k < 5; k++) { + for (int k = 1; k < 6; k++) { String id2 = id + " -> " + k; child = container.addItem(id2); child.getItemProperty(CAPTION_PROPERTY).setValue( diff --git a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java new file mode 100644 index 0000000000..fdb2eabeee --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java @@ -0,0 +1,239 @@ +/* + * 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.themes.valo; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.CssLayoutElement; +import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.testbench.elements.TreeElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class ValoThemeUITest extends MultiBrowserTest { + + @Test + public void labels() throws Exception { + openTestURL("test"); + open("Labels"); + compareScreen("labels"); + } + + @Test + public void buttonsLinks() throws Exception { + openTestURL("test"); + open("Buttons & Links", "Buttons"); + compareScreen("buttonsLinks"); + } + + @Test + public void textFields() throws Exception { + openTestURL("test"); + open("Text Fields 123", + "Text Fields"); + compareScreen("textFields"); + } + + @Test + public void common() throws Exception { + openTestURL("test"); + open("Common UI Elements"); + compareScreen("common"); + } + + @Test + public void datefields() throws Exception { + openTestURL("test"); + open("Date Fields"); + // Note that this can look broken in IE9 because of some browser + // rendering issue... The problem seems to be in the customized + // horizontal layout in the test app + compareScreen("datefields"); + } + + @Test + public void comboboxes() throws Exception { + openTestURL("test"); + open("Combo Boxes"); + compareScreen("comboboxes"); + } + + @Test + public void selects() throws Exception { + openTestURL("test"); + open("Selects"); + compareScreen("selects"); + } + + @Test + public void checkboxes() throws Exception { + openTestURL("test"); + open("Check Boxes & Option Groups", "Check Boxes"); + compareScreen("checkboxes"); + } + + @Test + public void sliders() throws Exception { + openTestURL("test"); + open("Sliders & Progress Bars", "Sliders"); + compareScreen("sliders"); + } + + @Test + public void colorpickers() throws Exception { + openTestURL("test"); + open("Color Pickers"); + compareScreen("colorpickers"); + } + + @Test + public void menubars() throws Exception { + openTestURL("test"); + open("Menu Bars"); + compareScreen("menubars"); + } + + @Test + public void trees() throws Exception { + openTestURL("test"); + open("Trees"); + selectTreeNodeByCaption("Quid securi"); + compareScreen("trees"); + } + + private void selectTreeNodeByCaption(String string) { + WebElement e = $(TreeElement.class).first().findElement( + By.xpath("//div[@class='v-tree-node-caption']//span[text()='" + + string + "']")); + e.click(); + } + + @Test + public void tables() throws Exception { + openTestURL("test"); + open("Tables"); + compareScreen("tables"); + } + + @Test + public void dragging() throws Exception { + openTestURL("test"); + open("Drag and Drop", "Dragging Components"); + compareScreen("dragging"); + } + + @Test + public void panels() throws Exception { + openTestURL("test"); + open("Panels", "Panels & Layout panels"); + compareScreen("panels"); + } + + @Test + public void splitpanels() throws Exception { + openTestURL("test"); + open("Split Panels"); + compareScreen("splitpanels"); + } + + @Test + public void tabs() throws Exception { + openTestURL("test"); + open("Tabs 123", "Tabs"); + compareScreen("tabs"); + } + + @Test + public void accordions() throws Exception { + openTestURL("test"); + open("Accordions"); + compareScreen("accordions"); + } + + @Test + public void popupviews() throws Exception { + openTestURL("test"); + open("Popup Views"); + scrollTo(500, 0); + compareScreen("popupviews"); + } + + @Test + public void calendar() throws Exception { + openTestURL("test"); + scrollTo(500, 0); + open("Calendar"); + + compareScreen("calendar"); + } + + @Test + public void forms() throws Exception { + openTestURL("test"); + scrollTo(500, 0); + open("Forms"); + compareScreen("forms"); + } + + private void open(String link) { + open(link, link); + } + + private void open(String link, String caption) { + open(link, caption, 10); + } + + // FIXME: Remove this once click works properly on IE... + private void open(String link, String caption, int tries) { + if (tries <= 0) { + throw new RuntimeException( + "Tried many times but was not able to click the link..."); + } + + $(ButtonElement.class).caption(link).first().click(); + CssLayoutElement content = wrap(CssLayoutElement.class, + findElement(By.className("valo-content"))); + LabelElement captionElem = content.$(LabelElement.class).first(); + if (!captionElem.getText().equals(caption)) { + // IE ... why you fail clicks + System.err.println("Extra click needed on '" + link + + "' on remote " + getDesiredCapabilities() + " " + + getRemoteControlName()); + + open(link, caption, tries - 1); + } + } + + private void scrollTo(int top, int left) { + CssLayoutElement testMenu = $(CssLayoutElement.class).id("testMenu"); + + testBenchElement(testMenu).scroll(top); + testBenchElement(testMenu).scrollLeft(left); + } + + @Override + protected boolean requireWindowFocusForIE() { + return true; + } + + @Override + protected boolean usePersistentHoverForIE() { + return false; + } + +} -- cgit v1.2.3 From ea8374649ba8b3b2d38a49a73eda205faf2f0fe9 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 6 Aug 2014 18:07:00 +0300 Subject: Always use cursor detection for improved test stability Change-Id: I3ac7a8b404da907fbe025b2ab1af03dd7c32813e --- .../vaadin/tests/components/window/ComboboxScrollableWindowTest.java | 2 -- uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindowTest.java b/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindowTest.java index e65a24e907..627efdc5b3 100644 --- a/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindowTest.java +++ b/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindowTest.java @@ -35,8 +35,6 @@ public class ComboboxScrollableWindowTest extends MultiBrowserTest { @Test public void testWindowScrollbars() throws Exception { openTestURL(); - com.vaadin.testbench.Parameters - .setScreenshotComparisonCursorDetection(true); WebElement window = driver.findElement(By.id(WINDOW_ID)); WebElement scrollableElement = window.findElement(By diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 7e22537032..b892fbe4a0 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -115,6 +115,11 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { desiredCapabilities = Browser.FIREFOX.getDesiredCapabilities(); } + static { + com.vaadin.testbench.Parameters + .setScreenshotComparisonCursorDetection(true); + } + /** * Connect to the hub using a remote web driver, set the canvas size and * opens the initial URL as specified by {@link #getTestUrl()} -- cgit v1.2.3 From 8c4ddbb2837c8966551636cf140bba86c9671d1e Mon Sep 17 00:00:00 2001 From: Bogdan Udrescu Date: Thu, 7 Aug 2014 15:31:07 +0300 Subject: TabSheet focus/blur events fixed (#14304) The blur and focus events should be linked with the TabSheet component as a whole. Any click inside the TabSheet should trigger one single focus and any leave the blur. Change-Id: Id24a2fab12aafe6f7aa3a44635e5b9e935a1cfe1 --- WebContent/html-tests/ComponentFocus.html | 16 + client/src/com/vaadin/client/ui/VTabsheet.java | 694 ++++++++++++++++----- .../components/tabsheet/TabKeyboardNavigation.html | 241 ------- .../components/tabsheet/TabKeyboardNavigation.java | 32 +- .../tabsheet/TabKeyboardNavigationTest.java | 188 ++++++ 5 files changed, 767 insertions(+), 404 deletions(-) create mode 100644 WebContent/html-tests/ComponentFocus.html delete mode 100644 uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html create mode 100644 uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationTest.java diff --git a/WebContent/html-tests/ComponentFocus.html b/WebContent/html-tests/ComponentFocus.html new file mode 100644 index 0000000000..0a822520e0 --- /dev/null +++ b/WebContent/html-tests/ComponentFocus.html @@ -0,0 +1,16 @@ + + + + +Insert title here + + + + + + + + + \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index 35fdebf353..a2a6889e15 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.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 @@ -42,9 +42,12 @@ import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.dom.client.HasBlurHandlers; import com.google.gwt.event.dom.client.HasFocusHandlers; import com.google.gwt.event.dom.client.HasKeyDownHandlers; +import com.google.gwt.event.dom.client.HasMouseDownHandlers; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownHandler; +import com.google.gwt.event.dom.client.MouseDownEvent; +import com.google.gwt.event.dom.client.MouseDownHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.regexp.shared.MatchResult; import com.google.gwt.regexp.shared.RegExp; @@ -74,7 +77,9 @@ import com.vaadin.shared.ui.tabsheet.TabsheetServerRpc; import com.vaadin.shared.ui.tabsheet.TabsheetState; public class VTabsheet extends VTabsheetBase implements Focusable, - FocusHandler, BlurHandler, KeyDownHandler, SubPartAware { + SubPartAware, + // TODO: These listeners are due to be removed in 7.3 + FocusHandler, BlurHandler, KeyDownHandler { private static class VCloseEvent { private Tab tab; @@ -95,10 +100,10 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Representation of a single "tab" shown in the TabBar - * + * */ public static class Tab extends SimplePanel implements HasFocusHandlers, - HasBlurHandlers, HasKeyDownHandlers { + HasBlurHandlers, HasMouseDownHandlers, HasKeyDownHandlers { private static final String TD_CLASSNAME = CLASSNAME + "-tabitemcell"; private static final String TD_FIRST_CLASSNAME = TD_CLASSNAME + "-first"; @@ -152,10 +157,6 @@ public class VTabsheet extends VTabsheetBase implements Focusable, Roles.getTabRole().setAriaLabelledbyProperty(getElement(), Id.of(tabCaption.getElement())); - - addFocusHandler(getTabsheet()); - addBlurHandler(getTabsheet()); - addKeyDownHandler(getTabsheet()); } public boolean isHiddenOnServer() { @@ -197,7 +198,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Toggles the style names for the Tab - * + * * @param selected * true if the Tab is selected * @param first @@ -281,6 +282,11 @@ public class VTabsheet extends VTabsheetBase implements Focusable, return addDomHandler(handler, BlurEvent.getType()); } + @Override + public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) { + return addDomHandler(handler, MouseDownEvent.getType()); + } + @Override public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) { return addDomHandler(handler, KeyDownEvent.getType()); @@ -420,8 +426,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, } - static class TabBar extends ComplexPanel implements ClickHandler, - VCloseHandler { + static class TabBar extends ComplexPanel implements VCloseHandler { private final Element tr = DOM.createTR(); @@ -443,6 +448,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, setStyleName(spacerTd, CLASSNAME + "-spacertd"); DOM.appendChild(tr, spacerTd); DOM.appendChild(spacerTd, DOM.createDiv()); + setElement(el); } @@ -460,10 +466,20 @@ public class VTabsheet extends VTabsheetBase implements Focusable, return DOM.asOld(tr); } + /** + * Gets the number of tabs from the tab bar. + * + * @return the number of tabs from the tab bar. + */ public int getTabCount() { return getWidgetCount(); } + /** + * Adds a tab to the tab bar. + * + * @return the added tab. + */ public Tab addTab() { Tab t = new Tab(this); int tabIndex = getTabCount(); @@ -476,31 +492,18 @@ public class VTabsheet extends VTabsheetBase implements Focusable, t.setStyleNames(false, true); } - t.addClickHandler(this); + getTabsheet().selectionHandler.registerTab(t); + t.setCloseHandler(this); return t; } - @Override - public void onClick(ClickEvent event) { - TabCaption caption = (TabCaption) event.getSource(); - Element targetElement = event.getNativeEvent().getEventTarget() - .cast(); - // the tab should not be focused if the close button was clicked - if (targetElement == caption.getCloseButton()) { - return; - } - - int index = getWidgetIndex(caption.getParent()); - - navigateTab(getTabsheet().focusedTabIndex, index); - getTabsheet().focusedTabIndex = index; - getTabsheet().focusedTab = getTab(index); - getTabsheet().focus(); - getTabsheet().loadTabSheet(index); - } - + /** + * Gets the tab sheet instance where the tab bar is attached to. + * + * @return the tab sheet instance where the tab bar is attached to. + */ public VTabsheet getTabsheet() { return tabsheet; } @@ -538,7 +541,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, getTab(tabsheet.activeTabIndex).recalculateCaptionWidth(); } - public void navigateTab(int fromIndex, int toIndex) { + public Tab navigateTab(int fromIndex, int toIndex) { Tab newNavigated = getTab(toIndex); if (newNavigated == null) { throw new IllegalArgumentException( @@ -553,6 +556,8 @@ public class VTabsheet extends VTabsheetBase implements Focusable, oldNavigated.setStyleNames(oldNavigated.equals(selected), isFirstVisibleTab(fromIndex), false); } + + return newNavigated; } public void removeTab(int i) { @@ -580,7 +585,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Returns the index of the first visible tab - * + * * @return */ private int getFirstVisibleTab() { @@ -589,7 +594,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Find the next visible tab. Returns -1 if none is found. - * + * * @param i * @return */ @@ -608,7 +613,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Find the previous visible tab. Returns -1 if none is found. - * + * * @param i * @return */ @@ -663,7 +668,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** For internal use only. May be removed or replaced in the future. */ // tabbar and 'scroller' container public final Element tabs; - Tab focusedTab; + /** * The tabindex property (position in the browser's focus cycle.) Named like * this to avoid confusion with activeTabIndex. @@ -697,9 +702,6 @@ public class VTabsheet extends VTabsheetBase implements Focusable, private String currentStyle; - /** For internal use only. May be removed or replaced in the future. */ - private int focusedTabIndex = 0; - /** * @return Whether the tab could be selected or not. */ @@ -720,11 +722,13 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Load the content of a tab of the provided index. - * + * * @param index * of the tab to load + * + * @return true if the specified sheet gets loaded, otherwise false. */ - public void loadTabSheet(int tabIndex) { + public boolean loadTabSheet(int tabIndex) { if (activeTabIndex != tabIndex && canSelectTab(tabIndex)) { tb.selectTab(tabIndex); @@ -741,12 +745,16 @@ public class VTabsheet extends VTabsheetBase implements Focusable, waitingForResponse = true; tb.getTab(tabIndex).focus(); // move keyboard focus to active tab + + return true; } + + return false; } /** * Returns the currently displayed widget in the tab panel. - * + * * @since 7.2 * @return currently displayed content widget */ @@ -756,7 +764,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Returns the client to server RPC proxy for the tabsheet. - * + * * @since 7.2 * @return RPC proxy */ @@ -766,10 +774,10 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * For internal use only. - * + * * Avoid using this method directly and use appropriate superclass methods * where applicable. - * + * * @deprecated since 7.2 - use more specific methods instead (getRpcProxy(), * getConnectorForWidget(Widget) etc.) * @return ApplicationConnection @@ -799,9 +807,6 @@ public class VTabsheet extends VTabsheetBase implements Focusable, public VTabsheet() { super(CLASSNAME); - addHandler(this, FocusEvent.getType()); - addHandler(this, BlurEvent.getType()); - // Tab scrolling getElement().getStyle().setOverflow(Overflow.HIDDEN); tabs = DOM.createDiv(); @@ -812,18 +817,21 @@ public class VTabsheet extends VTabsheetBase implements Focusable, Roles.getTablistRole().setAriaHiddenState(scroller, true); DOM.setElementProperty(scroller, "className", SCROLLER_CLASSNAME); + scrollerPrev = DOM.createButton(); scrollerPrev.setTabIndex(-1); DOM.setElementProperty(scrollerPrev, "className", SCROLLER_CLASSNAME + "Prev"); Roles.getTablistRole().setAriaHiddenState(scrollerPrev, true); - DOM.sinkEvents(scrollerPrev, Event.ONCLICK); + DOM.sinkEvents(scrollerPrev, Event.ONCLICK | Event.ONMOUSEDOWN); + scrollerNext = DOM.createButton(); scrollerNext.setTabIndex(-1); DOM.setElementProperty(scrollerNext, "className", SCROLLER_CLASSNAME + "Next"); Roles.getTablistRole().setAriaHiddenState(scrollerNext, true); - DOM.sinkEvents(scrollerNext, Event.ONCLICK); + DOM.sinkEvents(scrollerNext, Event.ONCLICK | Event.ONMOUSEDOWN); + DOM.appendChild(getElement(), tabs); // Tabs @@ -856,35 +864,68 @@ public class VTabsheet extends VTabsheetBase implements Focusable, @Override public void onBrowserEvent(Event event) { + com.google.gwt.dom.client.Element eventTarget = DOM + .eventGetTarget(event); + if (event.getTypeInt() == Event.ONCLICK) { + // Tab scrolling - if (isScrolledTabs() && DOM.eventGetTarget(event) == scrollerPrev) { - int newFirstIndex = tb.scrollLeft(scrollerIndex); - if (newFirstIndex != -1) { - scrollerIndex = newFirstIndex; - updateTabScroller(); - } - event.stopPropagation(); - return; - } else if (isClippedTabs() - && DOM.eventGetTarget(event) == scrollerNext) { - int newFirstIndex = tb.scrollRight(scrollerIndex); + if (eventTarget == scrollerPrev || eventTarget == scrollerNext) { + scrollAccordingToScrollTarget(eventTarget); - if (newFirstIndex != -1) { - scrollerIndex = newFirstIndex; - updateTabScroller(); - } event.stopPropagation(); + } + + } else if (event.getTypeInt() == Event.ONMOUSEDOWN) { + + if (eventTarget == scrollerPrev || eventTarget == scrollerNext) { + // In case the focus was previously on a Tab, we need to cancel + // the upcoming blur on the Tab which will follow this mouse + // down event. + focusBlurManager.cancelNextBlurSchedule(); + return; } } + super.onBrowserEvent(event); } + /* + * Scroll the tab bar according to the last scrollTarget (the scroll button + * pressed). + */ + private void scrollAccordingToScrollTarget( + com.google.gwt.dom.client.Element scrollTarget) { + if (scrollTarget == null) { + return; + } + + int newFirstIndex = -1; + + // Scroll left. + if (isScrolledTabs() && scrollTarget == scrollerPrev) { + newFirstIndex = tb.scrollLeft(scrollerIndex); + + // Scroll right. + } else if (isClippedTabs() && scrollTarget == scrollerNext) { + newFirstIndex = tb.scrollRight(scrollerIndex); + } + + if (newFirstIndex != -1) { + scrollerIndex = newFirstIndex; + updateTabScroller(); + } + + // For this to work well, make sure the method gets called only from + // user events. + selectionHandler.focusTabAtIndex(scrollerIndex); + } + /** * Checks if the tab with the selected index has been scrolled out of the * view (on the left side). - * + * * @param index * @return */ @@ -1016,7 +1057,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Renders the widget content for a tab sheet. - * + * * @param newWidget */ public void renderContent(Widget newWidget) { @@ -1239,69 +1280,444 @@ public class VTabsheet extends VTabsheetBase implements Focusable, } @Override - public void onBlur(BlurEvent event) { - getVTooltip().hideTooltip(); + public void focus() { + getActiveTab().focus(); + } - if (focusedTab != null && focusedTab == event.getSource()) { - focusedTab.removeAssistiveDescription(); - focusedTab = null; - if (connector.hasEventListener(EventId.BLUR)) { - connector.getRpcProxy(FocusAndBlurServerRpc.class).blur(); - } - } + public void blur() { + getActiveTab().blur(); } - @Override - public void onFocus(FocusEvent event) { - if (focusedTab == null && event.getSource() instanceof Tab) { - focusedTab = (Tab) event.getSource(); + /* + * Gets the active tab. + */ + private Tab getActiveTab() { + return tb.getTab(activeTabIndex); + } + + /* + * The focus and blur manager instance. + */ + private FocusBlurManager focusBlurManager = new FocusBlurManager(); + + /* + * Manage the TabSheet component blur event. + */ + private class FocusBlurManager implements FocusedTabProvider { + + // The real tab with focus on it. If the focus goes to another element + // in the page this will be null. + private Tab focusedTab; + + @Override + public Tab getFocusedTab() { + return focusedTab; + } + + @Override + public void setFocusedTab(Tab focusedTab) { + this.focusedTab = focusedTab; + } + + /** + * Process the focus event no matter where it occurs on the tab bar. + * We've added this method + * + * @since + * @param newFocusTab + * the new focused tab. + * @see #blur(Tab) + */ + public void focus(Tab newFocusTab) { + if (connector.hasEventListener(EventId.FOCUS)) { - connector.getRpcProxy(FocusAndBlurServerRpc.class).focus(); + + // Send the focus event only first time when we focus on any + // tab. The focused tab will be reseted on the last blur. + if (focusedTab == null) { + connector.getRpcProxy(FocusAndBlurServerRpc.class).focus(); + } } + removeBlurSchedule(); + + setFocusedTab(newFocusTab); + if (focusedTab.hasTooltip()) { focusedTab.setAssistiveDescription(getVTooltip().getUniqueId()); getVTooltip().showAssistive(focusedTab.getTooltipInfo()); } + + } + + /** + * Process the blur event for the current focusedTab. + * + * @param blurSource + * the source of the blur. + * + * @see #focus(Tab) + */ + public void blur(Tab blurSource) { + if (focusedTab != null && focusedTab == blurSource) { + + if (connector.hasEventListener(EventId.BLUR)) { + scheduleBlur(focusedTab); + } + } + } + + /* + * The last blur command to be executed. + */ + private BlurCommand blurCommand; + + /** + * Schedule a new blur event for a deferred execution. + */ + public void scheduleBlur(Tab blurSource) { + + if (cancelNextBlurSchedule) { + + // This will set the stopNextBlurCommand back to false as well. + removeBlurSchedule(); + + // Leave this though to make things clear for the developer. + cancelNextBlurSchedule = false; + return; + } + + removeBlurSchedule(); + + blurCommand = new BlurCommand(blurSource, this); + blurCommand.scheduleDeferred(); + } + + /** + * Remove the last blur command from execution. + */ + public void removeBlurSchedule() { + if (blurCommand != null) { + blurCommand.stopSchedule(); + blurCommand = null; + } + + // Maybe this is not the best place to reset this, but we really + // want to make sure it'll reset at any time when something + // interact with the blur manager. Might change it later. + cancelNextBlurSchedule = false; + } + + /** + * Cancel the next possible scheduled execution. + */ + public void cancelNextBlurSchedule() { + + // Make sure there's still no other command to be executed. + removeBlurSchedule(); + + cancelNextBlurSchedule = true; + } + + // Stupid workaround... + private boolean cancelNextBlurSchedule = false; + + } + + /* + * Wraps the focused tab. + */ + private interface FocusedTabProvider { + + /** + * Gets the focused Tab. + * + * @return the focused Tab. + */ + Tab getFocusedTab(); + + /** + * Sets the focused Tab. + * + * @param focusedTab + * the focused Tab. + */ + void setFocusedTab(Tab focusedTab); + + } + + /* + * Execute the final blur command. + */ + private class BlurCommand implements Command { + + /* + * The blur source. + */ + private Tab blurSource; + + /* + * Provide the current focused Tab. + */ + private FocusedTabProvider focusedTabProvider; + + /** + * Create the blur command using the blur source. + * + * @param blurSource + * the source. + * @param focusedTabProvider + * provides the current focused tab. + */ + public BlurCommand(Tab blurSource, FocusedTabProvider focusedTabProvider) { + this.blurSource = blurSource; + this.focusedTabProvider = focusedTabProvider; + } + + /** + * Stop the command from being executed. + * + * @since + */ + public void stopSchedule() { + blurSource = null; + } + + /** + * Schedule the command for a deferred execution. + * + * @since + */ + public void scheduleDeferred() { + Scheduler.get().scheduleDeferred(this); + } + + @Override + public void execute() { + + Tab focusedTab = focusedTabProvider.getFocusedTab(); + + if (blurSource == null) { + return; + } + + // The focus didn't change since this blur triggered, so + // the new focused element is not a tab. + if (focusedTab == blurSource) { + + // We're certain there's no focus anymore. + focusedTab.removeAssistiveDescription(); + focusedTabProvider.setFocusedTab(null); + + connector.getRpcProxy(FocusAndBlurServerRpc.class).blur(); + } + + // Call this to set it to null and be consistent. + focusBlurManager.removeBlurSchedule(); } } @Override - public void focus() { - tb.getTab(activeTabIndex).focus(); + public void onBlur(BlurEvent event) { + selectionHandler.onBlur(event); } - public void blur() { - tb.getTab(activeTabIndex).blur(); + @Override + public void onFocus(FocusEvent event) { + selectionHandler.onFocus(event); } @Override public void onKeyDown(KeyDownEvent event) { - if (event.getSource() instanceof Tab) { - int keycode = event.getNativeEvent().getKeyCode(); - - // Scroll throw the tabs. - if (!event.isAnyModifierKeyDown()) { - if (keycode == getPreviousTabKey()) { - selectPreviousTab(); - event.stopPropagation(); - } else if (keycode == getNextTabKey()) { - selectNextTab(); - event.stopPropagation(); - } else if (keycode == getCloseTabKey()) { - Tab tab = tb.getTab(activeTabIndex); - if (tab.isClosable()) { - tab.onClose(); - } - } else if (keycode == getSelectTabKey()) { - loadTabSheet(focusedTabIndex); + selectionHandler.onKeyDown(event); + } + + /* + * The tabs selection handler instance. + */ + private final TabSelectionHandler selectionHandler = new TabSelectionHandler(); + + /* + * Handle the events for selecting the tabs. + */ + private class TabSelectionHandler implements FocusHandler, BlurHandler, + KeyDownHandler, ClickHandler, MouseDownHandler { + + /** For internal use only. May be removed or replaced in the future. */ + // The current visible focused index. + private int focusedTabIndex = 0; + + /** + * Register the tab to the selection handler. + * + * @param tab + * the tab to register. + */ + public void registerTab(Tab tab) { + + // TODO: change VTabsheet.this to this in 7.3 + tab.addBlurHandler(VTabsheet.this); + tab.addFocusHandler(VTabsheet.this); + tab.addKeyDownHandler(VTabsheet.this); + + tab.addClickHandler(this); + tab.addMouseDownHandler(this); + } + + @Override + public void onBlur(final BlurEvent event) { + + getVTooltip().hideTooltip(); + + Object blurSource = event.getSource(); + + if (blurSource instanceof Tab) { + focusBlurManager.blur((Tab) blurSource); + } + } + + @Override + public void onFocus(FocusEvent event) { + + if (event.getSource() instanceof Tab) { + focusBlurManager.focus((Tab) event.getSource()); + } + } + + @Override + public void onClick(ClickEvent event) { + + // IE doesn't trigger focus when click, so we need to make sure + // the previous blur deferred command will get killed. + focusBlurManager.removeBlurSchedule(); + + TabCaption caption = (TabCaption) event.getSource(); + Element targetElement = event.getNativeEvent().getEventTarget() + .cast(); + // the tab should not be focused if the close button was clicked + if (targetElement == caption.getCloseButton()) { + return; + } + + int index = tb.getWidgetIndex(caption.getParent()); + + tb.navigateTab(focusedTabIndex, index); - // Prevent the page from scrolling when hitting space - // (select key) to select the current tab. - event.preventDefault(); + focusedTabIndex = index; + + if (!loadTabSheet(index)) { + + // This needs to be called at the end, as the activeTabIndex + // is set in the loadTabSheet. + focus(); + } + } + + @Override + public void onMouseDown(MouseDownEvent event) { + + if (event.getSource() instanceof Tab) { + + // IE doesn't trigger focus when click, so we need to make sure + // the + // next blur deferred command will get killed. + focusBlurManager.cancelNextBlurSchedule(); + } + } + + @Override + public void onKeyDown(KeyDownEvent event) { + if (event.getSource() instanceof Tab) { + int keycode = event.getNativeEvent().getKeyCode(); + + if (!event.isAnyModifierKeyDown()) { + if (keycode == getPreviousTabKey()) { + selectPreviousTab(); + event.stopPropagation(); + + } else if (keycode == getNextTabKey()) { + selectNextTab(); + event.stopPropagation(); + + } else if (keycode == getCloseTabKey()) { + Tab tab = tb.getTab(activeTabIndex); + if (tab.isClosable()) { + tab.onClose(); + } + + } else if (keycode == getSelectTabKey()) { + loadTabSheet(focusedTabIndex); + + // Prevent the page from scrolling when hitting space + // (select key) to select the current tab. + event.preventDefault(); + } } } } + + /* + * Left arrow key selection. + */ + private void selectPreviousTab() { + int newTabIndex = focusedTabIndex; + // Find the previous visible and enabled tab if any. + do { + newTabIndex--; + } while (newTabIndex >= 0 && !canSelectTab(newTabIndex)); + + if (newTabIndex >= 0) { + keySelectTab(newTabIndex); + } + } + + /* + * Right arrow key selection. + */ + private void selectNextTab() { + int newTabIndex = focusedTabIndex; + // Find the next visible and enabled tab if any. + do { + newTabIndex++; + } while (newTabIndex < getTabCount() && !canSelectTab(newTabIndex)); + + if (newTabIndex < getTabCount()) { + keySelectTab(newTabIndex); + } + } + + /* + * Select the specified tab using left/right key. + */ + private void keySelectTab(int newTabIndex) { + Tab tab = tb.getTab(newTabIndex); + if (tab == null) { + return; + } + + // Focus the tab, otherwise the selected one will loose focus and + // TabSheet will get blurred. + focusTabAtIndex(newTabIndex); + + tb.navigateTab(focusedTabIndex, newTabIndex); + + focusedTabIndex = newTabIndex; + } + + /** + * Focus the specified tab. Make sure to call this only from user + * events, otherwise will break things. + * + * @param tabIndex + * the index of the tab to set. + */ + void focusTabAtIndex(int tabIndex) { + Tab tabToFocus = tb.getTab(tabIndex); + if (tabToFocus != null) { + tabToFocus.focus(); + } + } + } /** @@ -1341,66 +1757,32 @@ public class VTabsheet extends VTabsheetBase implements Focusable, return KeyCodes.KEY_DELETE; } - private void selectPreviousTab() { - int newTabIndex = focusedTabIndex; - // Find the previous visible and enabled tab if any. - do { - newTabIndex--; - } while (newTabIndex >= 0 && !canSelectTab(newTabIndex)); - - if (newTabIndex >= 0) { - tb.navigateTab(focusedTabIndex, newTabIndex); - focusedTabIndex = newTabIndex; - - // If this TabSheet already has focus, set the new selected tab - // as focused. - if (focusedTab != null) { - focusedTab = tb.getTab(focusedTabIndex); - focusedTab.focus(); - } - } - } - - private void selectNextTab() { - int newTabIndex = focusedTabIndex; - // Find the next visible and enabled tab if any. - do { - newTabIndex++; - } while (newTabIndex < getTabCount() && !canSelectTab(newTabIndex)); - - if (newTabIndex < getTabCount()) { + private void scrollIntoView(Tab tab) { - tb.navigateTab(focusedTabIndex, newTabIndex); - focusedTabIndex = newTabIndex; + if (!tab.isHiddenOnServer()) { - // If this TabSheet already has focus, set the new selected tab - // as focused. - if (focusedTab != null) { - focusedTab = tb.getTab(focusedTabIndex); - focusedTab.focus(); - } - } - } + // Check for visibility first as clipped tabs to the right are + // always visible. + // On IE8 a tab with false visibility would have the bounds of the + // full TabBar. + if (!tab.isVisible()) { + while (!tab.isVisible()) { + scrollerIndex = tb.scrollLeft(scrollerIndex); + } + updateTabScroller(); - private void scrollIntoView(Tab tab) { - if (!tab.isHiddenOnServer()) { - if (isClipped(tab)) { + } else if (isClipped(tab)) { while (isClipped(tab) && scrollerIndex != -1) { scrollerIndex = tb.scrollRight(scrollerIndex); } updateTabScroller(); - } else if (!tab.isVisible()) { - while (!tab.isVisible()) { - scrollerIndex = tb.scrollLeft(scrollerIndex); - } - updateTabScroller(); } } } /** * Makes tab bar visible. - * + * * @since 7.2 */ public void showTabs() { @@ -1411,7 +1793,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, /** * Makes tab bar invisible. - * + * * @since 7.2 */ public void hideTabs() { diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html b/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html deleted file mode 100644 index 825988173a..0000000000 --- a/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html +++ /dev/null @@ -1,241 +0,0 @@ - - - - - -TabKeyboardNavigation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TabKeyboardNavigation
open/run/TabKeyboardNavigation?restartApplication
mouseClickvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]9,8
pressSpecialKeyvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]right
pause10001000
assertTextvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[1]/ChildComponentContainer[0]/VLabel[0]Tab 1
pressSpecialKeyvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]space
assertTextvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[1]/ChildComponentContainer[0]/VLabel[0]Tab 2
screenCapturetab2
pressSpecialKeyvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]right
pressSpecialKeyvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]right
pause10001000
assertTextvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[3]/ChildComponentContainer[0]/VLabel[0]Tab 2
pressSpecialKeyvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]space
assertTextvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[3]/ChildComponentContainer[0]/VLabel[0]Tab 5
screenCaptureskip-disabled-to-tab5
clickvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
pressSpecialKeyvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]right
pause10001000
assertTextvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[4]/ChildComponentContainer[0]/VLabel[0]Tab 5
pressSpecialKeyvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]space
assertTextvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[4]/ChildComponentContainer[0]/VLabel[0]Tab 6
clickvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
mouseClickvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[8]/domChild[0]/domChild[0]/domChild[0]18,10
pressSpecialKeyvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[8]right
pressSpecialKeyvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[9]right
pressSpecialKeyvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[10]right
pause10001000
assertTextvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[8]/ChildComponentContainer[0]/VLabel[0]Tab 9
pressSpecialKeyvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[10]space
assertTextvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[8]/ChildComponentContainer[0]/VLabel[0]Tab 12
screenCapturescrolled-right-to-tab-12
mouseClickvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[4]/domChild[0]/domChild[0]/domChild[0]11,2
pressSpecialKeyvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[4]left
pressSpecialKeyvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]left
pressSpecialKeyvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]left
pause10001000
assertTextvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]Tab 5
pressSpecialKeyvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]space
assertTextvaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]Tab 1
screenCapturescrolled-left-to-tab-1
- - diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java index ba737f1df8..620f04fe60 100644 --- a/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java @@ -6,7 +6,8 @@ import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; -import com.vaadin.tests.components.TestBase; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; @@ -19,7 +20,16 @@ import com.vaadin.ui.TabSheet.Tab; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; -public class TabKeyboardNavigation extends TestBase { +/** + * Test if the click and key tab selection in a tabsheet generate the correct + * focus/blur events. + * + * The solution was broken in ticket (#14304) + * + * @since + * @author Vaadin Ltd + */ +public class TabKeyboardNavigation extends AbstractTestUI { int index = 1; ArrayList tabs = new ArrayList(); @@ -27,18 +37,18 @@ public class TabKeyboardNavigation extends TestBase { Log focusblur = new Log(10); @Override - protected void setup() { + protected void setup(VaadinRequest request) { ts.setWidth("500px"); ts.setHeight("500px"); - ts.addListener(new FocusListener() { + ts.addFocusListener(new FocusListener() { @Override public void focus(FocusEvent event) { focusblur.log("Tabsheet focused!"); } }); - ts.addListener(new BlurListener() { + ts.addBlurListener(new BlurListener() { @Override public void blur(BlurEvent event) { focusblur.log("Tabsheet blurred!"); @@ -74,7 +84,7 @@ public class TabKeyboardNavigation extends TestBase { } @Override - protected String getDescription() { + protected String getTestDescription() { return "The tab bar should be focusable and arrow keys should switch tabs. The del key should close a tab if closable."; } @@ -83,10 +93,18 @@ public class TabKeyboardNavigation extends TestBase { return 5100; } + public final static String LABEL_ID = "sheetLabel"; + + public final static String labelID(int index) { + return LABEL_ID + index; + } + private Tab addTab() { Layout content = new VerticalLayout(); tabs.add(content); - content.addComponent(new Label("Tab " + index)); + Label label = new Label("Tab " + index); + label.setId(labelID(index)); + content.addComponent(label); content.addComponent(new TextField()); Tab tab = ts.addTab(content, "Tab " + index, null); if (index == 2) { diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationTest.java new file mode 100644 index 0000000000..65307f9492 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationTest.java @@ -0,0 +1,188 @@ +/* + * 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.tabsheet; + +import java.io.IOException; + +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.testbench.TestBenchElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Add TB3 test as the TB2 one failed on keyboard events. + * + * @since + * @author Vaadin Ltd + */ +public class TabKeyboardNavigationTest extends MultiBrowserTest { + + @Test + public void testFocus() throws InterruptedException, IOException { + openTestURL(); + + click(1); + sendKeys(1, Keys.ARROW_RIGHT); + + assertSheet(1); + sendKeys(2, Keys.SPACE); + assertSheet(2); + compareScreen("tab2"); + + sendKeys(2, Keys.ARROW_RIGHT); + sendKeys(3, Keys.ARROW_RIGHT); + assertSheet(2); + + sendKeys(5, Keys.SPACE); + assertSheet(5); + compareScreen("skip-disabled-to-tab5"); + + TestBenchElement addTabButton = (TestBenchElement) getDriver() + .findElements(By.className("v-button")).get(0); + + click(addTabButton); + + click(5); + sendKeys(5, Keys.ARROW_RIGHT); + assertSheet(5); + + sendKeys(6, Keys.SPACE); + assertSheet(6); + + click(addTabButton); + click(addTabButton); + click(addTabButton); + click(addTabButton); + click(addTabButton); + click(addTabButton); + + click(8); + compareScreen("click-tab-8"); + + sendKeys(8, Keys.ARROW_RIGHT); + sendKeys(9, Keys.SPACE); + click(9); + compareScreen("tab-9"); + + sendKeys(9, Keys.ARROW_RIGHT); + Thread.sleep(DELAY); + + sendKeys(10, Keys.ARROW_RIGHT); + + // Here PhantomJS used to fail. Or when accessing tab2. The fix was to + // call the elem.click(x, y) using the (x, y) position instead of the + // elem.click() without any arguments. + sendKeys(11, Keys.ARROW_RIGHT); + + assertSheet(9); + sendKeys(12, Keys.SPACE); + assertSheet(12); + compareScreen("scrolled-right-to-tab-12"); + + click(5); + + sendKeys(5, Keys.ARROW_LEFT); + + // Here IE8 used to fail. A hidden
in IE8 would have the bounds of + // it's parent, and when trying to see in which direction to scroll + // (left or right) to make the key selected tab visible, the + // VTabSheet.scrollIntoView(Tab) used to check first whether the tab + // isClipped. On IE8 this will always return true for both hidden tabs + // on the left and clipped tabs on the right. So instead of going to + // left, it'll search all the way to the right. + sendKeys(3, Keys.ARROW_LEFT); + sendKeys(2, Keys.ARROW_LEFT); + assertSheet(5); + + sendKeys(1, Keys.SPACE); + assertSheet(1); + compareScreen("scrolled-left-to-tab-1"); + } + + /* + * Press key on the element. + */ + private void sendKeys(int tabIndex, Keys key) throws InterruptedException { + sendKeys(tab(tabIndex), key); + } + + /* + * Press key on the element. + */ + private void sendKeys(TestBenchElement element, Keys key) + throws InterruptedException { + + element.sendKeys(key); + if (DELAY > 0) { + sleep(DELAY); + } + } + + /* + * Click on the element. + */ + private void click(int tabIndex) throws InterruptedException { + click(tab(tabIndex)); + } + + /* + * Click on the element. + */ + private void click(TestBenchElement element) throws InterruptedException { + + element.click(10, 10); + if (DELAY > 0) { + sleep(DELAY); + } + } + + /* + * Delay for PhantomJS. + */ + private final static int DELAY = 10; + + private void assertSheet(int index) { + String labelCaption = "Tab " + index; + + By id = By.id(TabKeyboardNavigation.labelID(index)); + WebElement labelElement = getDriver().findElement(id); + + waitForElementPresent(id); + + Assert.assertEquals(labelCaption, labelCaption, labelElement.getText()); + } + + /* + * Provide the tab at specified index. + */ + private TestBenchElement tab(int index) { + By by = By.className("v-tabsheet-tabitemcell"); + + TestBenchElement element = (TestBenchElement) getDriver().findElements( + by).get(index - 1); + + String expected = "Tab " + index; + Assert.assertEquals(expected, + element.getText().substring(0, expected.length())); + + return element; + } + +} -- cgit v1.2.3 From 358583738aaf0def7b827e9fbe042e008dbdf8cd Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Thu, 24 Jul 2014 18:06:16 +0300 Subject: Upgraded TestTooSmallSubwindowSize from TB2 (#14292) Change-Id: I351e94c6827e4585ddeb0060251f9ba7c5c55df4 --- .../window/TestTooSmallSubwindowSize.html | 32 ------ .../window/TestTooSmallSubwindowSize.java | 113 +++++++++++++++++++-- .../window/TestTooSmallSubwindowSizeTest.java | 38 +++++++ 3 files changed, 142 insertions(+), 41 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/window/TestTooSmallSubwindowSize.html create mode 100644 uitest/src/com/vaadin/tests/components/window/TestTooSmallSubwindowSizeTest.java diff --git a/uitest/src/com/vaadin/tests/components/window/TestTooSmallSubwindowSize.html b/uitest/src/com/vaadin/tests/components/window/TestTooSmallSubwindowSize.html deleted file mode 100644 index f926696d63..0000000000 --- a/uitest/src/com/vaadin/tests/components/window/TestTooSmallSubwindowSize.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - -TestTooSmallSubwindowSize - - - - - - - - - - - - - - - - - - - - - - -
TestTooSmallSubwindowSize
open/run/com.vaadin.tests.components.window.TestTooSmallSubwindowSize
waitForVaadin
screenCapture
- - diff --git a/uitest/src/com/vaadin/tests/components/window/TestTooSmallSubwindowSize.java b/uitest/src/com/vaadin/tests/components/window/TestTooSmallSubwindowSize.java index 46845748a3..669774f715 100644 --- a/uitest/src/com/vaadin/tests/components/window/TestTooSmallSubwindowSize.java +++ b/uitest/src/com/vaadin/tests/components/window/TestTooSmallSubwindowSize.java @@ -1,15 +1,22 @@ package com.vaadin.tests.components.window; -import com.vaadin.tests.components.TestBase; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -public class TestTooSmallSubwindowSize extends TestBase { +/** + * Tests that the styles work correctly in tiny subwindows that have more + * content than can fit. + * + * @author Vaadin Ltd + */ +public class TestTooSmallSubwindowSize extends AbstractTestUI { @Override - protected String getDescription() { - return "The size of the subwindow (outer size) is set to 60x60 pixels. Minimum size for the content area is 150x100, which means the window and shadow should be around 155x155 and the content area 150x100. The decoration at the lower left corner of the window must not be missing either."; + protected String getTestDescription() { + return "The size of the subwindows (outer size) is set to 60x60 pixels. Make sure the shadows fits the windows instead of the contents. The decorations at the lower right corners of the resizable windows must not be missing either."; } @Override @@ -18,7 +25,14 @@ public class TestTooSmallSubwindowSize extends TestBase { } @Override - protected void setup() { + protected void setup(VaadinRequest request) { + getUI().addWindow(createNonResizableWindow()); + getUI().addWindow(createNonResizableWindowWithHorizontalScrollbar()); + getUI().addWindow(createResizableWindow()); + getUI().addWindow(createResizableWindowWithHorizontalScrollbar()); + } + + private Window createNonResizableWindow() { VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); Window w = new Window("Scroll", layout); @@ -35,13 +49,94 @@ public class TestTooSmallSubwindowSize extends TestBase { w.setPositionY(100); // Set window size - w.setWidth(60, Window.UNITS_PIXELS); - w.setHeight(60, Window.UNITS_PIXELS); + w.setWidth(60, Unit.PIXELS); + w.setHeight(60, Unit.PIXELS); + + // Disable resizing + w.setResizable(false); + + return w; + } + + private Window createNonResizableWindowWithHorizontalScrollbar() { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + Window w = new Window("Scroll", layout); + Label desc = new Label( + "This is a new child window with a preset" + + " width, height and position. Resizing has been" + + " disabled for this window. Additionally, this text label" + + " is intentionally too large to fit the window. You could" + + " use the scrollbars to view different parts of the window content," + + " except it's too small for that either."); + // disable wrapping + desc.setSizeUndefined(); + layout.addComponent(desc); + + // Set window position + w.setPositionX(200); + w.setPositionY(100); + + // Set window size + w.setWidth(60, Unit.PIXELS); + w.setHeight(60, Unit.PIXELS); // Disable resizing - w.setResizable(true); + w.setResizable(false); + + return w; + } + + private Window createResizableWindow() { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + Window w = new Window("Resize", layout); + Label desc = new Label( + "This is a new child window with a preset" + + " width, height and position. Resizing has not been" + + " disabled for this window. Additionally, this text label" + + " is intentionally too large to fit the window. You can resize or" + + " use the scrollbars to view different parts of the window content."); + layout.addComponent(desc); + + // Set window position + w.setPositionX(300); + w.setPositionY(100); + + // Set window size + w.setWidth(60, Unit.PIXELS); + w.setHeight(60, Unit.PIXELS); + + // Don't disable resizing + + return w; + } + + private Window createResizableWindowWithHorizontalScrollbar() { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + Window w = new Window("Resize", layout); + Label desc = new Label( + "This is a new child window with a preset" + + " width, height and position. Resizing has not been" + + " disabled for this window. Additionally, this text label" + + " is intentionally too large to fit the window. You can resize" + + " to view different parts of the window content."); + // disable wrapping + desc.setSizeUndefined(); + layout.addComponent(desc); + + // Set window position + w.setPositionX(400); + w.setPositionY(100); + + // Set window size + w.setWidth(60, Unit.PIXELS); + w.setHeight(60, Unit.PIXELS); + + // Don't disable resizing - getMainWindow().addWindow(w); + return w; } } diff --git a/uitest/src/com/vaadin/tests/components/window/TestTooSmallSubwindowSizeTest.java b/uitest/src/com/vaadin/tests/components/window/TestTooSmallSubwindowSizeTest.java new file mode 100644 index 0000000000..0019900884 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/TestTooSmallSubwindowSizeTest.java @@ -0,0 +1,38 @@ +/* + * 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.window; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests that the styles work correctly in tiny subwindows that have more + * content than can fit. + * + * @author Vaadin Ltd + */ +public class TestTooSmallSubwindowSizeTest extends MultiBrowserTest { + + @Test + public void testSubwindowStyles() throws IOException { + openTestURL(); + + compareScreen("initial"); + } +} -- cgit v1.2.3 From a2bf94616f7f58ec4256aaf1f9dbad735a20f529 Mon Sep 17 00:00:00 2001 From: Juho Nurminen Date: Thu, 14 Aug 2014 17:11:38 +0300 Subject: Update modernie property provider to recognize IE11 on WP 8.1 Update (#14376) Change-Id: I8df8260bf875dd2a3cf974885bde8b473f4951a5 --- client/src/com/vaadin/Vaadin.gwt.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/com/vaadin/Vaadin.gwt.xml b/client/src/com/vaadin/Vaadin.gwt.xml index 711729f64f..aad0563975 100644 --- a/client/src/com/vaadin/Vaadin.gwt.xml +++ b/client/src/com/vaadin/Vaadin.gwt.xml @@ -68,7 +68,7 @@ -- cgit v1.2.3 From b0b9cc3389e2ae9e570fb698605bf923f042f222 Mon Sep 17 00:00:00 2001 From: Juho Nurminen Date: Thu, 14 Aug 2014 17:54:24 +0300 Subject: Update VBrowserDetails to handle the new IE11 UA on WP 8.1 Update (#14376) Change-Id: I7fdd091a3b2994270e9928eb4f118ab5ca59ef30 --- .../com/vaadin/client/TestVBrowserDetailsUserAgentParser.java | 11 +++++++++++ shared/src/com/vaadin/shared/VBrowserDetails.java | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java b/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java index 5b428574e2..e38054e3e4 100644 --- a/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java +++ b/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java @@ -28,6 +28,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { private static final String IE10_WINDOWS_8 = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"; private static final String IE11_WINDOWS_7 = "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; rv:11.0) like Gecko"; + private static final String IE11_WINDOWS_PHONE_8_1_UPDATE = "Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 920) Like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537"; // "Version/" was added in 10.00 private static final String OPERA964_WINDOWS = "Opera/9.64(Windows NT 5.1; U; en) Presto/2.1.1"; @@ -396,6 +397,16 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase { assertWindows(bd); } + public void testIE11WindowsPhone81Update() { + VBrowserDetails bd = new VBrowserDetails(IE11_WINDOWS_PHONE_8_1_UPDATE); + assertTrident(bd); + assertEngineVersion(bd, 7); + assertIE(bd); + assertBrowserMajorVersion(bd, 11); + assertBrowserMinorVersion(bd, 0); + assertWindows(bd); + } + /* * Helper methods below */ diff --git a/shared/src/com/vaadin/shared/VBrowserDetails.java b/shared/src/com/vaadin/shared/VBrowserDetails.java index 3680e4168e..81a39cdedc 100644 --- a/shared/src/com/vaadin/shared/VBrowserDetails.java +++ b/shared/src/com/vaadin/shared/VBrowserDetails.java @@ -68,19 +68,19 @@ public class VBrowserDetails implements Serializable { isGecko = userAgent.indexOf("gecko") != -1 && userAgent.indexOf("webkit") == -1 && userAgent.indexOf("trident/") == -1; - isWebKit = userAgent.indexOf("applewebkit") != -1; isPresto = userAgent.indexOf(" presto/") != -1; isTrident = userAgent.indexOf("trident/") != -1; + isWebKit = !isTrident && userAgent.indexOf("applewebkit") != -1; // browser name isChrome = userAgent.indexOf(" chrome/") != -1; - isSafari = !isChrome && userAgent.indexOf("safari") != -1; isOpera = userAgent.indexOf("opera") != -1; isIE = userAgent.indexOf("msie") != -1 && !isOpera && (userAgent.indexOf("webtv") == -1); // IE 11 no longer contains MSIE in the user agent isIE = isIE || isTrident; + isSafari = !isChrome && !isIE && userAgent.indexOf("safari") != -1; isFirefox = userAgent.indexOf(" firefox/") != -1; // chromeframe -- cgit v1.2.3 From 987505f4a9ffee33bd9edc48d412f5b29a3fccd2 Mon Sep 17 00:00:00 2001 From: Juho Nurminen Date: Thu, 14 Aug 2014 20:08:06 +0300 Subject: Update GWT version (#14376) Change-Id: Idc948853a1a8529e42cbab5e4dce5938897d39dc --- build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.properties b/build.properties index 488c2fa32f..bd31158a3e 100644 --- a/build.properties +++ b/build.properties @@ -6,5 +6,5 @@ vaadin.url=http://vaadin.com vaadin.java.version=1.6 vaadin.version=0.0.0.unversioned-development-build vaadin.sass.version=0.9.9 -gwt.version=2.6.0.vaadin3 +gwt.version=2.6.0.vaadin4 commons-io.version=2.4 -- cgit v1.2.3 From 56195677e92cb6ad9ac6e0e5ef2aae2a403d3fc0 Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Thu, 14 Aug 2014 14:48:26 +0300 Subject: Window close and maximize/restore buttons not visible on initial render in IE8 (Valo) #14413 Remove unnecessary FontAwesome declaration as well, which made the characters look bad in IE8. Change-Id: Ib0f9b01023b0a7a6f40513c80cbb6e6c69bd164c --- WebContent/VAADIN/themes/valo/components/_window.scss | 1 - client/src/com/vaadin/client/ui/VWindow.java | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/WebContent/VAADIN/themes/valo/components/_window.scss b/WebContent/VAADIN/themes/valo/components/_window.scss index d866ce2584..97859a62b2 100644 --- a/WebContent/VAADIN/themes/valo/components/_window.scss +++ b/WebContent/VAADIN/themes/valo/components/_window.scss @@ -125,7 +125,6 @@ $v-window-modality-curtain-background-color: #222 !default; line-height: $v-unit-size - 3px; text-align: center; cursor: pointer; - font-family: FontAwesome; font-size: round($v-font-size * 1.3); color: valo-font-color($v-window-background-color, .4); diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index 495e230156..7223e4ac83 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -245,6 +245,20 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, * state. */ setTabStopEnabled(doTabStop); + + // Fix for #14413. Any pseudo elements inside these elements are not + // visible on initial render unless we shake the DOM. + if (BrowserInfo.get().isIE8()) { + closeBox.getStyle().setDisplay(Display.NONE); + maximizeRestoreBox.getStyle().setDisplay(Display.NONE); + Scheduler.get().scheduleFinally(new Command() { + @Override + public void execute() { + closeBox.getStyle().clearDisplay(); + maximizeRestoreBox.getStyle().clearDisplay(); + } + }); + } } @Override -- cgit v1.2.3 From e95965a10bb6070096ee239ba22cc0e038874bde Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Fri, 15 Aug 2014 12:32:34 +0300 Subject: Add two new size variants for Valo, tiny and huge Available as additional style names for buttons, text fields/text areas, combo boxes, date fields and labels. Change-Id: I12f36935a690f5bf3f12333f5bd4ac986d4efd1f --- .../VAADIN/themes/valo/components/_button.scss | 16 +++++ .../VAADIN/themes/valo/components/_combobox.scss | 10 ++++ .../VAADIN/themes/valo/components/_datefield.scss | 10 ++++ .../VAADIN/themes/valo/components/_label.scss | 8 +++ .../VAADIN/themes/valo/components/_textarea.scss | 10 ++++ .../VAADIN/themes/valo/components/_textfield.scss | 12 ++++ .../VAADIN/themes/valo/shared/_variables.scss | 12 +++- server/src/com/vaadin/ui/themes/ValoTheme.java | 69 +++++++++++++++++++++- .../vaadin/tests/themes/valo/ButtonsAndLinks.java | 8 +++ .../com/vaadin/tests/themes/valo/ComboBoxes.java | 16 +++++ .../com/vaadin/tests/themes/valo/DateFields.java | 12 ++++ .../src/com/vaadin/tests/themes/valo/Labels.java | 8 +++ .../com/vaadin/tests/themes/valo/TextFields.java | 20 +++++++ 13 files changed, 205 insertions(+), 6 deletions(-) diff --git a/WebContent/VAADIN/themes/valo/components/_button.scss b/WebContent/VAADIN/themes/valo/components/_button.scss index ec74f70eaf..42953ea610 100644 --- a/WebContent/VAADIN/themes/valo/components/_button.scss +++ b/WebContent/VAADIN/themes/valo/components/_button.scss @@ -45,6 +45,10 @@ @include valo-link-style; } + .#{$primary-stylename}-tiny { + @include valo-button-style($unit-size: $v-unit-size--tiny, $bevel: null, $shadow: null, $background-color: null, $font-size: $v-font-size--tiny, $font-weight: null); + } + .#{$primary-stylename}-small { @include valo-button-style($unit-size: $v-unit-size--small, $bevel: null, $shadow: null, $background-color: null, $font-size: $v-font-size--small, $font-weight: null); } @@ -53,6 +57,10 @@ @include valo-button-style($unit-size: $v-unit-size--large, $bevel: null, $shadow: null, $background-color: null, $font-size: $v-font-size--large, $font-weight: null); } + .#{$primary-stylename}-huge { + @include valo-button-style($unit-size: $v-unit-size--huge, $bevel: null, $shadow: null, $background-color: null, $font-size: $v-font-size--huge, $font-weight: null); + } + .#{$primary-stylename}-icon-align-right { @include valo-button-icon-align-right-style; } @@ -65,6 +73,10 @@ width: $v-unit-size; padding: 0; + &.#{$primary-stylename}-tiny { + width: $v-unit-size--tiny; + } + &.#{$primary-stylename}-small { width: $v-unit-size--small; } @@ -73,6 +85,10 @@ width: $v-unit-size--large; } + &.#{$primary-stylename}-huge { + width: $v-unit-size--huge; + } + .#{$primary-stylename}-caption { display: none; } diff --git a/WebContent/VAADIN/themes/valo/components/_combobox.scss b/WebContent/VAADIN/themes/valo/components/_combobox.scss index 4e5cd5bbac..538a5e2694 100644 --- a/WebContent/VAADIN/themes/valo/components/_combobox.scss +++ b/WebContent/VAADIN/themes/valo/components/_combobox.scss @@ -78,6 +78,11 @@ text-align: center; } + .#{$primary-stylename}-tiny { + @include valo-combobox-style($unit-size: $v-unit-size--tiny, $bevel: null, $shadow: null, $gradient: null, $border: null, $border-radius: null, $background-color: null, $states: normal); + font-size: $v-font-size--tiny; + } + .#{$primary-stylename}-small { @include valo-combobox-style($unit-size: $v-unit-size--small, $bevel: null, $shadow: null, $gradient: null, $border: null, $border-radius: null, $background-color: null, $states: normal); font-size: $v-font-size--small; @@ -87,6 +92,11 @@ @include valo-combobox-style($unit-size: $v-unit-size--large, $bevel: null, $shadow: null, $gradient: null, $border: null, $border-radius: null, $background-color: null, $states: normal); font-size: $v-font-size--large; } + + .#{$primary-stylename}-huge { + @include valo-combobox-style($unit-size: $v-unit-size--huge, $bevel: null, $shadow: null, $gradient: null, $border: null, $border-radius: null, $background-color: null, $states: normal); + font-size: $v-font-size--huge; + } } } diff --git a/WebContent/VAADIN/themes/valo/components/_datefield.scss b/WebContent/VAADIN/themes/valo/components/_datefield.scss index 1538681740..8854992032 100644 --- a/WebContent/VAADIN/themes/valo/components/_datefield.scss +++ b/WebContent/VAADIN/themes/valo/components/_datefield.scss @@ -59,6 +59,11 @@ text-align: center; } + .#{$primary-stylename}-tiny { + @include valo-datefield-style($unit-size: $v-unit-size--tiny, $bevel: null, $shadow: null, $border: null, $background-color: null, $states: normal); + font-size: $v-font-size--tiny; + } + .#{$primary-stylename}-small { @include valo-datefield-style($unit-size: $v-unit-size--small, $bevel: null, $shadow: null, $border: null, $background-color: null, $states: normal); font-size: $v-font-size--small; @@ -68,6 +73,11 @@ @include valo-datefield-style($unit-size: $v-unit-size--large, $bevel: null, $shadow: null, $border: null, $background-color: null, $states: normal); font-size: $v-font-size--large; } + + .#{$primary-stylename}-huge { + @include valo-datefield-style($unit-size: $v-unit-size--huge, $bevel: null, $shadow: null, $border: null, $background-color: null, $states: normal); + font-size: $v-font-size--huge; + } } } diff --git a/WebContent/VAADIN/themes/valo/components/_label.scss b/WebContent/VAADIN/themes/valo/components/_label.scss index 29d811fc9a..51e7026834 100644 --- a/WebContent/VAADIN/themes/valo/components/_label.scss +++ b/WebContent/VAADIN/themes/valo/components/_label.scss @@ -112,6 +112,14 @@ $v-letter-spacing--h4: 0 !default; font-size: $v-font-size--small; } + .#{$primary-stylename}-tiny { + font-size: $v-font-size--tiny; + } + + .#{$primary-stylename}-huge { + font-size: $v-font-size--huge; + } + .#{$primary-stylename}-bold { font-weight: $v-font-weight + 200; } diff --git a/WebContent/VAADIN/themes/valo/components/_textarea.scss b/WebContent/VAADIN/themes/valo/components/_textarea.scss index 4c5d99b8e2..5e524bfb9e 100644 --- a/WebContent/VAADIN/themes/valo/components/_textarea.scss +++ b/WebContent/VAADIN/themes/valo/components/_textarea.scss @@ -19,6 +19,11 @@ @include valo-textfield-borderless-style; } + .#{$primary-stylename}-tiny { + @include valo-textarea-style($unit-size: $v-unit-size--tiny, $states: normal, $background-color: null, $border: null, $bevel: null, $shadow: null); + font-size: $v-font-size--tiny; + } + .#{$primary-stylename}-small { @include valo-textarea-style($unit-size: $v-unit-size--small, $states: normal, $background-color: null, $border: null, $bevel: null, $shadow: null); font-size: $v-font-size--small; @@ -29,6 +34,11 @@ font-size: $v-font-size--large; } + .#{$primary-stylename}-huge { + @include valo-textarea-style($unit-size: $v-unit-size--huge, $states: normal, $background-color: null, $border: null, $bevel: null, $shadow: null); + font-size: $v-font-size--huge; + } + .#{$primary-stylename}-align-right { text-align: right; } diff --git a/WebContent/VAADIN/themes/valo/components/_textfield.scss b/WebContent/VAADIN/themes/valo/components/_textfield.scss index 75cfc5ef85..dc516048e7 100644 --- a/WebContent/VAADIN/themes/valo/components/_textfield.scss +++ b/WebContent/VAADIN/themes/valo/components/_textfield.scss @@ -30,6 +30,11 @@ $v-textfield-disabled-opacity: $v-disabled-opacity !default; @include valo-textfield-borderless-style; } + .#{$primary-stylename}-tiny { + @include valo-textfield-style($unit-size: $v-unit-size--tiny, $states: normal, $background-color: null, $border: null, $gradient: null, $bevel: null, $shadow: null); + font-size: $v-font-size--tiny; + } + .#{$primary-stylename}-small { @include valo-textfield-style($unit-size: $v-unit-size--small, $states: normal, $background-color: null, $border: null, $gradient: null, $bevel: null, $shadow: null); font-size: $v-font-size--small; @@ -40,9 +45,16 @@ $v-textfield-disabled-opacity: $v-disabled-opacity !default; font-size: $v-font-size--large; } + .#{$primary-stylename}-huge { + @include valo-textfield-style($unit-size: $v-unit-size--huge, $states: normal, $background-color: null, $border: null, $gradient: null, $bevel: null, $shadow: null); + font-size: $v-font-size--huge; + } + @include valo-textfield-inline-icon($stylenames: inline-icon); + @include valo-textfield-inline-icon($stylenames: inline-icon tiny, $unit-size: $v-unit-size--tiny, $font-size: $v-font-size--tiny); @include valo-textfield-inline-icon($stylenames: inline-icon small, $unit-size: $v-unit-size--small, $font-size: $v-font-size--small); @include valo-textfield-inline-icon($stylenames: inline-icon large, $unit-size: $v-unit-size--large, $font-size: $v-font-size--large); + @include valo-textfield-inline-icon($stylenames: inline-icon huge, $unit-size: $v-unit-size--huge, $font-size: $v-font-size--huge); .#{$primary-stylename}-align-right { text-align: right; diff --git a/WebContent/VAADIN/themes/valo/shared/_variables.scss b/WebContent/VAADIN/themes/valo/shared/_variables.scss index b1c113b2cc..7dd3827298 100644 --- a/WebContent/VAADIN/themes/valo/shared/_variables.scss +++ b/WebContent/VAADIN/themes/valo/shared/_variables.scss @@ -60,14 +60,20 @@ $v-required-field-indicator-color : $v-error-indicator-color $v-friendly-color : #2c9720 !default; -$v-scaling-factor--small : 0.8 !default; +$v-scaling-factor--tiny : 0.75 !default; +$v-scaling-factor--small : 0.85 !default; $v-scaling-factor--large : 1.2 !default; +$v-scaling-factor--huge : 1.6 !default; +$v-unit-size--tiny : round($v-unit-size * $v-scaling-factor--tiny) !default; $v-unit-size--small : round($v-unit-size * $v-scaling-factor--small) !default; $v-unit-size--large : round($v-unit-size * $v-scaling-factor--large) !default; +$v-unit-size--huge : round($v-unit-size * $v-scaling-factor--huge) !default; -$v-font-size--small : round($v-font-size * $v-scaling-factor--small) !default; -$v-font-size--large : round($v-font-size * $v-scaling-factor--large) !default; +$v-font-size--tiny : ceil($v-font-size * $v-scaling-factor--tiny) !default; +$v-font-size--small : ceil($v-font-size * $v-scaling-factor--small) !default; +$v-font-size--large : ceil($v-font-size * $v-scaling-factor--large) !default; +$v-font-size--huge : ceil($v-font-size * $v-scaling-factor--huge) !default; diff --git a/server/src/com/vaadin/ui/themes/ValoTheme.java b/server/src/com/vaadin/ui/themes/ValoTheme.java index ad949c6a32..ea6b9082f8 100644 --- a/server/src/com/vaadin/ui/themes/ValoTheme.java +++ b/server/src/com/vaadin/ui/themes/ValoTheme.java @@ -25,9 +25,10 @@ import com.vaadin.ui.Table.ColumnHeaderMode; *

* *

- * These styles are only available if the Valo theme (or any of it's variants) - * is built with the $valo-include-common-stylenames Sass variable - * set to true. + * These styles are only available if the + * $v-included-additional-styles Sass list variable contains the + * name of the component for that additional style name (e.g. + * button, textfield, table). *

* *

@@ -148,6 +149,12 @@ public class ValoTheme { */ public static final String LABEL_NO_MARGIN = "no-margin"; + /** + * Tiny font size. Suitable for additional/supplementary UI text. Can be + * combined with any other Label style. + */ + public static final String LABEL_TINY = "tiny"; + /** * Small font size. Suitable for additional/supplementary UI text. Can be * combined with any other Label style. @@ -160,6 +167,12 @@ public class ValoTheme { */ public static final String LABEL_LARGE = "large"; + /** + * Huge font size. Suitable for important/prominent UI text. Can be combined + * with any other Label style. + */ + public static final String LABEL_HUGE = "huge"; + /** * Lighter font weight. Suitable for additional/supplementary UI text. Can * be combined with any other Label style. @@ -251,6 +264,11 @@ public class ValoTheme { */ public static final String BUTTON_LINK = "link"; + /** + * Tiny size button. Can be combined with any other Button style. + */ + public static final String BUTTON_TINY = "tiny"; + /** * Small size button. Can be combined with any other Button style. */ @@ -261,6 +279,11 @@ public class ValoTheme { */ public static final String BUTTON_LARGE = "large"; + /** + * Huge size button. Can be combined with any other Button style. + */ + public static final String BUTTON_HUGE = "huge"; + /** * Align the icon to the right side of the button caption. Can be combined * with any other Button style. @@ -300,6 +323,11 @@ public class ValoTheme { * **************************************************************************/ + /** + * Tiny size text field. Can be combined with any other TextField style. + */ + public static final String TEXTFIELD_TINY = "tiny"; + /** * Small size text field. Can be combined with any other TextField style. */ @@ -310,6 +338,11 @@ public class ValoTheme { */ public static final String TEXTFIELD_LARGE = "large"; + /** + * Huge size text field. Can be combined with any other TextField style. + */ + public static final String TEXTFIELD_HUGE = "huge"; + /** * Removes the border and background from the text field. Can be combined * with any other TextField style. @@ -340,6 +373,11 @@ public class ValoTheme { * **************************************************************************/ + /** + * Tiny size text area. Can be combined with any other TextArea style. + */ + public static final String TEXTAREA_TINY = "tiny"; + /** * Small size text area. Can be combined with any other TextArea style. */ @@ -350,6 +388,11 @@ public class ValoTheme { */ public static final String TEXTAREA_LARGE = "large"; + /** + * Huge size text area. Can be combined with any other TextArea style. + */ + public static final String TEXTAREA_HUGE = "huge"; + /** * Removes the border and background from the text area. Can be combined * with any other TextArea style. @@ -374,6 +417,11 @@ public class ValoTheme { * **************************************************************************/ + /** + * Tiny size date field. Can be combined with any other DateField style. + */ + public static final String DATEFIELD_TINY = "tiny"; + /** * Small size date field. Can be combined with any other DateField style. */ @@ -384,6 +432,11 @@ public class ValoTheme { */ public static final String DATEFIELD_LARGE = "large"; + /** + * Huge size date field. Can be combined with any other DateField style. + */ + public static final String DATEFIELD_HUGE = "huge"; + /** * Removes the border and background from the date field. Can be combined * with any other DateField style. @@ -408,6 +461,11 @@ public class ValoTheme { * **************************************************************************/ + /** + * Tiny size combo box. Can be combined with any other ComboBox style. + */ + public static final String COMBOBOX_TINY = "tiny"; + /** * Small size combo box. Can be combined with any other ComboBox style. */ @@ -418,6 +476,11 @@ public class ValoTheme { */ public static final String COMBOBOX_LARGE = "large"; + /** + * Huge size combo box. Can be combined with any other ComboBox style. + */ + public static final String COMBOBOX_HUGE = "huge"; + /** * Removes the border and background from the combo box. Can be combined * with any other ComboBox style. diff --git a/uitest/src/com/vaadin/tests/themes/valo/ButtonsAndLinks.java b/uitest/src/com/vaadin/tests/themes/valo/ButtonsAndLinks.java index 758d2de200..e66cd2668b 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/ButtonsAndLinks.java +++ b/uitest/src/com/vaadin/tests/themes/valo/ButtonsAndLinks.java @@ -136,6 +136,14 @@ public class ButtonsAndLinks extends VerticalLayout implements View { button = new Button("Three"); group.addComponent(button); + button = new Button("Tiny"); + button.addStyleName("tiny"); + row.addComponent(button); + + button = new Button("Huge"); + button.addStyleName("huge"); + row.addComponent(button); + NativeButton nbutton = new NativeButton("Native"); row.addComponent(nbutton); diff --git a/uitest/src/com/vaadin/tests/themes/valo/ComboBoxes.java b/uitest/src/com/vaadin/tests/themes/valo/ComboBoxes.java index 1b8b290d91..98a9cad83c 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/ComboBoxes.java +++ b/uitest/src/com/vaadin/tests/themes/valo/ComboBoxes.java @@ -162,6 +162,22 @@ public class ComboBoxes extends VerticalLayout implements View { combo.addItem("Option Three"); combo.addStyleName("borderless"); row.addComponent(combo); + + combo = new ComboBox("Tiny"); + combo.setInputPrompt("You can type here"); + combo.setContainerDataSource(ValoThemeUI.generateContainer(200, false)); + combo.setItemCaptionPropertyId(ValoThemeUI.CAPTION_PROPERTY); + combo.setItemIconPropertyId(ValoThemeUI.ICON_PROPERTY); + combo.addStyleName("tiny"); + row.addComponent(combo); + + combo = new ComboBox("Huge"); + combo.setInputPrompt("You can type here"); + combo.setContainerDataSource(ValoThemeUI.generateContainer(200, false)); + combo.setItemCaptionPropertyId(ValoThemeUI.CAPTION_PROPERTY); + combo.setItemIconPropertyId(ValoThemeUI.ICON_PROPERTY); + combo.addStyleName("huge"); + row.addComponent(combo); } @Override diff --git a/uitest/src/com/vaadin/tests/themes/valo/DateFields.java b/uitest/src/com/vaadin/tests/themes/valo/DateFields.java index 41aa287f9f..bdc0dc5983 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/DateFields.java +++ b/uitest/src/com/vaadin/tests/themes/valo/DateFields.java @@ -172,6 +172,18 @@ public class DateFields extends VerticalLayout implements View { date.setDateFormat("E dd/MM/yyyy"); row.addComponent(date); + date = new DateField("Tiny"); + date.setValue(new Date()); + date.setResolution(Resolution.DAY); + date.addStyleName("tiny"); + row.addComponent(date); + + date = new DateField("Huge"); + date.setValue(new Date()); + date.setResolution(Resolution.DAY); + date.addStyleName("huge"); + row.addComponent(date); + date = new InlineDateField("Date picker"); setDate(date); row.addComponent(date); diff --git a/uitest/src/com/vaadin/tests/themes/valo/Labels.java b/uitest/src/com/vaadin/tests/themes/valo/Labels.java index 08378ad9e6..63c138093c 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/Labels.java +++ b/uitest/src/com/vaadin/tests/themes/valo/Labels.java @@ -45,6 +45,10 @@ public class Labels extends VerticalLayout implements View { left.setMargin(new MarginInfo(false, true, false, false)); split.addComponent(left); + Label huge = new Label("Huge type for display text."); + huge.addStyleName("huge"); + left.addComponent(huge); + Label large = new Label( "Large type for introductory text. Etiam at risus et justo dignissim congue. Donec congue lacinia dui, a porttitor lectus condimentum laoreet. Nunc eu."); large.addStyleName("large"); @@ -68,6 +72,10 @@ public class Labels extends VerticalLayout implements View { small.addStyleName("small"); left.addComponent(small); + Label tiny = new Label("Tiny type for minor text."); + tiny.addStyleName("tiny"); + left.addComponent(tiny); + Label h4 = new Label("Section Title"); h4.addStyleName("h4"); left.addComponent(h4); diff --git a/uitest/src/com/vaadin/tests/themes/valo/TextFields.java b/uitest/src/com/vaadin/tests/themes/valo/TextFields.java index f8606bb7c9..347a683673 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/TextFields.java +++ b/uitest/src/com/vaadin/tests/themes/valo/TextFields.java @@ -182,6 +182,16 @@ public class TextFields extends VerticalLayout implements View { pwf.setIcon(FontAwesome.LOCK); row.addComponent(pwf); + tf = new TextField("Tiny"); + tf.setValue("Field value"); + tf.addStyleName("tiny"); + row.addComponent(tf); + + tf = new TextField("Huge"); + tf.setValue("Field value"); + tf.addStyleName("huge"); + row.addComponent(tf); + h1 = new Label("Text Areas"); h1.addStyleName("h1"); addComponent(h1); @@ -242,6 +252,16 @@ public class TextFields extends VerticalLayout implements View { ta.setValue("Field value, spanning multiple lines of text"); row.addComponent(ta); + ta = new TextArea("Tiny"); + ta.addStyleName("tiny"); + ta.setInputPrompt("Write your comment…"); + row.addComponent(ta); + + ta = new TextArea("Huge"); + ta.addStyleName("huge"); + ta.setInputPrompt("Write your comment…"); + row.addComponent(ta); + RichTextArea rta = new RichTextArea(); rta.setValue("Some rich content"); row.addComponent(rta); -- cgit v1.2.3 From dcf6c391202d2474ca42cf9a50de62ac953e1382 Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Tue, 29 Jul 2014 16:02:56 +0300 Subject: ExtraWindowShownWaiAria test upgrade (#14292) Change-Id: I83f0d08850d2e03008601f10043314c00818bdaa --- .../components/window/ExtraWindowShownWaiAria.html | 136 --------------------- .../window/ExtraWindowShownWaiAriaTest.java | 128 +++++++++++++++++++ 2 files changed, 128 insertions(+), 136 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.html create mode 100644 uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAriaTest.java diff --git a/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.html b/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.html deleted file mode 100644 index f5f89d13ef..0000000000 --- a/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.html +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - -ExtraWindowShownWaiAria - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ExtraWindowShownWaiAria
open/run/com.vaadin.tests.components.window.ExtraWindowShownWaiAria?restartApplication
clickvaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
assertElementPresentvaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/
assertAttributevaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/@roledialog
storeAttributevaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]@idheaderid
assertAttributevaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/@aria-labelledby${headerid}
storeAttributevaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/FocusableScrollPanel[0]/VCssLayout[0]/VLabel[0]@iddescriptionid
assertAttributevaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/@aria-describedby${descriptionid}
assertAttributevaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]@rolebutton
assertAttributevaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]@rolebutton
clickvaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/FocusableScrollPanel[0]/VCssLayout[0]/VButton[0]/domChild[0]/domChild[0]
assertElementNotPresentvaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/
clickvaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VCheckBox[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
storeAttributevaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/FocusableScrollPanel[0]/VCssLayout[0]/VLabel[0]@iddescriptionid
storeAttributevaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/FocusableScrollPanel[0]/VCssLayout[0]/VLabel[1]@iddescription2id
assertAttributevaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/@aria-describedby${descriptionid} ${description2id}
clickvaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/FocusableScrollPanel[0]/VCssLayout[0]/VButton[0]/domChild[0]/domChild[0]
assertElementNotPresentvaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/
typevaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[6]/VTextField[0]Important
typevaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[7]/VTextField[0] - do ASAP
clickvaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
assertTextxpath=//div[@class='v-window-header']/span[@class='v-assistive-device-only'][1]Important
assertTextxpath=//div[@class='v-window-header']/span[@class='v-assistive-device-only'][2]- do ASAP
- - diff --git a/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAriaTest.java b/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAriaTest.java new file mode 100644 index 0000000000..44aea3522a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAriaTest.java @@ -0,0 +1,128 @@ +/* + * 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.window; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.testbench.elements.WindowElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests dialogs with WAI-ARIA. + * + * @since + * @author Vaadin Ltd + */ +public class ExtraWindowShownWaiAriaTest extends MultiBrowserTest { + + @Test + public void testDialogs() throws InterruptedException { + openTestURL(); + + List buttons = $(ButtonElement.class).all(); + assertFalse(buttons.isEmpty()); + + // open alert dialog + buttons.get(0).click(); + + // ensure dialog opened + List windows = $(WindowElement.class).all(); + assertFalse(windows.isEmpty()); + + // ensure correct attributes + assertEquals("alertdialog", windows.get(0).getAttribute("role")); + + WebElement header = windows.get(0).findElement( + By.className("v-window-header")); + assertEquals(header.getAttribute("id"), + windows.get(0).getAttribute("aria-labelledby")); + + WebElement label = windows.get(0).findElement(By.className("v-label")); + assertEquals(label.getAttribute("id"), + windows.get(0).getAttribute("aria-describedby")); + + List wButtons = windows.get(0).findElements( + By.className("v-button")); + assertEquals("button", wButtons.get(0).getAttribute("role")); + assertEquals("button", wButtons.get(1).getAttribute("role")); + + // close dialog + wButtons.get(0).click(); + + // ensure dialog closed + windows = $(WindowElement.class).all(); + assertTrue(windows.isEmpty()); + + // check additional description (second checkbox on the page) + List checkBoxes = $(CheckBoxElement.class).all(); + WebElement input = checkBoxes.get(1).findElement(By.tagName("input")); + // ensure that not checked yet + assertEquals(null, input.getAttribute("checked")); + input.click(); + // ensure that checked now + assertEquals("true", input.getAttribute("checked")); + + // open alert dialog + buttons = $(ButtonElement.class).all(); + buttons.get(0).click(); + + // ensure correct attributes + windows = $(WindowElement.class).all(); + List labels = windows.get(0).findElements( + By.className("v-label")); + assertEquals(labels.get(0).getAttribute("id") + " " + + labels.get(1).getAttribute("id"), windows.get(0) + .getAttribute("aria-describedby")); + + // close dialog + wButtons = windows.get(0).findElements(By.className("v-button")); + wButtons.get(0).click(); + + // ensure dialog closed + windows = $(WindowElement.class).all(); + assertTrue(windows.isEmpty()); + + // add prefix and postfix + List textFields = $(TextFieldElement.class).all(); + textFields.get(0).sendKeys("Important"); + textFields.get(1).sendKeys(" - do ASAP"); + + // open alert dialog + buttons = $(ButtonElement.class).all(); + buttons.get(0).click(); + + // ensure the assistive spans have been added to the header + windows = $(WindowElement.class).all(); + header = windows.get(0).findElement(By.className("v-window-header")); + List assistiveElements = header.findElements(By + .className("v-assistive-device-only")); + assertEquals("Important", + assistiveElements.get(0).getAttribute("innerHTML")); + assertEquals(" - do ASAP", + assistiveElements.get(1).getAttribute("innerHTML")); + } +} -- cgit v1.2.3 From 726f77cce759feeaf78e4f92119b60ad33e0079d Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Fri, 15 Aug 2014 12:28:07 +0300 Subject: Valo Tree Drag & Drop styles broken (#14360) Change-Id: Iafee03aaea3266ab32edb407e605ff3d8de474e1 --- WebContent/VAADIN/themes/valo/components/_tree.scss | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/WebContent/VAADIN/themes/valo/components/_tree.scss b/WebContent/VAADIN/themes/valo/components/_tree.scss index 7e00f4ec09..93553fe55a 100644 --- a/WebContent/VAADIN/themes/valo/components/_tree.scss +++ b/WebContent/VAADIN/themes/valo/components/_tree.scss @@ -218,7 +218,8 @@ $v-tree-expand-animation-enabled: false !default; // Drag'n'drop styles .#{$primary-stylename}-node-drag-top:before, - .#{$primary-stylename}-node-drag-bottom:after { + .#{$primary-stylename}-node-drag-bottom:after, + .#{$primary-stylename}-node-drag-bottom.#{$primary-stylename}-node-dragfolder.#{$primary-stylename}-node-expanded > .#{$primary-stylename}-node-children:before { content: "\2022"; display: block; position: absolute; @@ -230,6 +231,12 @@ $v-tree-expand-animation-enabled: false !default; color: $v-focus-color; text-indent: round($v-font-size/-4); text-shadow: 0 0 1px $v-background-color, 0 0 1px $v-background-color; + opacity: 1; + visibility: visible; + } + + .#{$primary-stylename}-node-drag-bottom.#{$primary-stylename}-node-dragfolder.#{$primary-stylename}-node-expanded:after { + content: none; } .#{$primary-stylename}-node-caption-drag-center { -- cgit v1.2.3 From c961d06c1f3fda81da3ab8700fbda5d33d8a9325 Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Mon, 11 Aug 2014 15:35:30 +0300 Subject: TextFieldRelativeWidth test upgrade (#14292) Change-Id: Ia879f22f171c97fd614a92526db3cd00f35d9d27 --- .../components/table/TextFieldRelativeWidth.html | 63 ---------------------- .../components/table/TextFieldRelativeWidth.java | 32 +++-------- .../table/TextFieldRelativeWidthTest.java | 45 ++++++++++++++++ 3 files changed, 53 insertions(+), 87 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/table/TextFieldRelativeWidth.html create mode 100644 uitest/src/com/vaadin/tests/components/table/TextFieldRelativeWidthTest.java diff --git a/uitest/src/com/vaadin/tests/components/table/TextFieldRelativeWidth.html b/uitest/src/com/vaadin/tests/components/table/TextFieldRelativeWidth.html deleted file mode 100644 index 6e3d86175a..0000000000 --- a/uitest/src/com/vaadin/tests/components/table/TextFieldRelativeWidth.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - -TextFieldRelativeWidth - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TextFieldRelativeWidth
open/run/com.vaadin.tests.components.table.TextFieldRelativeWidth
open/run/com.vaadin.tests.components.table.TextFieldRelativeWidth
waitForVaadin
screenCapture
clickvaadin=runcomvaadintestscomponentstableTextFieldRelativeWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
clickvaadin=runcomvaadintestscomponentstableTextFieldRelativeWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[4]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
screenCapture
- - diff --git a/uitest/src/com/vaadin/tests/components/table/TextFieldRelativeWidth.java b/uitest/src/com/vaadin/tests/components/table/TextFieldRelativeWidth.java index 5c7479d060..4799d05415 100644 --- a/uitest/src/com/vaadin/tests/components/table/TextFieldRelativeWidth.java +++ b/uitest/src/com/vaadin/tests/components/table/TextFieldRelativeWidth.java @@ -1,19 +1,19 @@ package com.vaadin.tests.components.table; import com.vaadin.data.Item; -import com.vaadin.data.Property; import com.vaadin.data.util.IndexedContainer; -import com.vaadin.tests.components.TestBase; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; -public class TextFieldRelativeWidth extends TestBase { +public class TextFieldRelativeWidth extends AbstractTestUI { @Override - public void setup() { + public void setup(VaadinRequest request) { TextField tf = new TextField("test", "testing"); tf.setWidth("100%"); @@ -30,15 +30,12 @@ public class TextFieldRelativeWidth extends TestBase { private Button addButton = new Button("Add new row", this); private String inputPrompt; - private String inputPromptChild; - private int nextItemIndex = 1; - private static final long serialVersionUID = 3326806911297977454L; - + @SuppressWarnings("unchecked") public EditTable() { - setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN); + setColumnHeaderMode(ColumnHeaderMode.HIDDEN); inputPrompt = ""; setPageLength(100); setHeight("100%"); @@ -51,20 +48,9 @@ public class TextFieldRelativeWidth extends TestBase { i.getItemProperty("text").setValue(addButton); setImmediate(true); setSelectable(true); - addListener(new Property.ValueChangeListener() { - private static final long serialVersionUID = 448896474865195605L; - - @Override - public void valueChange( - com.vaadin.data.Property.ValueChangeEvent event) { - // IndexedContainer idc = (IndexedContainer) - // getContainerDataSource(); - - } - - }); } + @SuppressWarnings("unchecked") public void addNewRow() { IndexedContainer idc = (IndexedContainer) getContainerDataSource(); int size = idc.size(); @@ -87,8 +73,6 @@ public class TextFieldRelativeWidth extends TestBase { if (inputPromptChild != null && inputPromptChild.length() > 0) { tf.setInputPrompt(inputPromptChild); } - // tf.setRows(1); - // tf.setHeight("45px"); tf.setWidth("100%"); tf.addStyleName("childtf"); newItem.getItemProperty("text").setValue(tf); @@ -119,7 +103,7 @@ public class TextFieldRelativeWidth extends TestBase { } @Override - protected String getDescription() { + protected String getTestDescription() { return "The table has 3 columns. The second column is expanded and contains 100% wide textfields. These should fill the available space. The third column is empty."; } diff --git a/uitest/src/com/vaadin/tests/components/table/TextFieldRelativeWidthTest.java b/uitest/src/com/vaadin/tests/components/table/TextFieldRelativeWidthTest.java new file mode 100644 index 0000000000..520ffa1aec --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TextFieldRelativeWidthTest.java @@ -0,0 +1,45 @@ +/* + * 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.table; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests that a TextField with 100% width fills the expanded column. + * + * @author Vaadin Ltd + */ +public class TextFieldRelativeWidthTest extends MultiBrowserTest { + + @Test + public void testWidth() throws IOException { + openTestURL(); + + compareScreen("initial"); + + ButtonElement button = $(ButtonElement.class).first(); + button.click(); + button.click(); + + compareScreen("after"); + } + +} -- cgit v1.2.3 From 9f1f5c5638757f7b727e300c7f437fd805914c54 Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Tue, 12 Aug 2014 15:07:45 +0300 Subject: Add new "colored" style for Label (Valo) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makes any Label text colored, by default the same as $v-selection-color. Modify the Forms and Labels examples to use the new style, and remove the fixed color from “light” style form layout for header labels. Change-Id: I27a4fce56b1f734aa5c2c837bf1684284b0d96cc --- WebContent/VAADIN/themes/valo/components/_formlayout.scss | 1 - WebContent/VAADIN/themes/valo/components/_label.scss | 5 +++++ server/src/com/vaadin/ui/themes/ValoTheme.java | 5 +++++ uitest/src/com/vaadin/tests/themes/valo/Forms.java | 3 +++ uitest/src/com/vaadin/tests/themes/valo/Labels.java | 5 +++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/WebContent/VAADIN/themes/valo/components/_formlayout.scss b/WebContent/VAADIN/themes/valo/components/_formlayout.scss index 25dbfbef28..fc065cec3d 100644 --- a/WebContent/VAADIN/themes/valo/components/_formlayout.scss +++ b/WebContent/VAADIN/themes/valo/components/_formlayout.scss @@ -198,7 +198,6 @@ > .v-label-h3, > .v-label-h4 { border-bottom: none; - color: $v-selection-color; } > .v-label-h3, diff --git a/WebContent/VAADIN/themes/valo/components/_label.scss b/WebContent/VAADIN/themes/valo/components/_label.scss index 51e7026834..e61aa4ec11 100644 --- a/WebContent/VAADIN/themes/valo/components/_label.scss +++ b/WebContent/VAADIN/themes/valo/components/_label.scss @@ -1,6 +1,7 @@ $v-font-weight--header: $v-font-weight - 100 !default; $v-line-height--header: 1.1 !default; $v-font-family--header: null !default; +$v-font-color--colored: $v-selection-color !default; $v-font-size--h1: 2.4em !default; $v-font-size--h2: 1.6em !default; @@ -104,6 +105,10 @@ $v-letter-spacing--h4: 0 !default; @if $include-additional-styles { + .#{$primary-stylename}-colored { + color: $v-font-color--colored; + } + .#{$primary-stylename}-large { font-size: $v-font-size--large; } diff --git a/server/src/com/vaadin/ui/themes/ValoTheme.java b/server/src/com/vaadin/ui/themes/ValoTheme.java index ea6b9082f8..d6bd97ed72 100644 --- a/server/src/com/vaadin/ui/themes/ValoTheme.java +++ b/server/src/com/vaadin/ui/themes/ValoTheme.java @@ -185,6 +185,11 @@ public class ValoTheme { */ public static final String LABEL_BOLD = "bold"; + /** + * Colored text. Can be combined with any other Label style. + */ + public static final String LABEL_COLORED = "colored"; + /** * Success badge style. Adds a border around the label and an icon next to * the text. Suitable for UI notifications that need to in the direct diff --git a/uitest/src/com/vaadin/tests/themes/valo/Forms.java b/uitest/src/com/vaadin/tests/themes/valo/Forms.java index c5b08902be..90a6c51496 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/Forms.java +++ b/uitest/src/com/vaadin/tests/themes/valo/Forms.java @@ -59,6 +59,7 @@ public class Forms extends VerticalLayout implements View { Label section = new Label("Personal Info"); section.addStyleName("h2"); + section.addStyleName("colored"); form.addComponent(section); StringGenerator sg = new StringGenerator(); @@ -85,6 +86,7 @@ public class Forms extends VerticalLayout implements View { section = new Label("Contact Info"); section.addStyleName("h3"); + section.addStyleName("colored"); form.addComponent(section); TextField email = new TextField("Email"); @@ -125,6 +127,7 @@ public class Forms extends VerticalLayout implements View { section = new Label("Additional Info"); section.addStyleName("h4"); + section.addStyleName("colored"); form.addComponent(section); TextField website = new TextField("Website"); diff --git a/uitest/src/com/vaadin/tests/themes/valo/Labels.java b/uitest/src/com/vaadin/tests/themes/valo/Labels.java index 63c138093c..b5bab3a1d3 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/Labels.java +++ b/uitest/src/com/vaadin/tests/themes/valo/Labels.java @@ -102,6 +102,11 @@ public class Labels extends VerticalLayout implements View { label.addStyleName("light"); right.addComponent(label); + label = new Label( + "Colored type for highlighted text. Etiam at risus et justo dignissim congue. Donec congue lacinia dui, a porttitor lectus condimentum laoreet. Nunc eu."); + label.addStyleName("colored"); + right.addComponent(label); + label = new Label("A label for success"); label.addStyleName("success"); right.addComponent(label); -- cgit v1.2.3 From 56c98c7bf18a2aa2b5e86db0f46b1cdb3f900822 Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Tue, 12 Aug 2014 15:27:06 +0300 Subject: Make read only textfield visually different from normal text fields If the background color of the app is the same as the textfield background color, make the textfield background color slightly darker. Change-Id: I4870c3e396cdd8c586bfd3f0e812cf1f5ebab1eb --- WebContent/VAADIN/themes/valo/components/_textfield.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebContent/VAADIN/themes/valo/components/_textfield.scss b/WebContent/VAADIN/themes/valo/components/_textfield.scss index dc516048e7..0b4fa50fb2 100644 --- a/WebContent/VAADIN/themes/valo/components/_textfield.scss +++ b/WebContent/VAADIN/themes/valo/components/_textfield.scss @@ -1,5 +1,5 @@ $v-textfield-background-color: if(is-dark-color($v-app-background-color), darken($v-app-background-color, 4%), lighten($v-app-background-color, 8%)) !default; -$v-textfield-background-color--readonly: $v-app-background-color; +$v-textfield-background-color--readonly: darkest-color($v-app-background-color, darken($v-textfield-background-color, 2%)); $v-textfield-bevel: inset 0 1px 0 v-shade !default; $v-textfield-shadow: 0 1px 0 (v-tint 2) !default; $v-textfield-font-weight: 400 !default; -- cgit v1.2.3 From 50a879e52e56d3acb3b8b8e77c2a86753e0c0385 Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Tue, 12 Aug 2014 13:19:54 +0300 Subject: PopupDateFieldExtendedRange test upgrade (#14292) Change-Id: I62f3f17cfbd5ddb5e1cd1b6085f4437fa49cfad1 --- .../datefield/PopupDateFieldExtendedRange.html | 136 ------ .../datefield/PopupDateFieldExtendedRange.java | 13 +- .../datefield/PopupDateFieldExtendedRangeTest.java | 510 +++++++++++++++++++++ 3 files changed, 517 insertions(+), 142 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.html create mode 100644 uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRangeTest.java diff --git a/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.html b/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.html deleted file mode 100644 index 2783ed2aa3..0000000000 --- a/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.html +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - -PopupDateFieldExtendedRange - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PopupDateFieldExtendedRange
open/run/com.vaadin.tests.components.datefield.PopupDateFieldExtendedRange?restartApplication
mouseClickvaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VPopupCalendar[0]#popupButton7,16
screenCapturepopup1-01-2011
mouseClickvaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]#prevmon8,7
screenCapturepopup1-12-2010
mouseClickvaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]#prevy12,6
screenCapturepopup1-12-2009
mouseClickvaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VPopupCalendar[0]#popupButton10,13
clickvaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]
mouseClickvaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPopupCalendar[0]#popupButton14,13
screenCapturepopup2-02-2010
pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]down
pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]down
screenCapturepopup2-03-2010
pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]left
pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]left
screenCapturepopup2-02-2010-again
mouseClickvaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPopupCalendar[0]#popupButton7,16
mouseClickvaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VPopupCalendar[0]#popupButton17,10
pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]shift left
screenCapturepopup3-01-2010
pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]shift down
screenCapturepopup3-01-2009
mouseClickvaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VPopupCalendar[0]#popupButton10,8
- - diff --git a/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.java b/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.java index a12bdfa44c..2608e6e081 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.java +++ b/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.java @@ -3,20 +3,21 @@ package com.vaadin.tests.components.datefield; import java.util.Calendar; import java.util.Locale; -import com.vaadin.tests.components.TestBase; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.datefield.Resolution; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.DateField; import com.vaadin.ui.PopupDateField; @SuppressWarnings("serial") -public class PopupDateFieldExtendedRange extends TestBase { +public class PopupDateFieldExtendedRange extends AbstractTestUI { private Calendar date = Calendar.getInstance(); @Override - protected void setup() { + protected void setup(VaadinRequest request) { date.set(2011, 0, 1); getLayout().setSpacing(true); @@ -52,7 +53,7 @@ public class PopupDateFieldExtendedRange extends TestBase { } @Override - protected String getDescription() { + protected String getTestDescription() { return "Show a few days of the preceding and following months in the datefield popup"; } @@ -63,7 +64,7 @@ public class PopupDateFieldExtendedRange extends TestBase { private PopupDateField makeDateField() { PopupDateField pdf = new PopupDateField(); - pdf.setResolution(DateField.RESOLUTION_DAY); + pdf.setResolution(Resolution.DAY); pdf.setValue(date.getTime()); return pdf; } diff --git a/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRangeTest.java b/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRangeTest.java new file mode 100644 index 0000000000..6d22048d32 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRangeTest.java @@ -0,0 +1,510 @@ +/* + * 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.datefield; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.DateFieldElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests contents and functionality of PopupDateField's popup. + * + * @author Vaadin Ltd + */ +public class PopupDateFieldExtendedRangeTest extends MultiBrowserTest { + + @Override + @Before + public void setup() throws Exception { + super.setup(); + openTestURL(); + } + + @Test + public void testFirstDateField() { + List dateFields = $(DateFieldElement.class).all(); + assertEquals("unexpected amount of datefields", 3, dateFields.size()); + + DateFieldElement dateField = dateFields.get(0); + + // open the popup + dateField.findElement(By.tagName("button")).click(); + + assertTrue("popup not found when there should be one", + isElementPresent(By.className("v-datefield-popup"))); + + // verify contents + WebElement popup = findElement(By.className("v-datefield-popup")); + assertEquals( + "unexpected month", + "tammikuu 2011", + popup.findElements( + By.className("v-datefield-calendarpanel-month")).get(1) + .getText()); + List headerElements = popup.findElement( + By.className("v-datefield-calendarpanel-weekdays")) + .findElements(By.tagName("td")); + List weekdays = new ArrayList(); + for (WebElement headerElement : headerElements) { + if ("columnheader".equals(headerElement.getAttribute("role"))) { + weekdays.add(headerElement); + } + } + assertEquals("unexpected weekday count", 7, weekdays.size()); + assertEquals("unexpected first day of week", "MA", weekdays.get(0) + .getText()); + assertEquals( + "unexpected weeknumber count", + 0, + popup.findElements( + By.className("v-datefield-calendarpanel-weeknumber")) + .size()); + assertEquals( + "unexpected selection", + "1", + popup.findElement( + By.className("v-datefield-calendarpanel-day-selected")) + .getText()); + assertEquals( + "unexpected focus", + "1", + popup.findElement( + By.className("v-datefield-calendarpanel-day-focused")) + .getText()); + List days = popup.findElements(By + .className("v-datefield-calendarpanel-day")); + assertEquals("unexpected day count", 42, days.size()); + assertEquals("unexpected day content", "27", days.get(0).getText()); + assertEquals("unexpected day content", "4", days.get(8).getText()); + assertEquals("unexpected day content", "21", days.get(25).getText()); + assertEquals("unexpected day content", "6", days.get(41).getText()); + + // move to the previous month + popup.findElement(By.className("v-datefield-calendarpanel-prevmonth")) + .findElement(By.tagName("button")).click(); + + // verify contents + assertEquals( + "unexpected month", + "joulukuu 2010", + popup.findElements( + By.className("v-datefield-calendarpanel-month")).get(1) + .getText()); + assertEquals( + "unexpected selection", + "1", + popup.findElement( + By.className("v-datefield-calendarpanel-day-selected")) + .getText()); + assertEquals( + "unexpected focus", + 0, + popup.findElements( + By.className("v-datefield-calendarpanel-day-focused")) + .size()); + days = popup + .findElements(By.className("v-datefield-calendarpanel-day")); + assertEquals("unexpected day count", 42, days.size()); + assertEquals("unexpected day content", "29", days.get(0).getText()); + assertEquals("unexpected day content", "7", days.get(8).getText()); + assertEquals("unexpected day content", "24", days.get(25).getText()); + assertEquals("unexpected day content", "9", days.get(41).getText()); + + // move to the previous year + popup.findElement(By.className("v-datefield-calendarpanel-prevyear")) + .findElement(By.tagName("button")).click(); + + // verify contents + assertEquals( + "unexpected month", + "joulukuu 2009", + popup.findElements( + By.className("v-datefield-calendarpanel-month")).get(1) + .getText()); + assertEquals( + "unexpected selection", + 0, + popup.findElements( + By.className("v-datefield-calendarpanel-day-selected")) + .size()); + assertEquals( + "unexpected focus", + 0, + popup.findElements( + By.className("v-datefield-calendarpanel-day-focused")) + .size()); + days = popup + .findElements(By.className("v-datefield-calendarpanel-day")); + assertEquals("unexpected day count", 42, days.size()); + assertEquals("unexpected day content", "30", days.get(0).getText()); + assertEquals("unexpected day content", "8", days.get(8).getText()); + assertEquals("unexpected day content", "25", days.get(25).getText()); + assertEquals("unexpected day content", "10", days.get(41).getText()); + + // close the popup by clicking the button again + dateField.findElement(By.tagName("button")).click(); + + // TODO: remove this once #14405 has been fixed + if (!getBrowsersExcludingIE().contains(getDesiredCapabilities())) { + // click something else outside the popup to close it + dateField.findElement(By.tagName("input")).click(); + } + + assertFalse("popup found when there should be none", + isElementPresent(By.className("v-datefield-popup"))); + } + + @Test + public void testSecondDateField() throws InterruptedException { + DateFieldElement dateField = $(DateFieldElement.class).all().get(1); + ButtonElement button = $(ButtonElement.class).first(); + + // change the date + button.click(); + sleep(100); + + // open the popup + dateField.findElement(By.tagName("button")).click(); + + assertTrue("popup not found when there should be one", + isElementPresent(By.className("v-datefield-popup"))); + + // verify contents + WebElement popup = findElement(By.className("v-datefield-popup")); + assertEquals( + "unexpected month", + "February 2010", + popup.findElements( + By.className("v-datefield-calendarpanel-month")).get(1) + .getText()); + List headerElements = popup.findElement( + By.className("v-datefield-calendarpanel-weekdays")) + .findElements(By.tagName("td")); + List weekdays = new ArrayList(); + for (WebElement headerElement : headerElements) { + if ("columnheader".equals(headerElement.getAttribute("role"))) { + weekdays.add(headerElement); + } + } + assertEquals("unexpected weekday count", 7, weekdays.size()); + assertEquals("unexpected first day of week", "SUN", weekdays.get(0) + .getText()); + assertEquals( + "unexpected weeknumber count", + 0, + popup.findElements( + By.className("v-datefield-calendarpanel-weeknumber")) + .size()); + assertEquals( + "unexpected selection", + "16", + popup.findElement( + By.className("v-datefield-calendarpanel-day-selected")) + .getText()); + assertEquals( + "unexpected focus", + "16", + popup.findElement( + By.className("v-datefield-calendarpanel-day-focused")) + .getText()); + List days = popup.findElements(By + .className("v-datefield-calendarpanel-day")); + assertEquals("unexpected day count", 42, days.size()); + assertEquals("unexpected day content", "31", days.get(0).getText()); + assertEquals("unexpected day content", "8", days.get(8).getText()); + assertEquals("unexpected day content", "25", days.get(25).getText()); + assertEquals("unexpected day content", "13", days.get(41).getText()); + + // navigate down + WebElement popupBody = popup.findElement(By + .className("v-datefield-calendarpanel")); + popupBody.sendKeys(Keys.ARROW_DOWN); + + // ensure the focus changed + assertEquals( + "unexpected focus", + "23", + popup.findElement( + By.className("v-datefield-calendarpanel-day-focused")) + .getText()); + + // navigate down + popupBody.sendKeys(Keys.ARROW_DOWN); + + // verify contents + assertEquals( + "unexpected month", + "March 2010", + popup.findElements( + By.className("v-datefield-calendarpanel-month")).get(1) + .getText()); + assertEquals( + "unexpected selection", + 0, + popup.findElements( + By.className("v-datefield-calendarpanel-day-selected")) + .size()); + assertEquals( + "unexpected focus", + "2", + popup.findElement( + By.className("v-datefield-calendarpanel-day-focused")) + .getText()); + days = popup + .findElements(By.className("v-datefield-calendarpanel-day")); + assertEquals("unexpected day count", 42, days.size()); + assertEquals("unexpected day content", "28", days.get(0).getText()); + assertEquals("unexpected day content", "8", days.get(8).getText()); + assertEquals("unexpected day content", "25", days.get(25).getText()); + assertEquals("unexpected day content", "10", days.get(41).getText()); + + // navigate left + popupBody = popup + .findElement(By.className("v-datefield-calendarpanel")); + popupBody.sendKeys(Keys.ARROW_LEFT); + + // ensure the focus changed + assertEquals( + "unexpected focus", + "1", + popup.findElement( + By.className("v-datefield-calendarpanel-day-focused")) + .getText()); + + // navigate left + popupBody.sendKeys(Keys.ARROW_LEFT); + + // verify contents + assertEquals( + "unexpected month", + "February 2010", + popup.findElements( + By.className("v-datefield-calendarpanel-month")).get(1) + .getText()); + assertEquals( + "unexpected selection", + "16", + popup.findElement( + By.className("v-datefield-calendarpanel-day-selected")) + .getText()); + assertEquals( + "unexpected focus", + "28", + popup.findElement( + By.className("v-datefield-calendarpanel-day-focused")) + .getText()); + days = popup + .findElements(By.className("v-datefield-calendarpanel-day")); + assertEquals("unexpected day count", 42, days.size()); + assertEquals("unexpected day content", "31", days.get(0).getText()); + assertEquals("unexpected day content", "8", days.get(8).getText()); + assertEquals("unexpected day content", "25", days.get(25).getText()); + assertEquals("unexpected day content", "13", days.get(41).getText()); + + // close the popup by clicking the input field + dateField.findElement(By.tagName("input")).click(); + + assertFalse("popup found when there should be none", + isElementPresent(By.className("v-datefield-popup"))); + } + + @Test + public void testThirdDateField() throws InterruptedException { + DateFieldElement dateField = $(DateFieldElement.class).all().get(2); + ButtonElement button = $(ButtonElement.class).first(); + + // change the date + button.click(); + sleep(100); + + // open the popup + dateField.findElement(By.tagName("button")).click(); + + assertTrue("popup not found when there should be one", + isElementPresent(By.className("v-datefield-popup"))); + + // verify contents + WebElement popup = findElement(By.className("v-datefield-popup")); + assertEquals( + "unexpected month", + "helmikuu 2010", + popup.findElements( + By.className("v-datefield-calendarpanel-month")).get(1) + .getText()); + List headerElements = popup.findElement( + By.className("v-datefield-calendarpanel-weekdays")) + .findElements(By.tagName("td")); + List weekdays = new ArrayList(); + for (WebElement headerElement : headerElements) { + if ("columnheader".equals(headerElement.getAttribute("role"))) { + weekdays.add(headerElement); + } + } + assertEquals("unexpected weekday count", 7, weekdays.size()); + assertEquals("unexpected first day of week", "MA", weekdays.get(0) + .getText()); + List weeknumbers = popup.findElements(By + .className("v-datefield-calendarpanel-weeknumber")); + assertEquals("unexpected weeknumber count", 6, weeknumbers.size()); + assertEquals("unexpected weeknumber content", "5", weeknumbers.get(0) + .getText()); + assertEquals("unexpected weeknumber content", "10", weeknumbers.get(5) + .getText()); + assertEquals( + "unexpected selection", + "16", + popup.findElement( + By.className("v-datefield-calendarpanel-day-selected")) + .getText()); + assertEquals( + "unexpected focus", + "16", + popup.findElement( + By.className("v-datefield-calendarpanel-day-focused")) + .getText()); + List days = popup.findElements(By + .className("v-datefield-calendarpanel-day")); + assertEquals("unexpected day count", 42, days.size()); + assertEquals("unexpected day content", "1", days.get(0).getText()); + assertEquals("unexpected day content", "9", days.get(8).getText()); + assertEquals("unexpected day content", "26", days.get(25).getText()); + assertEquals("unexpected day content", "14", days.get(41).getText()); + + // navigate to previous month + WebElement popupBody = popup.findElement(By + .className("v-datefield-calendarpanel")); + new Actions(driver).keyDown(Keys.SHIFT).perform(); + popupBody.sendKeys(Keys.ARROW_LEFT); + new Actions(driver).keyUp(Keys.SHIFT).perform(); + + // TODO: remove this once #14406 has been fixed + if (!getBrowsersExcludingIE().contains(getDesiredCapabilities()) + && !Browser.IE8.getDesiredCapabilities().equals( + getDesiredCapabilities())) { + popup.findElement( + By.className("v-datefield-calendarpanel-prevmonth")) + .findElement(By.tagName("button")).click(); + } + + // verify contents + assertEquals( + "unexpected month", + "tammikuu 2010", + popup.findElements( + By.className("v-datefield-calendarpanel-month")).get(1) + .getText()); + weeknumbers = popup.findElements(By + .className("v-datefield-calendarpanel-weeknumber")); + assertEquals("unexpected weeknumber count", 6, weeknumbers.size()); + assertEquals("unexpected weeknumber content", "53", weeknumbers.get(0) + .getText()); + assertEquals("unexpected weeknumber content", "5", weeknumbers.get(5) + .getText()); + assertEquals( + "unexpected selection", + 0, + popup.findElements( + By.className("v-datefield-calendarpanel-day-selected")) + .size()); + // TODO: remove this check once #14406 has been fixed -- clicking the + // button instead of navigating with arrow keys steals the focus + if (getBrowsersExcludingIE().contains(getDesiredCapabilities()) + || Browser.IE8.getDesiredCapabilities().equals( + getDesiredCapabilities())) { + assertEquals( + "unexpected focus", + "16", + popup.findElement( + By.className("v-datefield-calendarpanel-day-focused")) + .getText()); + } + days = popup + .findElements(By.className("v-datefield-calendarpanel-day")); + assertEquals("unexpected day count", 42, days.size()); + assertEquals("unexpected day content", "28", days.get(0).getText()); + assertEquals("unexpected day content", "5", days.get(8).getText()); + assertEquals("unexpected day content", "22", days.get(25).getText()); + assertEquals("unexpected day content", "7", days.get(41).getText()); + + // navigate to previous year + new Actions(driver).keyDown(Keys.SHIFT).perform(); + popupBody.sendKeys(Keys.ARROW_DOWN); + new Actions(driver).keyUp(Keys.SHIFT).perform(); + + // TODO: remove this once #14406 has been fixed + popup.findElement(By.className("v-datefield-calendarpanel-prevyear")) + .findElement(By.tagName("button")).click(); + + // verify contents + assertEquals( + "unexpected month", + "tammikuu 2009", + popup.findElements( + By.className("v-datefield-calendarpanel-month")).get(1) + .getText()); + weeknumbers = popup.findElements(By + .className("v-datefield-calendarpanel-weeknumber")); + assertEquals("unexpected weeknumber count", 6, weeknumbers.size()); + assertEquals("unexpected weeknumber content", "1", weeknumbers.get(0) + .getText()); + assertEquals("unexpected weeknumber content", "6", weeknumbers.get(5) + .getText()); + assertEquals( + "unexpected selection", + 0, + popup.findElements( + By.className("v-datefield-calendarpanel-day-selected")) + .size()); + // TODO: remove this check once #14406 has been fixed -- clicking the + // button instead of navigating with arrow keys steals the focus + if (false) { + assertEquals( + "unexpected focus", + "16", + popup.findElement( + By.className("v-datefield-calendarpanel-day-focused")) + .getText()); + } + days = popup + .findElements(By.className("v-datefield-calendarpanel-day")); + assertEquals("unexpected day count", 42, days.size()); + assertEquals("unexpected day content", "29", days.get(0).getText()); + assertEquals("unexpected day content", "6", days.get(8).getText()); + assertEquals("unexpected day content", "23", days.get(25).getText()); + assertEquals("unexpected day content", "8", days.get(41).getText()); + + // close the popup by clicking an unrelated element + button.click(); + + assertFalse("popup found when there should be none", + isElementPresent(By.className("v-datefield-popup"))); + } + +} -- cgit v1.2.3 From 12a588b53e53bc883be08298554a6adeedc5946b Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Tue, 12 Aug 2014 15:02:40 +0300 Subject: Modularize menubar mixins and add submenu indicator for top level items MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactored menubar mixins so that less overrides are necessary from normal button styles, and so that custom colored and custom sized menu bars are possible. Add new examples to test app for “drop down buttons” and “split buttons” using MenuBar. Change-Id: I2b0b76817d1c9119f82b2c2f4d7e5b95a9f05a5c --- WebContent/VAADIN/themes/tests-valo/_valotest.scss | 4 + .../VAADIN/themes/valo/components/_menubar.scss | 85 ++++++++++++---------- .../src/com/vaadin/tests/themes/valo/MenuBars.java | 71 ++++++++++++++++++ 3 files changed, 121 insertions(+), 39 deletions(-) diff --git a/WebContent/VAADIN/themes/tests-valo/_valotest.scss b/WebContent/VAADIN/themes/tests-valo/_valotest.scss index 7c024b323e..568dfec0b8 100644 --- a/WebContent/VAADIN/themes/tests-valo/_valotest.scss +++ b/WebContent/VAADIN/themes/tests-valo/_valotest.scss @@ -141,4 +141,8 @@ .v-accordion-item-color1 .v-accordion-item-caption { @include valo-accordion-item-caption-style($background-color: $color2); } + + .v-menubar-color1 { + @include valo-menubar-style($background-color: $v-selection-color, $unit-size: null); + } } diff --git a/WebContent/VAADIN/themes/valo/components/_menubar.scss b/WebContent/VAADIN/themes/valo/components/_menubar.scss index e79e6898a9..7d7e854989 100644 --- a/WebContent/VAADIN/themes/valo/components/_menubar.scss +++ b/WebContent/VAADIN/themes/valo/components/_menubar.scss @@ -1,24 +1,8 @@ @mixin valo-menubar ($primary-stylename: v-menubar, $include-additional-styles: contains($v-included-additional-styles, menubar)) { .#{$primary-stylename} { - @include valo-button-static-style($states: normal, $vertical-centering: false); - @include valo-button-style($states: normal, $cursor: default); - padding: 0; - text-align: left; - overflow: hidden; - - &:focus:not(.v-disabled) { - @include valo-button-focus-style($border-fallback: none, $include-box-shadow: false); - $box-shadow: valo-bevel-and-shadow($bevel: $v-bevel, $shadow: $v-shadow, $gradient: $v-gradient); - @if type-of($v-focus-style) == list { - $box-shadow: $box-shadow, $v-focus-style; - } - @include box-shadow($box-shadow); - } - - &.v-disabled { - @include opacity($v-disabled-opacity); - } + @include valo-button-static-style($states: normal focus disabled, $vertical-centering: false); + @include valo-menubar-style; } .#{$primary-stylename}:active:after { @@ -60,6 +44,20 @@ .#{$primary-stylename} .#{$primary-stylename}-submenu-indicator { display: none; + + + .#{$primary-stylename}-menuitem-caption:after { + font-family: FontAwesome; + content: "\f078"; + font-size: 0.7em; + vertical-align: .15em; + margin: 0 -.2em 0 .5em; + // IE filters are not supported on pseudo elements + opacity: .5; + } + + + .#{$primary-stylename}-menuitem-caption:empty:after { + margin-left: -.2em; + } } .#{$primary-stylename}-popup { @@ -70,10 +68,10 @@ } } - + @if $include-additional-styles { .#{$primary-stylename}-small { - @include valo-menubar-small-style($unit-size: $v-unit-size--small); + @include valo-menubar-style($background-color: null, $unit-size: $v-unit-size--small); font-size: $v-font-size--small; } @@ -87,6 +85,27 @@ +@mixin valo-menubar-style ($primary-stylename: v-menubar, $background-color: $v-background-color, $unit-size: $v-unit-size) { + @include valo-button-style($states: normal focus, $cursor: default, $background-color: $background-color, $unit-size: $unit-size); + padding: 0; + text-align: left; + + @if $unit-size { + line-height: $unit-size - first-number($v-border) * 2 - 1px; + + > .#{$primary-stylename}-menuitem { + padding: 0 round($unit-size/2.6); + + &[class*="-icon-only"] { + width: $unit-size; + } + } + } +} + + + + @mixin valo-menubar-menuitem-style { $border-width: first-number($v-border); position: relative; @@ -95,10 +114,12 @@ @include box-sizing(border-box); @include valo-button-style($states: normal, $border-radius: 0, $shadow: null, $font-color: inherit, $cursor: pointer); background: transparent; + @include box-shadow(none); border-width: 0 $border-width 0 0; + border-color: inherit; height: 100%; + line-height: inherit; vertical-align: top; - line-height: $v-unit-size - $border-width*2 - 1px; text-align: center; @if $border-width == 0 { @@ -253,20 +274,6 @@ } - -@mixin valo-menubar-small-style ($primary-stylename: v-menubar, $unit-size: round($v-unit-size * 0.8)) { - height: $unit-size; - - .#{$primary-stylename}-menuitem { - line-height: $unit-size - first-number($v-border)*2; - padding: 0 round($unit-size/2.5); - - &[class*="-icon-only"] { - width: $unit-size; - } - } -} - @mixin valo-menubar-borderless-style ($primary-stylename: v-menubar) { border: none; border-radius: 0; @@ -275,9 +282,8 @@ background: transparent; color: inherit; - &:not(.v-disabled):focus { - border: none; - @include box-shadow(none); + &:focus:after { + display: none; } .#{$primary-stylename}-menuitem { @@ -294,7 +300,8 @@ } &:first-child, - &:last-child { + &:last-child, + &:first-child:last-child { border-radius: $v-border-radius; } diff --git a/uitest/src/com/vaadin/tests/themes/valo/MenuBars.java b/uitest/src/com/vaadin/tests/themes/valo/MenuBars.java index 88eea73513..4a0130931e 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/MenuBars.java +++ b/uitest/src/com/vaadin/tests/themes/valo/MenuBars.java @@ -18,6 +18,7 @@ package com.vaadin.tests.themes.valo; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.server.FontAwesome; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.MenuBar; import com.vaadin.ui.MenuBar.Command; @@ -53,6 +54,62 @@ public class MenuBars extends VerticalLayout implements View { menuBar.addStyleName("borderless"); menuBar.addStyleName("small"); addComponent(menuBar); + + Label h2 = new Label("Drop Down Button"); + h2.addStyleName("h2"); + addComponent(h2); + + HorizontalLayout wrap = new HorizontalLayout(); + wrap.addStyleName("wrapping"); + wrap.setSpacing(true); + addComponent(wrap); + + wrap.addComponent(getMenuButton("Normal", false)); + + MenuBar split = getMenuButton("Small", false); + split.addStyleName("small"); + wrap.addComponent(split); + + split = getMenuButton("Borderless", false); + split.addStyleName("borderless"); + wrap.addComponent(split); + + split = getMenuButton("Themed", false); + split.addStyleName("color1"); + wrap.addComponent(split); + + split = getMenuButton("Small", false); + split.addStyleName("color1"); + split.addStyleName("small"); + wrap.addComponent(split); + + h2 = new Label("Split Button"); + h2.addStyleName("h2"); + addComponent(h2); + + wrap = new HorizontalLayout(); + wrap.addStyleName("wrapping"); + wrap.setSpacing(true); + addComponent(wrap); + + wrap.addComponent(getMenuButton("Normal", true)); + + split = getMenuButton("Small", true); + split.addStyleName("small"); + wrap.addComponent(split); + + split = getMenuButton("Borderless", true); + split.addStyleName("borderless"); + wrap.addComponent(split); + + split = getMenuButton("Themed", true); + split.addStyleName("color1"); + wrap.addComponent(split); + + split = getMenuButton("Small", true); + split.addStyleName("color1"); + split.addStyleName("small"); + wrap.addComponent(split); } static MenuBar getMenuBar() { @@ -180,6 +237,20 @@ public class MenuBars extends VerticalLayout implements View { return menubar; } + static MenuBar getMenuButton(String caption, boolean splitButton) { + MenuBar split = new MenuBar(); + MenuBar.MenuItem dropdown = split.addItem(caption, null); + if (splitButton) { + dropdown = split.addItem("", null); + } + dropdown.addItem("Another Action", null); + dropdown.addItem("Secondary Action", null); + dropdown.addSeparator(); + dropdown.addItem("Last Action", null); + + return split; + } + @Override public void enter(ViewChangeEvent event) { // TODO Auto-generated method stub -- cgit v1.2.3 From e75aa11368629324e0f06708cce12a4d7d4e8d9c Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Fri, 15 Aug 2014 12:23:49 +0300 Subject: Remove unnecessary negative border radius declarations from menu bar (Valo) Change-Id: I3739cdacf6a117cd0d75cab3566a82ee0fedd6bd --- WebContent/VAADIN/themes/valo/components/_menubar.scss | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/WebContent/VAADIN/themes/valo/components/_menubar.scss b/WebContent/VAADIN/themes/valo/components/_menubar.scss index 7d7e854989..f03bc3d022 100644 --- a/WebContent/VAADIN/themes/valo/components/_menubar.scss +++ b/WebContent/VAADIN/themes/valo/components/_menubar.scss @@ -126,21 +126,25 @@ margin-right: 1px; } - $br: $v-border-radius - $border-width - 1px; + $br: max(0, $v-border-radius - $border-width); &:first-child { border-left-width: 0; - border-radius: $br 0 0 $br; + @if $v-border-radius > 0 { + border-radius: $br 0 0 $br; + } } &:last-child { - border-radius: 0 $br $br 0; - margin-right: -$border-width; + @if $v-border-radius > 0 { + border-radius: 0 $br $br 0; + } + border-right-width: 0; } &:first-child:last-child { - border-radius: $br; - border-right-width: 0; - margin-right: 0; + @if $v-border-radius > 0 { + border-radius: $br; + } } &:before { -- cgit v1.2.3 From 074f248f7ef1e4cd09420cc1f37dbcfc22325d0e Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Sat, 16 Aug 2014 19:58:11 +0300 Subject: Make test stable again Change-Id: I1e02ce31ec7f0235158a5b04812c031e040c7ba2 --- uitest/src/com/vaadin/tests/themes/valo/DateFields.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uitest/src/com/vaadin/tests/themes/valo/DateFields.java b/uitest/src/com/vaadin/tests/themes/valo/DateFields.java index bdc0dc5983..7738b2d6db 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/DateFields.java +++ b/uitest/src/com/vaadin/tests/themes/valo/DateFields.java @@ -173,13 +173,13 @@ public class DateFields extends VerticalLayout implements View { row.addComponent(date); date = new DateField("Tiny"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("tiny"); row.addComponent(date); date = new DateField("Huge"); - date.setValue(new Date()); + setDate(date); date.setResolution(Resolution.DAY); date.addStyleName("huge"); row.addComponent(date); -- cgit v1.2.3 From 4556b4e80b4334d581d010089293219b4f42d438 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Sun, 17 Aug 2014 00:07:36 +0300 Subject: Update GWT version (#14051) The new version fixes source map generation when collapse-all-properties is on Change-Id: I4bcf9bd64a8dd9bc2e65c225df9ba4313e3d4194 --- build.properties | 2 +- client/src/com/vaadin/DefaultWidgetSet.gwt.xml | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/build.properties b/build.properties index bd31158a3e..0a25dab4b9 100644 --- a/build.properties +++ b/build.properties @@ -6,5 +6,5 @@ vaadin.url=http://vaadin.com vaadin.java.version=1.6 vaadin.version=0.0.0.unversioned-development-build vaadin.sass.version=0.9.9 -gwt.version=2.6.0.vaadin4 +gwt.version=2.6.0.vaadin5 commons-io.version=2.4 diff --git a/client/src/com/vaadin/DefaultWidgetSet.gwt.xml b/client/src/com/vaadin/DefaultWidgetSet.gwt.xml index 461bd5ed1b..8512d547e3 100755 --- a/client/src/com/vaadin/DefaultWidgetSet.gwt.xml +++ b/client/src/com/vaadin/DefaultWidgetSet.gwt.xml @@ -15,7 +15,4 @@ larger. --> - - - -- cgit v1.2.3 From 035f82020a9d82d0d5ab6206f8d3ad606011c65a Mon Sep 17 00:00:00 2001 From: Bogdan Udrescu Date: Fri, 15 Aug 2014 16:05:53 +0300 Subject: TabSheet focus/blur API improvement (#14304) Simplify the new inner API in the VTabSheet which solves the focus/blur issue. The blur and focus events should be linked with the TabSheet component as a whole. Any click inside the TabSheet should trigger one single focus and any leave the blur. Change-Id: I90dd05f056441920a286b6debdc288fb1a9a7e10 --- client/src/com/vaadin/client/ui/VTabsheet.java | 289 +++++++++++++------------ 1 file changed, 156 insertions(+), 133 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index a2a6889e15..aff1848647 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -1295,40 +1295,79 @@ public class VTabsheet extends VTabsheetBase implements Focusable, return tb.getTab(activeTabIndex); } + @Override + public void setConnector(AbstractComponentConnector connector) { + super.setConnector(connector); + + focusBlurManager.connector = connector; + } + /* * The focus and blur manager instance. */ private FocusBlurManager focusBlurManager = new FocusBlurManager(); /* - * Manage the TabSheet component blur event. + * Generate the correct focus/blur events for the main TabSheet component + * (#14304). + * + * The TabSheet must fire one focus event when the user clicks on the tab + * bar (i.e. inner TabBar class) containing the Tabs or when the focus is + * provided to the TabSheet by any means. Also one blur event should be + * fired only when the user leaves the tab bar. After the user focus on the + * tab bar and before leaving it, no matter how many times he's pressing the + * Tabs or the scroll buttons, the TabSheet component should not fire any of + * those blur/focus events. + * + * The only focusable elements contained in the tab bar are the Tabs (see + * inner class Tab). The reason is the accessibility support. + * + * Having this in mind, the chosen solution path for our problem is to match + * a sequence of focus/blur events on the tabs, choose only the first focus + * and last blur events and pass only those further to the main component. + * Any consecutive blur/focus events on 2 Tabs must be ignored. + * + * Because in a blur event we don't know whether or not a focus will follow, + * we just defer a command initiated on the blur event to wait and see if + * any focus will appear. The command will be executed after the next focus, + * so if no focus was triggered in the mean while it'll submit the blur + * event to the main component, otherwise it'll do nothing, so the main + * component will not generate the blur.. */ - private class FocusBlurManager implements FocusedTabProvider { + private static class FocusBlurManager { // The real tab with focus on it. If the focus goes to another element // in the page this will be null. private Tab focusedTab; - @Override - public Tab getFocusedTab() { + /* + * Gets the focused tab. + */ + private Tab getFocusedTab() { return focusedTab; } - @Override - public void setFocusedTab(Tab focusedTab) { + /* + * Sets the local field tracking the focused tab. + */ + private void setFocusedTab(Tab focusedTab) { this.focusedTab = focusedTab; } + /* + * The ultimate focus/blur event dispatcher. + */ + private AbstractComponentConnector connector; + /** - * Process the focus event no matter where it occurs on the tab bar. - * We've added this method + * Delegate method for the onFocus event occurring on Tab. * * @since * @param newFocusTab * the new focused tab. - * @see #blur(Tab) + * @see #onBlur(Tab) */ - public void focus(Tab newFocusTab) { + public void onFocus(Tab newFocusTab) { if (connector.hasEventListener(EventId.FOCUS)) { @@ -1339,26 +1378,20 @@ public class VTabsheet extends VTabsheetBase implements Focusable, } } - removeBlurSchedule(); + cancelLastBlurSchedule(); setFocusedTab(newFocusTab); - - if (focusedTab.hasTooltip()) { - focusedTab.setAssistiveDescription(getVTooltip().getUniqueId()); - getVTooltip().showAssistive(focusedTab.getTooltipInfo()); - } - } /** - * Process the blur event for the current focusedTab. + * Delegate method for the onBlur event occurring on Tab. * * @param blurSource * the source of the blur. * - * @see #focus(Tab) + * @see #onFocus(Tab) */ - public void blur(Tab blurSource) { + public void onBlur(Tab blurSource) { if (focusedTab != null && focusedTab == blurSource) { if (connector.hasEventListener(EventId.BLUR)) { @@ -1372,149 +1405,131 @@ public class VTabsheet extends VTabsheetBase implements Focusable, */ private BlurCommand blurCommand; - /** + /* + * Execute the final blur command. + */ + private class BlurCommand implements Command { + + /* + * The blur source. + */ + private Tab blurSource; + + /** + * Create the blur command using the blur source. + * + * @param blurSource + * the source. + * @param focusedTabProvider + * provides the current focused tab. + */ + public BlurCommand(Tab blurSource) { + this.blurSource = blurSource; + } + + /** + * Stop the command from being executed. + * + * @since + */ + public void stopSchedule() { + blurSource = null; + } + + /** + * Schedule the command for a deferred execution. + * + * @since + */ + public void scheduleDeferred() { + Scheduler.get().scheduleDeferred(this); + } + + @Override + public void execute() { + + Tab focusedTab = getFocusedTab(); + + if (blurSource == null) { + return; + } + + // The focus didn't change since this blur triggered, so + // the new focused element is not a tab. + if (focusedTab == blurSource) { + + // We're certain there's no focus anymore. + focusedTab.removeAssistiveDescription(); + setFocusedTab(null); + + connector.getRpcProxy(FocusAndBlurServerRpc.class).blur(); + } + + // Call this to set it to null and be consistent. + cancelLastBlurSchedule(); + } + } + + /* * Schedule a new blur event for a deferred execution. */ - public void scheduleBlur(Tab blurSource) { + private void scheduleBlur(Tab blurSource) { - if (cancelNextBlurSchedule) { + if (nextBlurScheduleCancelled) { // This will set the stopNextBlurCommand back to false as well. - removeBlurSchedule(); + cancelLastBlurSchedule(); - // Leave this though to make things clear for the developer. - cancelNextBlurSchedule = false; + // Reset the status. + nextBlurScheduleCancelled = false; return; } - removeBlurSchedule(); + cancelLastBlurSchedule(); - blurCommand = new BlurCommand(blurSource, this); + blurCommand = new BlurCommand(blurSource); blurCommand.scheduleDeferred(); } /** - * Remove the last blur command from execution. + * Remove the last blur deferred command from execution. */ - public void removeBlurSchedule() { + public void cancelLastBlurSchedule() { if (blurCommand != null) { blurCommand.stopSchedule(); blurCommand = null; } - // Maybe this is not the best place to reset this, but we really - // want to make sure it'll reset at any time when something - // interact with the blur manager. Might change it later. - cancelNextBlurSchedule = false; + // We really want to make sure this flag gets reseted at any time + // when something interact with the blur manager and ther's no blur + // command scheduled (as we just canceled it). + nextBlurScheduleCancelled = false; } /** - * Cancel the next possible scheduled execution. + * Cancel the next scheduled execution. This method must be called only + * from an event occurring before the onBlur event. It's the case of IE + * which doesn't trigger the focus event, so we're using this approach + * to cancel the next blur event prior it's execution, calling the + * method from mouse down event. */ public void cancelNextBlurSchedule() { // Make sure there's still no other command to be executed. - removeBlurSchedule(); + cancelLastBlurSchedule(); - cancelNextBlurSchedule = true; + nextBlurScheduleCancelled = true; } - // Stupid workaround... - private boolean cancelNextBlurSchedule = false; - - } - - /* - * Wraps the focused tab. - */ - private interface FocusedTabProvider { - - /** - * Gets the focused Tab. - * - * @return the focused Tab. - */ - Tab getFocusedTab(); - - /** - * Sets the focused Tab. - * - * @param focusedTab - * the focused Tab. - */ - void setFocusedTab(Tab focusedTab); - - } - - /* - * Execute the final blur command. - */ - private class BlurCommand implements Command { - - /* - * The blur source. - */ - private Tab blurSource; - /* - * Provide the current focused Tab. - */ - private FocusedTabProvider focusedTabProvider; - - /** - * Create the blur command using the blur source. - * - * @param blurSource - * the source. - * @param focusedTabProvider - * provides the current focused tab. - */ - public BlurCommand(Tab blurSource, FocusedTabProvider focusedTabProvider) { - this.blurSource = blurSource; - this.focusedTabProvider = focusedTabProvider; - } - - /** - * Stop the command from being executed. - * - * @since + * Flag that the next deferred command won't get executed. This is + * useful in case of IE where the user focus event don't fire and we're + * using the mouse down event to track the focus. But the mouse down + * event triggers before the blur, so we need to cancel the deferred + * execution in advance. */ - public void stopSchedule() { - blurSource = null; - } - - /** - * Schedule the command for a deferred execution. - * - * @since - */ - public void scheduleDeferred() { - Scheduler.get().scheduleDeferred(this); - } - - @Override - public void execute() { + private boolean nextBlurScheduleCancelled = false; - Tab focusedTab = focusedTabProvider.getFocusedTab(); - - if (blurSource == null) { - return; - } - - // The focus didn't change since this blur triggered, so - // the new focused element is not a tab. - if (focusedTab == blurSource) { - - // We're certain there's no focus anymore. - focusedTab.removeAssistiveDescription(); - focusedTabProvider.setFocusedTab(null); - - connector.getRpcProxy(FocusAndBlurServerRpc.class).blur(); - } - - // Call this to set it to null and be consistent. - focusBlurManager.removeBlurSchedule(); - } } @Override @@ -1572,7 +1587,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, Object blurSource = event.getSource(); if (blurSource instanceof Tab) { - focusBlurManager.blur((Tab) blurSource); + focusBlurManager.onBlur((Tab) blurSource); } } @@ -1580,7 +1595,15 @@ public class VTabsheet extends VTabsheetBase implements Focusable, public void onFocus(FocusEvent event) { if (event.getSource() instanceof Tab) { - focusBlurManager.focus((Tab) event.getSource()); + Tab focusSource = (Tab) event.getSource(); + focusBlurManager.onFocus(focusSource); + + if (focusSource.hasTooltip()) { + focusSource.setAssistiveDescription(getVTooltip() + .getUniqueId()); + getVTooltip().showAssistive(focusSource.getTooltipInfo()); + } + } } @@ -1589,7 +1612,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, // IE doesn't trigger focus when click, so we need to make sure // the previous blur deferred command will get killed. - focusBlurManager.removeBlurSchedule(); + focusBlurManager.cancelLastBlurSchedule(); TabCaption caption = (TabCaption) event.getSource(); Element targetElement = event.getNativeEvent().getEventTarget() -- cgit v1.2.3 From f21099256e02b355c8d090eb669a5b9f0ce4b7cd Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Thu, 31 Jul 2014 11:36:44 +0300 Subject: TableRowScrolledBottom test upgrade (#14292) Change-Id: I382a4da5f186239c5791d1e63e9a75ece9039760 --- .../components/table/TableRowScrolledBottom.html | 52 --------------- .../components/table/TableRowScrolledBottom.java | 20 +++--- .../table/TableRowScrolledBottomTest.java | 73 ++++++++++++++++++++++ 3 files changed, 83 insertions(+), 62 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.html create mode 100644 uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottomTest.java diff --git a/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.html b/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.html deleted file mode 100644 index 5116fceb49..0000000000 --- a/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.table.TableRowScrolledBottom?restartApplication
clickvaadin=runcomvaadintestscomponentstableTableRowScrolledBottom::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]
pause500
assertTextvaadin=runcomvaadintestscomponentstableTableRowScrolledBottom::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[44]/VLabel[0]This is a test item with long text so that there is something to see Nr. 100. This text must be long otherwise the timing issue on Firefox does not occur. This works fine in IE
clickvaadin=runcomvaadintestscomponentstableTableRowScrolledBottom::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]
pause500
assertTextvaadin=runcomvaadintestscomponentstableTableRowScrolledBottom::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[44]/VLabel[0]This is a test item with long text so that there is something to see Nr. 200. This text must be long otherwise the timing issue on Firefox does not occur. This works fine in IE
- - diff --git a/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.java b/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.java index 7d48dfa11e..e1fe4d0514 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.java +++ b/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.java @@ -1,15 +1,19 @@ package com.vaadin.tests.components.table; +import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Label; import com.vaadin.ui.Table; -public class TableRowScrolledBottom extends TestBase { +public class TableRowScrolledBottom extends AbstractTestUI { + + final static String part1 = "This is a test item with long text so that there is something to see Nr. "; + final static String part2 = ". This text must be long otherwise the timing issue on Firefox does not occur. This works fine in IE"; @Override - protected void setup() { + protected void setup(VaadinRequest request) { final Table table = new Table(); table.setSizeFull(); @@ -24,12 +28,8 @@ public class TableRowScrolledBottom extends TestBase { public void buttonClick(Button.ClickEvent event) { for (int j = 0; j < 100; j++) { ++i; - table.addItem( - new Object[] { new Label( - "This is a test item with long text so that there is something to see Nr. " - + i - + ". This text must be long otherwise the timing issue on Firefox does not occur. This works fine in IE", - ContentMode.HTML) }, i); + table.addItem(new Object[] { new Label(part1 + "" + i + + "" + part2, ContentMode.HTML) }, i); table.setCurrentPageFirstItemIndex(table .getContainerDataSource().size() - 1); } @@ -42,7 +42,7 @@ public class TableRowScrolledBottom extends TestBase { } @Override - protected String getDescription() { + protected String getTestDescription() { return "Table should be scrolled to bottom when adding rows and updating currentPageFirstItemIndex to last item"; } diff --git a/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottomTest.java b/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottomTest.java new file mode 100644 index 0000000000..0fad02b410 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottomTest.java @@ -0,0 +1,73 @@ +/* + * 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.table; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests that adding long labels to a Table and scrolling to the bottom works as + * intended. + * + * @author Vaadin Ltd + */ +public class TableRowScrolledBottomTest extends MultiBrowserTest { + + @Test + public void testScrolling() throws IOException, InterruptedException { + openTestURL(); + + ButtonElement button = $(ButtonElement.class).first(); + TableElement table = $(TableElement.class).first(); + + // initialise contents + button.click(); + sleep(500); + + List rows = table.findElement(By.className("v-table-body")) + .findElements(By.tagName("tr")); + + // check that the final row is the one intended + WebElement finalRow = rows.get(rows.size() - 1); + WebElement label = finalRow.findElement(By.className("v-label")); + assertEquals(TableRowScrolledBottom.part1 + 100 + + TableRowScrolledBottom.part2, label.getText()); + + // add more rows + button.click(); + sleep(500); + + rows = table.findElement(By.className("v-table-body")).findElements( + By.tagName("tr")); + + // check that the final row is the one intended + finalRow = rows.get(rows.size() - 1); + label = finalRow.findElement(By.className("v-label")); + assertEquals(TableRowScrolledBottom.part1 + 200 + + TableRowScrolledBottom.part2, label.getText()); + } + +} -- cgit v1.2.3 From a960cfd12b8fb42ae78e39ffb61c04e3a3b831bf Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Tue, 12 Aug 2014 14:47:03 +0300 Subject: UIProviderInitParameter test upgrade (#14292) Change-Id: I44e7fa4b0d890972d4e6d14c3159aa9db9131c1d --- .../UIProviderInitParameter.html | 39 --------------- .../UIProviderInitParameterTest.java | 58 ++++++++++++++++++++++ 2 files changed, 58 insertions(+), 39 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/applicationservlet/UIProviderInitParameter.html create mode 100644 uitest/src/com/vaadin/tests/applicationservlet/UIProviderInitParameterTest.java diff --git a/uitest/src/com/vaadin/tests/applicationservlet/UIProviderInitParameter.html b/uitest/src/com/vaadin/tests/applicationservlet/UIProviderInitParameter.html deleted file mode 100644 index 8a5f89cbad..0000000000 --- a/uitest/src/com/vaadin/tests/applicationservlet/UIProviderInitParameter.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/uiprovider
assertTextvaadin=uiprovider::/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VLabel[0]Tests whether the testing server is run with assertions enabled.
open/uiprovider/test
assertTextvaadin=uiprovider::/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VLabel[0]Test for basic JavaScript component functionality.
- - diff --git a/uitest/src/com/vaadin/tests/applicationservlet/UIProviderInitParameterTest.java b/uitest/src/com/vaadin/tests/applicationservlet/UIProviderInitParameterTest.java new file mode 100644 index 0000000000..8197bbe8b8 --- /dev/null +++ b/uitest/src/com/vaadin/tests/applicationservlet/UIProviderInitParameterTest.java @@ -0,0 +1,58 @@ +/* + * 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.applicationservlet; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.junit.Test; + +import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class UIProviderInitParameterTest extends MultiBrowserTest { + + @Test + public void testDefault() { + // Test that UI parameter is used by default + openTestURL(); + + List labels = $(LabelElement.class).all(); + assertTrue("unexpected amount of labels", labels.size() > 2); + + LabelElement label = labels.get(labels.size() - 1); + String message = "Tests whether the testing server is run with assertions enabled."; + assertEquals("unexpected text found", message, label.getText()); + } + + @Test + public void testExtended() { + // Test that UIProvider parameter is more important than UI parameter + driver.get(getTestUrl().replace("uiprovider", "uiprovider/test")); + + LabelElement label = $(LabelElement.class).first(); + String message = "Test for basic JavaScript component functionality."; + assertEquals("unexpected text found", message, label.getText()); + } + + @Override + protected String getDeploymentPath() { + return "/uiprovider"; + } + +} -- cgit v1.2.3 From 1020faa337eddeb07f141cb7ef12fbb20bd2ded2 Mon Sep 17 00:00:00 2001 From: Sebastian Nyholm Date: Tue, 27 May 2014 14:46:47 +0300 Subject: Fixes DragAndDropWrapper does not support choosing a custom component as the drag image (#13836) Amend : Fixes the comments for the last commit. Amend 2: Fixes a nullpointer found in a certain test scenario Change-Id: I72327f5f8ab9e46d88e1ebed8f1db3a7da39d7d8 --- .../com/vaadin/client/ui/VDragAndDropWrapper.java | 27 +++++++++++++- .../DragAndDropWrapperConnector.java | 26 ++++++++++++++ server/src/com/vaadin/ui/DragAndDropWrapper.java | 41 ++++++++++++++++++++++ .../DragAndDropWrapperConstants.java | 2 ++ .../draganddropwrapper/DragStartModes.java | 31 ++++++++++++++-- .../draganddropwrapper/DragStartModesTest.java | 1 + 6 files changed, 125 insertions(+), 3 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java b/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java index 4010ffd542..7bf341a387 100644 --- a/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java +++ b/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java @@ -114,7 +114,8 @@ public class VDragAndDropWrapper extends VCustomComponent implements * @return true if the event was handled as a drag start event */ private boolean startDrag(NativeEvent event) { - if (dragStartMode == WRAPPER || dragStartMode == COMPONENT) { + if (dragStartMode == WRAPPER || dragStartMode == COMPONENT + || dragStartMode == COMPONENT_OTHER) { VTransferable transferable = new VTransferable(); transferable.setDragSource(getConnector()); @@ -130,6 +131,10 @@ public class VDragAndDropWrapper extends VCustomComponent implements if (dragStartMode == WRAPPER) { dragEvent.createDragImage(getElement(), true); + } else if (dragStartMode == COMPONENT_OTHER + && getDragImageWidget() != null) { + dragEvent.createDragImage(getDragImageWidget().getElement(), + true); } else { dragEvent.createDragImage(widget.getElement(), true); } @@ -142,6 +147,7 @@ public class VDragAndDropWrapper extends VCustomComponent implements protected final static int COMPONENT = 1; protected final static int WRAPPER = 2; protected final static int HTML5 = 3; + protected final static int COMPONENT_OTHER = 4; /** For internal use only. May be removed or replaced in the future. */ public int dragStartMode; @@ -458,6 +464,7 @@ public class VDragAndDropWrapper extends VCustomComponent implements * Flag used by html5 dd */ private boolean currentlyValid; + private Widget dragImageWidget; private static final String OVER_STYLE = "v-ddwrapper-over"; @@ -661,4 +668,22 @@ public class VDragAndDropWrapper extends VCustomComponent implements notifySizePotentiallyChanged(); } + /** + * Set the widget that will be used as the drag image when using + * DragStartMode {@link COMPONENT_OTHER} . + * + * @param widget + */ + public void setDragAndDropWidget(Widget widget) { + dragImageWidget = widget; + } + + /** + * @return the widget used as drag image. Returns null if no + * widget is set. + */ + public Widget getDragImageWidget() { + return dragImageWidget; + } + } diff --git a/client/src/com/vaadin/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java b/client/src/com/vaadin/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java index afb521b141..f222721e24 100644 --- a/client/src/com/vaadin/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java +++ b/client/src/com/vaadin/client/ui/draganddropwrapper/DragAndDropWrapperConnector.java @@ -17,8 +17,12 @@ package com.vaadin.client.ui.draganddropwrapper; import java.util.HashMap; import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.ComponentConnector; +import com.vaadin.client.ConnectorMap; import com.vaadin.client.Paintable; import com.vaadin.client.UIDL; import com.vaadin.client.VConsole; @@ -81,6 +85,25 @@ public class DragAndDropWrapperConnector extends CustomComponentConnector getWidget().dragStartMode = uidl .getIntAttribute(DragAndDropWrapperConstants.DRAG_START_MODE); + + String dragImageComponentConnectorId = uidl + .getStringAttribute(DragAndDropWrapperConstants.DRAG_START_COMPONENT_ATTRIBUTE); + + ComponentConnector connector = null; + if (dragImageComponentConnectorId != null) { + connector = (ComponentConnector) ConnectorMap.get(client) + .getConnector(dragImageComponentConnectorId); + + if (connector == null) { + getLogger().log( + Level.WARNING, + "DragAndDropWrapper drag image component" + + " connector now found. Make sure the" + + " component is attached."); + } else { + getWidget().setDragAndDropWidget(connector.getWidget()); + } + } getWidget().initDragStartMode(); getWidget().html5DataFlavors = uidl .getMapAttribute(DragAndDropWrapperConstants.HTML5_DATA_FLAVORS); @@ -95,4 +118,7 @@ public class DragAndDropWrapperConnector extends CustomComponentConnector return (VDragAndDropWrapper) super.getWidget(); } + private static Logger getLogger() { + return Logger.getLogger(DragAndDropWrapperConnector.class.getName()); + } } diff --git a/server/src/com/vaadin/ui/DragAndDropWrapper.java b/server/src/com/vaadin/ui/DragAndDropWrapper.java index 3d3356b338..0e2e8f6d2f 100644 --- a/server/src/com/vaadin/ui/DragAndDropWrapper.java +++ b/server/src/com/vaadin/ui/DragAndDropWrapper.java @@ -180,10 +180,17 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, * the wrapper will no longer work. */ HTML5, + + /** + * Uses the component defined in + * {@link #setDragImageComponent(Component)} as the drag image. + */ + COMPONENT_OTHER, } private final Map html5DataFlavors = new LinkedHashMap(); private DragStartMode dragStartMode = DragStartMode.NONE; + private Component dragImageComponent = null; private Set sentIds = new HashSet(); @@ -227,6 +234,19 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, public void paintContent(PaintTarget target) throws PaintException { target.addAttribute(DragAndDropWrapperConstants.DRAG_START_MODE, dragStartMode.ordinal()); + + if (dragStartMode.equals(DragStartMode.COMPONENT_OTHER)) { + if (dragImageComponent != null) { + target.addAttribute( + DragAndDropWrapperConstants.DRAG_START_COMPONENT_ATTRIBUTE, + dragImageComponent.getConnectorId()); + } else { + throw new IllegalArgumentException( + "DragStartMode.COMPONENT_OTHER set but no component " + + "was defined. Please set a component using DragAnd" + + "DropWrapper.setDragStartComponent(Component)."); + } + } if (getDropHandler() != null) { getDropHandler().getAcceptCriterion().paint(target); } @@ -300,6 +320,27 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, return dragStartMode; } + /** + * Sets the component that will be used as the drag image. Only used when + * wrapper is set to {@link DragStartMode#COMPONENT_OTHER} + * + * @param dragImageComponent + */ + public void setDragImageComponent(Component dragImageComponent) { + this.dragImageComponent = dragImageComponent; + markAsDirty(); + } + + /** + * Gets the component that will be used as the drag image. Only used when + * wrapper is set to {@link DragStartMode#COMPONENT_OTHER} + * + * @return null if no component is set. + */ + public Component getDragImageComponent() { + return dragImageComponent; + } + final class ProxyReceiver implements StreamVariable { private String id; diff --git a/shared/src/com/vaadin/shared/ui/draganddropwrapper/DragAndDropWrapperConstants.java b/shared/src/com/vaadin/shared/ui/draganddropwrapper/DragAndDropWrapperConstants.java index 8dd8ef513e..9dda86ad73 100644 --- a/shared/src/com/vaadin/shared/ui/draganddropwrapper/DragAndDropWrapperConstants.java +++ b/shared/src/com/vaadin/shared/ui/draganddropwrapper/DragAndDropWrapperConstants.java @@ -25,4 +25,6 @@ public class DragAndDropWrapperConstants implements Serializable { @Deprecated public static final String DRAG_START_MODE = "dragStartMode"; + public static final String DRAG_START_COMPONENT_ATTRIBUTE = "dragStartComponent"; + } diff --git a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragStartModes.java b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragStartModes.java index b143ddf2dc..8539f70b17 100644 --- a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragStartModes.java +++ b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragStartModes.java @@ -3,26 +3,53 @@ package com.vaadin.tests.components.draganddropwrapper; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.TestUtils; import com.vaadin.ui.Component; +import com.vaadin.ui.CssLayout; import com.vaadin.ui.DragAndDropWrapper; import com.vaadin.ui.DragAndDropWrapper.DragStartMode; import com.vaadin.ui.Label; +import com.vaadin.ui.VerticalLayout; public class DragStartModes extends TestBase { @Override protected void setup() { - TestUtils.injectCSS(getMainWindow(), - ".v-ddwrapper { background: #ACF; }"); + TestUtils + .injectCSS(getMainWindow(), + ".v-ddwrapper { background: #ACF; } .extra{ background: #FFA500; }"); addComponent(makeWrapper(DragStartMode.NONE)); addComponent(makeWrapper(DragStartMode.COMPONENT)); addComponent(makeWrapper(DragStartMode.WRAPPER)); addComponent(makeWrapper(DragStartMode.HTML5)); + addComponent(makeOtherComponentWrapper(DragStartMode.COMPONENT_OTHER)); addComponent(new Label("Drop here")); } + private Component makeOtherComponentWrapper(DragStartMode componentOther) { + VerticalLayout parent = new VerticalLayout(); + parent.setWidth("200px"); + parent.setSpacing(true); + + CssLayout header = new CssLayout(); + header.addComponent(new Label("Drag start mode : COMPONENT_OTHER")); + header.setSizeUndefined(); + + DragAndDropWrapper wrapper = new DragAndDropWrapper(header); + wrapper.setDragStartMode(DragStartMode.COMPONENT_OTHER); + wrapper.setDragImageComponent(parent); + wrapper.setId("label" + "COMPONENT_OTHER"); + parent.addComponent(wrapper); + + Label extra = new Label( + "Extra label that is not part of the wrapper. This should be dragged along with COMPONENT_OTHER."); + extra.addStyleName("extra"); + parent.addComponent(extra); + + return parent; + } + private Component makeWrapper(DragStartMode mode) { Label label = new Label("Drag start mode: " + mode); label.setId("label" + mode); diff --git a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragStartModesTest.java b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragStartModesTest.java index 25aef1b815..ba27ee293e 100644 --- a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragStartModesTest.java +++ b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragStartModesTest.java @@ -31,6 +31,7 @@ public class DragStartModesTest extends MultiBrowserTest { WebElement dropTarget = vaadinElement("/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[0]"); dragToTarget("COMPONENT", dropTarget); dragToTarget("WRAPPER", dropTarget); + dragToTarget("COMPONENT_OTHER", dropTarget); } private void dragToTarget(String dragMode, WebElement dropTarget) -- cgit v1.2.3 From e0411e7b3c4017542cbbd8d1203f011215e69afa Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Thu, 14 Aug 2014 16:58:28 +0300 Subject: TreeTablePartialUpdatesPageLength0 test upgrade (#14292) Change-Id: I8f7717138247c46d7b85f4fab46328d5d118dbef --- .../TreeTablePartialUpdatesPageLength0.html | 56 -------------- .../TreeTablePartialUpdatesPageLength0.java | 11 ++- .../TreeTablePartialUpdatesPageLength0Test.java | 86 ++++++++++++++++++++++ 3 files changed, 93 insertions(+), 60 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesPageLength0.html create mode 100644 uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesPageLength0Test.java diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesPageLength0.html b/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesPageLength0.html deleted file mode 100644 index 34ab0c0c2e..0000000000 --- a/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesPageLength0.html +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - -DisappearingComponents - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DisappearingComponents
open/run/com.vaadin.tests.components.treetable.TreeTablePartialUpdatesPageLength0?restartApplication
mouseClickvaadin=runcomvaadintestscomponentstreetableTreeTablePartialUpdatesPageLength0::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTreeTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,2
screenCaptureroot1-expanded-10-items
mouseClickvaadin=runcomvaadintestscomponentstreetableTreeTablePartialUpdatesPageLength0::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTreeTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[12]/domChild[0]/domChild[0]/domChild[0]11,3
mouseClickvaadin=runcomvaadintestscomponentstreetableTreeTablePartialUpdatesPageLength0::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTreeTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[11]/domChild[0]/domChild[0]/domChild[0]9,7
scrollvaadin=runcomvaadintestscomponentstreetableTreeTablePartialUpdatesPageLength0::12500
pause300
screenCaptureall-expanded-bottom
- - diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesPageLength0.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesPageLength0.java index 20412bf0e2..686d86a0dc 100644 --- a/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesPageLength0.java +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesPageLength0.java @@ -2,13 +2,14 @@ package com.vaadin.tests.components.treetable; import com.vaadin.data.Container.Hierarchical; import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.tests.components.TestBase; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.TreeTable; -public class TreeTablePartialUpdatesPageLength0 extends TestBase { +public class TreeTablePartialUpdatesPageLength0 extends AbstractTestUI { @Override - protected void setup() { + protected void setup(VaadinRequest request) { setTheme("reindeer-tests"); TreeTable tt = new TreeTable(); tt.addStyleName("table-equal-rowheight"); @@ -20,6 +21,7 @@ public class TreeTablePartialUpdatesPageLength0 extends TestBase { tt.getParent().getParent().setHeight(null); } + @SuppressWarnings("unchecked") private Hierarchical makeHierarchicalContainer() { HierarchicalContainer hc = new HierarchicalContainer(); hc.addContainerProperty("p1", String.class, ""); @@ -47,6 +49,7 @@ public class TreeTablePartialUpdatesPageLength0 extends TestBase { return hc; } + @SuppressWarnings("unchecked") private void addNodesToRoot(HierarchicalContainer hc, Object root, int count) { for (int ix = 0; ix < count; ix++) { Object id = hc.addItem(); @@ -56,7 +59,7 @@ public class TreeTablePartialUpdatesPageLength0 extends TestBase { } @Override - protected String getDescription() { + protected String getTestDescription() { return ""; } diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesPageLength0Test.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesPageLength0Test.java new file mode 100644 index 0000000000..d88c6ba7ca --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesPageLength0Test.java @@ -0,0 +1,86 @@ +/* + * 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.treetable; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.TreeTableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests expanding TreeTable rows when page length is zero. + * + * @author Vaadin Ltd + */ +public class TreeTablePartialUpdatesPageLength0Test extends MultiBrowserTest { + + @Test + public void testExpanding() throws IOException { + openTestURL(); + + TreeTableElement treeTable = $(TreeTableElement.class).first(); + List rows = treeTable.findElement( + By.className("v-table-body")).findElements(By.tagName("tr")); + assertEquals("unexpected row count", 4, rows.size()); + assertEquals("unexpected contents", "root1", treeTable.getCell(0, 0) + .getText()); + assertEquals("unexpected contents", "root2", treeTable.getCell(1, 0) + .getText()); + assertEquals("unexpected contents", "root3", treeTable.getCell(2, 0) + .getText()); + assertEquals("unexpected contents", "END", treeTable.getCell(3, 0) + .getText()); + + // expand first row, should have 10 children + treeTable.getCell(0, 0) + .findElement(By.className("v-treetable-treespacer")).click(); + + treeTable = $(TreeTableElement.class).first(); + rows = treeTable.findElement(By.className("v-table-body")) + .findElements(By.tagName("tr")); + assertEquals("unexpected row count", 14, rows.size()); + + // expand root3, should have 200 children + assertEquals("unexpected contents", "root3", treeTable.getCell(12, 0) + .getText()); + treeTable.getCell(12, 0) + .findElement(By.className("v-treetable-treespacer")).click(); + + // expand root2, should have 200 children + assertEquals("unexpected contents", "root2", treeTable.getCell(11, 0) + .getText()); + treeTable.getCell(11, 0) + .findElement(By.className("v-treetable-treespacer")).click(); + + treeTable = $(TreeTableElement.class).first(); + rows = treeTable.findElement(By.className("v-table-body")) + .findElements(By.tagName("tr")); + assertEquals("unexpected row count", 414, rows.size()); + + // scroll all the way to the bottom + WebElement ui = findElement(By.className("v-ui")); + testBenchElement(ui).scroll(12500); + + compareScreen("bottom"); + } +} -- cgit v1.2.3 From 4dcace7123b605115efcbb395a320d460eed9c0e Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Wed, 30 Jul 2014 12:04:47 +0300 Subject: SortLabelsInTable test upgrade (#14292) Change-Id: I07d2b0882ea5520f3d7ec30e29d4c42fb9167c9c --- .../tests/components/table/SortLabelsInTable.java | 13 +-- .../components/table/SortLabelsInTableTest.java | 93 ++++++++++++++++++++++ 2 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/table/SortLabelsInTableTest.java diff --git a/uitest/src/com/vaadin/tests/components/table/SortLabelsInTable.java b/uitest/src/com/vaadin/tests/components/table/SortLabelsInTable.java index 0dc8584169..499cce58c8 100644 --- a/uitest/src/com/vaadin/tests/components/table/SortLabelsInTable.java +++ b/uitest/src/com/vaadin/tests/components/table/SortLabelsInTable.java @@ -16,14 +16,16 @@ package com.vaadin.tests.components.table; import com.vaadin.data.Item; -import com.vaadin.tests.components.TestBase; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Label; import com.vaadin.ui.Table; -public class SortLabelsInTable extends TestBase { +public class SortLabelsInTable extends AbstractTestUI { + @SuppressWarnings("unchecked") @Override - protected void setup() { + protected void setup(VaadinRequest request) { Table t = new Table("A table with a text column and a Label column"); t.addContainerProperty("text", String.class, null); t.addContainerProperty("label", Label.class, null); @@ -37,9 +39,8 @@ public class SortLabelsInTable extends TestBase { } @Override - protected String getDescription() { - // TODO Auto-generated method stub - return null; + protected String getTestDescription() { + return "Tests that Labels are sorted in the same way than Strings are."; } @Override diff --git a/uitest/src/com/vaadin/tests/components/table/SortLabelsInTableTest.java b/uitest/src/com/vaadin/tests/components/table/SortLabelsInTableTest.java new file mode 100644 index 0000000000..54b5cad9b2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/SortLabelsInTableTest.java @@ -0,0 +1,93 @@ +/* + * 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.table; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.vaadin.testbench.elements.TableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests sorting labels in table. + * + * @author Vaadin Ltd + */ +public class SortLabelsInTableTest extends MultiBrowserTest { + + @Test + public void testSorting() { + openTestURL(); + + TableElement table = $(TableElement.class).first(); + + // check unsorted + assertEquals("Text 0", table.getCell(0, 0).getText()); + assertEquals("Label 0", table.getCell(0, 1).getText()); + assertEquals("Text 14", table.getCell(14, 0).getText()); + assertEquals("Label 14", table.getCell(14, 1).getText()); + + // sort by first column (ascending order) + table.getHeaderCell(0).click(); + + // check sorted + assertEquals("Text 0", table.getCell(0, 0).getText()); + assertEquals("Label 0", table.getCell(0, 1).getText()); + assertEquals("Text 10", table.getCell(2, 0).getText()); + assertEquals("Label 10", table.getCell(2, 1).getText()); + assertEquals("Text 19", table.getCell(11, 0).getText()); + assertEquals("Label 19", table.getCell(11, 1).getText()); + assertEquals("Text 4", table.getCell(14, 0).getText()); + assertEquals("Label 4", table.getCell(14, 1).getText()); + + // sort by first column (descending order) + table.getHeaderCell(0).click(); + + // check sorted + assertEquals("Text 9", table.getCell(0, 0).getText()); + assertEquals("Label 9", table.getCell(0, 1).getText()); + assertEquals("Text 19", table.getCell(8, 0).getText()); + assertEquals("Label 19", table.getCell(8, 1).getText()); + assertEquals("Text 13", table.getCell(14, 0).getText()); + assertEquals("Label 13", table.getCell(14, 1).getText()); + + // sort by second column (descending order) + table.getHeaderCell(1).click(); + + // check no change + assertEquals("Text 9", table.getCell(0, 0).getText()); + assertEquals("Label 9", table.getCell(0, 1).getText()); + assertEquals("Text 19", table.getCell(8, 0).getText()); + assertEquals("Label 19", table.getCell(8, 1).getText()); + assertEquals("Text 13", table.getCell(14, 0).getText()); + assertEquals("Label 13", table.getCell(14, 1).getText()); + + // sort by second column (ascending order) + table.getHeaderCell(1).click(); + + // check back to first sorting results + assertEquals("Text 0", table.getCell(0, 0).getText()); + assertEquals("Label 0", table.getCell(0, 1).getText()); + assertEquals("Text 10", table.getCell(2, 0).getText()); + assertEquals("Label 10", table.getCell(2, 1).getText()); + assertEquals("Text 19", table.getCell(11, 0).getText()); + assertEquals("Label 19", table.getCell(11, 1).getText()); + assertEquals("Text 4", table.getCell(14, 0).getText()); + assertEquals("Label 4", table.getCell(14, 1).getText()); + } + +} -- cgit v1.2.3