From acf28902774c68919726051984e847bcedaf7a3f Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Wed, 12 Nov 2014 10:06:22 +0200 Subject: Revert "Table column width can be changed from defined to expandratio (#15101)" This reverts commit 7237b88645a27b157bc85d62292dc93faddd19f9. Change-Id: Ifbe26c90a91a21a1ac416bda8e59acbbd80cf5f0 --- client/src/com/vaadin/client/ui/VScrollTable.java | 1 - .../tests/components/table/TableExpandRatio.java | 110 --------------------- .../components/table/TableExpandRatioTest.java | 88 ----------------- 3 files changed, 199 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/table/TableExpandRatio.java delete mode 100644 uitest/src/com/vaadin/tests/components/table/TableExpandRatioTest.java diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index b07d2dc9c0..6c241f1033 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -3636,7 +3636,6 @@ public class VScrollTable extends FlowPanel implements HasWidgets, c.setWidth(widthWithoutAddedIndent, true); } } else if (col.hasAttribute("er")) { - c.setUndefinedWidth(); c.setExpandRatio(col.getFloatAttribute("er")); } else if (recalcWidths) { diff --git a/uitest/src/com/vaadin/tests/components/table/TableExpandRatio.java b/uitest/src/com/vaadin/tests/components/table/TableExpandRatio.java deleted file mode 100644 index 92c9b8d988..0000000000 --- a/uitest/src/com/vaadin/tests/components/table/TableExpandRatio.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2000-2014 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.table; - -import java.util.Arrays; - -import com.vaadin.annotations.PreserveOnRefresh; -import com.vaadin.annotations.Theme; -import com.vaadin.data.util.BeanItemContainer; -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.Table; -import com.vaadin.ui.VerticalLayout; - -@PreserveOnRefresh -@Theme("valo") -public class TableExpandRatio extends AbstractTestUI { - - @Override - protected void setup(VaadinRequest request) { - - BeanItemContainer container = new BeanItemContainer( - MyItem.class, Arrays.asList(new MyItem("one", 1), new MyItem( - "two", 2))); - - final Table table = new Table(null, container); - - table.setWidth("800px"); - table.setImmediate(true); - - Button widthButton = new Button("Set Width", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.setColumnWidth("value", 300); - - } - }); - - Button expandButton = new Button("Set Expand Ratio", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - table.setColumnExpandRatio("value", 1); - - } - }); - - widthButton.setId("widthbutton"); - expandButton.setId("expandbutton"); - - VerticalLayout layout = new VerticalLayout(widthButton, expandButton, - table); - addComponent(layout); - } - - public class MyItem { - - private String name; - private Integer value; - - public MyItem(String name, Integer value) { - this.name = name; - this.value = value; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getValue() { - return value; - } - - public void setValue(Integer value) { - this.value = value; - } - } - - @Override - protected String getTestDescription() { - return "When a column has fixed width and it is changed to expand ratio, the width should update accordingly"; - } - - @Override - protected Integer getTicketNumber() { - return 15101; - } -} diff --git a/uitest/src/com/vaadin/tests/components/table/TableExpandRatioTest.java b/uitest/src/com/vaadin/tests/components/table/TableExpandRatioTest.java deleted file mode 100644 index 3cf66d4e4b..0000000000 --- a/uitest/src/com/vaadin/tests/components/table/TableExpandRatioTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2000-2014 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.table; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.number.IsCloseTo.closeTo; - -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; - -public class TableExpandRatioTest extends MultiBrowserTest { - - @Override - public void setup() throws Exception { - super.setup(); - - openTestURL(); - } - - /* - * Needed for IE to get focus when button is clicked - */ - @Override - protected boolean requireWindowFocusForIE() { - - return true; - } - - @Test - public void cellWidthUpdatesWhenExpandRatioSetAfterDefinedWidth() { - - // test that after setting defined size to the second column, the first - // column will have correct size - - setDefinedWidth(); - - assertThat(getFirstCellWidth(), closeTo(500, 10)); - - // test that after setting expandratio to the second column, it is - // correct - - setExpandRatio(); - - assertThat(getFirstCellWidth(), closeTo(65, 5)); - - } - - private void setExpandRatio() { - $(ButtonElement.class).id("expandbutton").click(); - } - - private void setDefinedWidth() { - $(ButtonElement.class).id("widthbutton").click(); - } - - private double getFirstCellWidth() { - - List rows = $(TableElement.class).first() - .findElement(By.className("v-table-body")) - .findElements(By.tagName("tr")); - WebElement firstrow = rows.get(0); - List cells = firstrow.findElements(By - .className("v-table-cell-content")); - - int cellwidth = cells.get(0).getSize().getWidth(); - return cellwidth; - } -} -- cgit v1.2.3 From eb4e2314fbd016b4ef4bd1640c5fc48876f9a46d Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Fri, 14 Nov 2014 12:21:26 +0200 Subject: Drop indicators in Valo are now working as in Reindeer theme (#14836) Change-Id: I12014c4329ca629dbfc9226b3b70538d33442690 --- .../VAADIN/themes/valo/components/_table.scss | 61 +++++++--------- .../components/table/TableDropIndicatorValo.java | 53 ++++++++++++++ .../table/TableDropIndicatorValoTest.java | 81 ++++++++++++++++++++++ 3 files changed, 159 insertions(+), 36 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValo.java create mode 100644 uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValoTest.java diff --git a/WebContent/VAADIN/themes/valo/components/_table.scss b/WebContent/VAADIN/themes/valo/components/_table.scss index a70532ccfd..019d8673ce 100644 --- a/WebContent/VAADIN/themes/valo/components/_table.scss +++ b/WebContent/VAADIN/themes/valo/components/_table.scss @@ -238,6 +238,7 @@ $v-table-background-color: null !default; border-left: $v-table-border-width solid $border-color; overflow: hidden; height: $v-table-row-height; + vertical-align: middle; &:first-child { border-left: none; @@ -520,46 +521,28 @@ $v-table-background-color: null !default; } } - .#{$primary-stylename}-row-drag-middle td:first-child:before { - content: ""; - display: block; - position: absolute; - z-index: 1; - height: $v-table-row-height + $v-table-border-width; - left: 0; - right: 0; - background: $v-focus-color; - @include opacity(.2); + .#{$primary-stylename}-row-drag-middle .#{$primary-stylename}-cell-content { + $bg: mix($v-focus-color, $background-color, 20%); + background-color: $bg; + color: valo-font-color($bg); } - .#{$primary-stylename}-row-drag-top td:first-child:before, - .#{$primary-stylename}-row-drag-bottom td:first-child:after { - content: "\2022"; - display: block; - position: absolute; - height: 2px; - left: 0; - right: 0; - background: $v-focus-color; - font-size: $v-font-size * 2; - line-height: 2px; - color: $v-focus-color; - text-indent: round($v-font-size/-4); - text-shadow: 0 0 1px $background-color, 0 0 1px $background-color; + .#{$primary-stylename}-row-drag-bottom td.#{$primary-stylename}-cell-content { + border-bottom: 2px solid $v-focus-color; + height: $v-table-row-height - 2px; } - .#{$primary-stylename}-row-drag-top td:first-child:before { - margin-top: -$v-table-border-width; + .#{$primary-stylename}-row-drag-bottom .#{$primary-stylename}-cell-wrapper { + margin-bottom: -2px; } - .v-ff & .#{$primary-stylename}-row-drag-top td:first-child:before, - .v-ff & .#{$primary-stylename}-row-drag-bottom td:first-child:after { - line-height: 1px; + .#{$primary-stylename}-row-drag-top td.#{$primary-stylename}-cell-content { + border-top: 2px solid $v-focus-color; + height: $v-table-row-height - 2px + $v-table-border-width; } - .v-ie & .#{$primary-stylename}-row-drag-top td:first-child:before, - .v-ie & .#{$primary-stylename}-row-drag-bottom td:first-child:after { - line-height: 0; + .#{$primary-stylename}-row-drag-top .#{$primary-stylename}-cell-wrapper { + margin-top: -1px; } @@ -700,6 +683,11 @@ $v-table-background-color: null !default; border-top: none; border-bottom: none; } + + .#{$primary-stylename}-row-drag-top .#{$primary-stylename}-cell-content, + .#{$primary-stylename}-row-drag-bottom .#{$primary-stylename}-cell-content { + height: $v-table-row-height - 1px; + } } @@ -814,10 +802,6 @@ $v-table-background-color: null !default; margin-top: round($row-height/-2); } - .#{$primary-stylename}-row-drag-middle td:first-child:before { - height: $row-height + $v-table-border-width; - } - &.v-treetable { .#{$primary-stylename}-cell-wrapper { padding-left: 0; @@ -839,4 +823,9 @@ $v-table-background-color: null !default; padding-right: $cell-padding-horizontal; } } + + .#{$primary-stylename}-row-drag-top .#{$primary-stylename}-cell-content, + .#{$primary-stylename}-row-drag-bottom .#{$primary-stylename}-cell-content { + height: $row-height - 1px; + } } diff --git a/uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValo.java b/uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValo.java new file mode 100644 index 0000000000..e3848bb152 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValo.java @@ -0,0 +1,53 @@ +package com.vaadin.tests.components.table; + +import com.vaadin.annotations.Theme; +import com.vaadin.event.dd.DragAndDropEvent; +import com.vaadin.event.dd.DropHandler; +import com.vaadin.event.dd.acceptcriteria.AcceptAll; +import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Table; + +@Theme("valo") +@SuppressWarnings("serial") +public class TableDropIndicatorValo extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + + Table table = new Table(); + + table.addContainerProperty("foo", Integer.class, 0); + table.addContainerProperty("bar", Integer.class, 0); + // table.addContainerProperty("button", Button.class, null); + + for (int i = 0; i < 40; i++) { + // Button b = new Button("testbutton"); + // b.setHeight("50px"); + table.addItem(new Object[] { i, i }, i); + } + + table.setDragMode(Table.TableDragMode.ROW); + table.setSelectable(true); + + table.setDropHandler(new DropHandler() { + @Override + public void drop(DragAndDropEvent dragAndDropEvent) { + + } + + @Override + public AcceptCriterion getAcceptCriterion() { + return AcceptAll.get(); + } + }); + + addComponent(table); + } + + @Override + protected String getTestDescription() { + return "Tests if the drop indicator appears between two rows as it should"; + } +} \ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValoTest.java b/uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValoTest.java new file mode 100644 index 0000000000..82a66eba07 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableDropIndicatorValoTest.java @@ -0,0 +1,81 @@ +/* + * 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.util.List; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.elements.TableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests that clicking on active fields doesn't change Table selection, nor does + * dragging rows. + * + * @author Vaadin Ltd + */ + +public class TableDropIndicatorValoTest extends MultiBrowserTest { + + @Override + public void setup() throws Exception { + + super.setup(); + openTestURL(); + } + + @Test + public void indicator() throws Exception { + + dragRowWithoutDropping(1); + compareScreen("indicator"); + } + + private List getCellContents(WebElement row) { + + return row.findElements(By.className("v-table-cell-content")); + } + + private List getRows() { + + return getTable().findElement(By.className("v-table-body")) + .findElements(By.tagName("tr")); + } + + private TableElement getTable() { + + return $(TableElement.class).first(); + } + + private void dragRowWithoutDropping(int from) { + + List rows = getRows(); + WebElement row = rows.get(from); + List cellContents = getCellContents(row); + + int rowHeight = row.getSize().getHeight(); + int halfRowHeight = (int) (rowHeight + 0.5) / 2; // rounded off + int oneAndAHalfRow = rowHeight + halfRowHeight; + + new Actions(getDriver()).moveToElement(cellContents.get(1)) + .clickAndHold().moveByOffset(0, oneAndAHalfRow).perform(); + } +} \ No newline at end of file -- cgit v1.2.3 From c4075e1f2fe0b35a7f90564c4315f03403826caa Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Fri, 14 Nov 2014 14:57:15 +0200 Subject: Revert "DateField popup doesn't close when click on popup button (#14857)" This reverts commit 457e802e2fe59ec35089a55acdc7b0321a2d4a5a. Patch does not fix the issue with "slow" clicks when closing the calendar. Change-Id: I48384e081cf66dd4fc6cded8ecbd94cef5db57bb --- .../src/com/vaadin/client/ui/VPopupCalendar.java | 79 +++------------------- .../datefield/DateFieldPopupClosing.java | 43 ------------ .../datefield/DateFieldPopupClosingTest.java | 42 ------------ 3 files changed, 11 insertions(+), 153 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java delete mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java diff --git a/client/src/com/vaadin/client/ui/VPopupCalendar.java b/client/src/com/vaadin/client/ui/VPopupCalendar.java index fbd66cff09..51b2ee22ec 100644 --- a/client/src/com/vaadin/client/ui/VPopupCalendar.java +++ b/client/src/com/vaadin/client/ui/VPopupCalendar.java @@ -27,10 +27,6 @@ import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.DomEvent; import com.google.gwt.event.dom.client.KeyCodes; -import com.google.gwt.event.dom.client.MouseOutEvent; -import com.google.gwt.event.dom.client.MouseOutHandler; -import com.google.gwt.event.dom.client.MouseOverEvent; -import com.google.gwt.event.dom.client.MouseOverHandler; import com.google.gwt.event.logical.shared.CloseEvent; import com.google.gwt.event.logical.shared.CloseHandler; import com.google.gwt.i18n.client.DateTimeFormat; @@ -64,8 +60,7 @@ import com.vaadin.shared.ui.datefield.Resolution; * */ public class VPopupCalendar extends VTextualDate implements Field, - ClickHandler, MouseOverHandler, MouseOutHandler, - CloseHandler, SubPartAware { + ClickHandler, CloseHandler, SubPartAware { /** For internal use only. May be removed or replaced in the future. */ public final Button calendarToggle = new Button(); @@ -80,20 +75,6 @@ public class VPopupCalendar extends VTextualDate implements Field, public boolean parsable = true; private boolean open = false; - /* - * To resolve #14857. If to click on calendarToggle button when calendar - * popup is opened (*1) then we have the following chain of calls: - * - * 1) onClose() 2) onClick() - * - * In this case we should prevent calling openCalendarPanel() in onClick. - */ - private boolean preventOpenPopupCalendar = false; - /* - * To resolve #14857. To determine this situation (*1) we use onMouseOver - * and OnMouseOut (for calendarToggle button). - */ - private boolean cursorOverCalendarToggleButton = false; private boolean textFieldEnabled = true; @@ -108,10 +89,6 @@ public class VPopupCalendar extends VTextualDate implements Field, calendarToggle.setText(""); calendarToggle.addClickHandler(this); - - calendarToggle.addMouseOverHandler(this); - calendarToggle.addMouseOutHandler(this); - // -2 instead of -1 to avoid FocusWidget.onAttach to reset it calendarToggle.getElement().setTabIndex(-2); @@ -464,10 +441,7 @@ public class VPopupCalendar extends VTextualDate implements Field, @Override public void onClick(ClickEvent event) { if (event.getSource() == calendarToggle && isEnabled()) { - if (!preventOpenPopupCalendar) { - openCalendarPanel(); - } - preventOpenPopupCalendar = false; + openCalendarPanel(); } } @@ -490,22 +464,15 @@ public class VPopupCalendar extends VTextualDate implements Field, focus(); } - open = false; - - if (cursorOverCalendarToggleButton) { - preventOpenPopupCalendar = true; - - // To resolve the problem: onMouseOut event not triggered when - // moving mouse fast (GWT - all browsers) - Timer unPreventClickTimer = new Timer() { - @Override - public void run() { - preventOpenPopupCalendar = false; - } - }; - - unPreventClickTimer.schedule(300); - } + // TODO resolve what the "Sigh." is all about and document it here + // Sigh. + Timer t = new Timer() { + @Override + public void run() { + open = false; + } + }; + t.schedule(100); } } @@ -675,28 +642,4 @@ public class VPopupCalendar extends VTextualDate implements Field, calendar.setRangeEnd(rangeEnd); } - /* - * (non-Javadoc) - * - * @see - * com.google.gwt.event.dom.client.MouseOverHandler#onMouseOver(com.google - * .gwt.event.dom.client.MouseOverEvent) - */ - @Override - public void onMouseOver(MouseOverEvent event) { - cursorOverCalendarToggleButton = true; - } - - /* - * (non-Javadoc) - * - * @see - * com.google.gwt.event.dom.client.MouseOutHandler#onMouseOut(com.google - * .gwt.event.dom.client.MouseOutEvent) - */ - @Override - public void onMouseOut(MouseOutEvent event) { - cursorOverCalendarToggleButton = false; - } - } diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java deleted file mode 100644 index 60508a30d4..0000000000 --- a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2000-2014 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.components.datefield; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.DateField; - -public class DateFieldPopupClosing extends AbstractTestUI { - - static final String DATEFIELD_ID = "datefield"; - - @Override - protected void setup(VaadinRequest request) { - final DateField df = new DateField(); - df.setId(DATEFIELD_ID); - addComponent(df); - } - - @Override - protected String getTestDescription() { - return "DateField popup should be closed when click on popup button"; - } - - @Override - protected Integer getTicketNumber() { - return 14857; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java deleted file mode 100644 index ecbd6dd667..0000000000 --- a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.vaadin.tests.components.datefield; - -import java.io.IOException; - -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.support.ui.ExpectedConditions; - -import com.vaadin.testbench.elements.DateFieldElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class DateFieldPopupClosingTest extends MultiBrowserTest { - /* - * try to open/close many times (not one time) because this defect is - * reproduced randomly (depends on timer) - */ - private static final int N = 100; - - @Test - public void testDateFieldPopupClosing() throws InterruptedException, - IOException { - openTestURL(); - - for (int i = 0; i < N; i++) { - clickDateDatePickerButton(); - - waitUntil(ExpectedConditions.visibilityOfElementLocated(By - .className("v-datefield-popup"))); - - clickDateDatePickerButton(); - - waitUntil(ExpectedConditions.invisibilityOfElementLocated(By - .className("v-datefield-popup"))); - } - } - - private void clickDateDatePickerButton() { - DateFieldElement dateField = $(DateFieldElement.class).first(); - dateField.findElement(By.tagName("button")).click(); - } - -} \ No newline at end of file -- cgit v1.2.3 From 488b4694519ee5d3451a5a6d70868d74b9cd8682 Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Fri, 14 Nov 2014 21:15:55 +0200 Subject: Make junit.test.suite a property. Change-Id: I3dd66e5f11a99efc3777513dc0e2989e8007c9c1 --- .../src/com/vaadin/tests/tb3/ChangedTB3TestLocator.java | 17 ++++++++++++++--- .../com/vaadin/tests/tb3/PrivateTB3Configuration.java | 17 +++++++++++------ uitest/tb3test.xml | 6 ++---- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/uitest/src/com/vaadin/tests/tb3/ChangedTB3TestLocator.java b/uitest/src/com/vaadin/tests/tb3/ChangedTB3TestLocator.java index b425de48b5..a2f8ceeefa 100644 --- a/uitest/src/com/vaadin/tests/tb3/ChangedTB3TestLocator.java +++ b/uitest/src/com/vaadin/tests/tb3/ChangedTB3TestLocator.java @@ -102,15 +102,26 @@ public class ChangedTB3TestLocator extends TB3TestLocator { List diffsInWorkingTree = new ArrayList(); for (DiffEntry diff : diffCommand.call()) { - // Exclude temporary junit files. - if (!diff.getNewPath().startsWith("uitest/junit")) { - diffsInWorkingTree.add(diff); + if (pathIsExcluded(diff.getNewPath())) { + continue; } + + diffsInWorkingTree.add(diff); } return diffsInWorkingTree; } + private boolean pathIsExcluded(String path) { + // Exclude temporary junit files and screeenshots. + return path.startsWith("uitest/junit") + || getScreenshotDirectory().contains(path); + } + + private String getScreenshotDirectory() { + return System.getProperty(PrivateTB3Configuration.SCREENSHOT_DIRECTORY); + } + private List getDiffsInHead(Repository repository) throws AmbiguousObjectException, IncorrectObjectTypeException, IOException, MissingObjectException { diff --git a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java index a4bb85bb53..f2f4af3910 100644 --- a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java +++ b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java @@ -42,10 +42,14 @@ import com.vaadin.tests.tb3.MultiBrowserTest.Browser; * Provides values for parameters which depend on where the test is run. * Parameters should be configured in work/eclipse-run-selected-test.properties. * A template is available in uitest/. - * + * * @author Vaadin Ltd */ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { + /** + * + */ + public static final String SCREENSHOT_DIRECTORY = "com.vaadin.testbench.screenshot.directory"; private static final String RUN_LOCALLY_PROPERTY = "com.vaadin.testbench.runLocally"; private static final String HOSTNAME_PROPERTY = "com.vaadin.testbench.deployment.hostname"; private static final String PORT_PROPERTY = "com.vaadin.testbench.deployment.port"; @@ -84,10 +88,11 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { @Override protected String getScreenshotDirectory() { - String screenshotDirectory = getProperty("com.vaadin.testbench.screenshot.directory"); + String screenshotDirectory = getProperty(SCREENSHOT_DIRECTORY); if (screenshotDirectory == null) { throw new RuntimeException( - "No screenshot directory defined. Use -Dcom.vaadin.testbench.screenshot.directory="); + "No screenshot directory defined. Use -D" + + SCREENSHOT_DIRECTORY + "="); } return screenshotDirectory; } @@ -116,7 +121,7 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { /** * Gets the hostname that tests are configured to use. - * + * * @return the host name configuration value */ public static String getConfiguredDeploymentHostname() { @@ -136,7 +141,7 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { /** * Gets the port that tests are configured to use. - * + * * @return the port configuration value */ public static int getConfiguredDeploymentPort() { @@ -153,7 +158,7 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { /** * Tries to automatically determine the IP address of the machine the test * is running on. - * + * * @return An IP address of one of the network interfaces in the machine. * @throws RuntimeException * if there was an error or no IP was found diff --git a/uitest/tb3test.xml b/uitest/tb3test.xml index 975298926e..ecacf43ee2 100644 --- a/uitest/tb3test.xml +++ b/uitest/tb3test.xml @@ -9,6 +9,7 @@ + @@ -18,13 +19,10 @@ - - - + - -- cgit v1.2.3 From 1d12fc07677debcac711586b5a57c2f397f3ec1f Mon Sep 17 00:00:00 2001 From: Denis Anisimov Date: Sat, 8 Nov 2014 12:47:05 +0200 Subject: Set v-bevel to 'false' should unset 'v-textfield-bevel' value (#14634). Change-Id: Ia3598b9bcef280bef38daa189ab3c7885e5d535a --- .../tests-valo-textfield-bevel/_variables.scss | 3 ++ .../themes/tests-valo-textfield-bevel/styles.scss | 6 +++ .../VAADIN/themes/valo/components/_textfield.scss | 2 +- .../vaadin/tests/themes/valo/TextFieldBevel.java | 52 +++++++++++++++++++ .../tests/themes/valo/TextFieldBevelTest.java | 59 ++++++++++++++++++++++ 5 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 WebContent/VAADIN/themes/tests-valo-textfield-bevel/_variables.scss create mode 100644 WebContent/VAADIN/themes/tests-valo-textfield-bevel/styles.scss create mode 100644 uitest/src/com/vaadin/tests/themes/valo/TextFieldBevel.java create mode 100644 uitest/src/com/vaadin/tests/themes/valo/TextFieldBevelTest.java diff --git a/WebContent/VAADIN/themes/tests-valo-textfield-bevel/_variables.scss b/WebContent/VAADIN/themes/tests-valo-textfield-bevel/_variables.scss new file mode 100644 index 0000000000..b1b215a40c --- /dev/null +++ b/WebContent/VAADIN/themes/tests-valo-textfield-bevel/_variables.scss @@ -0,0 +1,3 @@ +$v-bevel: false; + +@import "../valo/valo"; diff --git a/WebContent/VAADIN/themes/tests-valo-textfield-bevel/styles.scss b/WebContent/VAADIN/themes/tests-valo-textfield-bevel/styles.scss new file mode 100644 index 0000000000..96a3ca63b6 --- /dev/null +++ b/WebContent/VAADIN/themes/tests-valo-textfield-bevel/styles.scss @@ -0,0 +1,6 @@ +@import "variables"; +@import "../tests-valo/valotest"; + +.tests-valo-textfield-bevel { + @include valotest; +} diff --git a/WebContent/VAADIN/themes/valo/components/_textfield.scss b/WebContent/VAADIN/themes/valo/components/_textfield.scss index 58f69e5e4c..50cb7b8042 100644 --- a/WebContent/VAADIN/themes/valo/components/_textfield.scss +++ b/WebContent/VAADIN/themes/valo/components/_textfield.scss @@ -14,7 +14,7 @@ $v-textfield-background-color--readonly: darkest-color($v-app-background-color, * The bevel style for text fields. See the documentation for $v-bevel. * @group textfield */ -$v-textfield-bevel: inset 0 1px 0 v-shade !default; +$v-textfield-bevel: if($v-bevel and ($v-bevel != none), inset 0 1px 0 v-shade, $v-bevel) !default; /** * The shadow style for text fields. See the documentation for $v-shadow. diff --git a/uitest/src/com/vaadin/tests/themes/valo/TextFieldBevel.java b/uitest/src/com/vaadin/tests/themes/valo/TextFieldBevel.java new file mode 100644 index 0000000000..4e1debc5b6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/valo/TextFieldBevel.java @@ -0,0 +1,52 @@ +/* + * 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 com.vaadin.annotations.Theme; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.TextField; + +/** + * Test UI for $v-textfield-bevel value in TextField component. + * + * @author Vaadin Ltd + */ +@Theme("tests-valo-textfield-bevel") +public class TextFieldBevel extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + TextField field = new TextField(); + addComponent(field); + } + + @Override + protected Integer getTicketNumber() { + return 14634; + } + + @Override + protected String getTestDescription() { + return "Set v-bevel to 'false' should unset 'v-textfield-bevel' value."; + } + + @Theme("valo") + public static class ValoDefaultTextFieldBevel extends TextFieldBevel { + + } + +} diff --git a/uitest/src/com/vaadin/tests/themes/valo/TextFieldBevelTest.java b/uitest/src/com/vaadin/tests/themes/valo/TextFieldBevelTest.java new file mode 100644 index 0000000000..ee2cdd41f8 --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/valo/TextFieldBevelTest.java @@ -0,0 +1,59 @@ +/* + * 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.Assert; +import org.junit.Test; + +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test for $v-textfield-bevel value when $v-bevel is unset. + * + * @author Vaadin Ltd + */ +public class TextFieldBevelTest extends MultiBrowserTest { + + @Test + public void testTextFieldBevel() { + String url = getTestUrl(); + StringBuilder defaultValoUi = new StringBuilder( + TextFieldBevel.class.getSimpleName()); + defaultValoUi.append('$'); + defaultValoUi.append(TextFieldBevel.ValoDefaultTextFieldBevel.class + .getSimpleName()); + url = url.replace(TextFieldBevel.class.getSimpleName(), + defaultValoUi.toString()); + getDriver().get(url); + + String defaultBoxShadow = $(TextFieldElement.class).first() + .getCssValue("box-shadow"); + + if (url.contains("restartApplication")) { + openTestURL(); + } else { + openTestURL("restartApplication"); + } + + String boxShadow = $(TextFieldElement.class).first().getCssValue( + "box-shadow"); + + Assert.assertNotEquals( + "Set v-bevel to 'false' doesn't affect 'v-textfield-bevel' value", + defaultBoxShadow, boxShadow); + } +} -- cgit v1.2.3 From 05d2e2cc76cbe64cf76a2ed4b541a5f500754e69 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 10 Apr 2014 14:05:03 +0300 Subject: Add constructor for directly extending a connector (#13579) Change-Id: Id8ba60cf8767ba171a5bcbd5541d8c0c7a9fa62d --- server/src/com/vaadin/server/AbstractExtension.java | 20 ++++++++++++++++++++ .../vaadin/server/AbstractJavaScriptExtension.java | 21 +++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/server/src/com/vaadin/server/AbstractExtension.java b/server/src/com/vaadin/server/AbstractExtension.java index 7148e6e84c..6395daebd1 100644 --- a/server/src/com/vaadin/server/AbstractExtension.java +++ b/server/src/com/vaadin/server/AbstractExtension.java @@ -35,6 +35,26 @@ public abstract class AbstractExtension extends AbstractClientConnector private ClientConnector parent; + /** + * Creates a new extension instance without extending any connector. + */ + public AbstractExtension() { + // Empty default constructor + } + + /** + * Creates a new extension instance that extends the provided connector. + * + * @since + * + * @param target + * the connector to extend + */ + public AbstractExtension(AbstractClientConnector target) { + this(); + extend(target); + } + /** * Gets a type that the parent must be an instance of. Override this if the * extension only support certain targets, e.g. if only TextFields can be diff --git a/server/src/com/vaadin/server/AbstractJavaScriptExtension.java b/server/src/com/vaadin/server/AbstractJavaScriptExtension.java index 410eea3c01..2f2752c317 100644 --- a/server/src/com/vaadin/server/AbstractJavaScriptExtension.java +++ b/server/src/com/vaadin/server/AbstractJavaScriptExtension.java @@ -127,6 +127,27 @@ public abstract class AbstractJavaScriptExtension extends AbstractExtension { private JavaScriptCallbackHelper callbackHelper = new JavaScriptCallbackHelper( this); + /** + * Creates a new JavasScript extension instance without extending any + * connector. + */ + public AbstractJavaScriptExtension() { + // Empty default constructor + } + + /** + * Creates a new JavaScript extension extending the provided connector. + * + * @since + * + * @param target + * the connector to extend + */ + public AbstractJavaScriptExtension(AbstractClientConnector target) { + this(); + extend(target); + } + @Override protected void registerRpc(T implementation, Class rpcInterfaceType) { -- cgit v1.2.3 From a020fd45a9b8c77dd6232f6aa9aa13e7a5434427 Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Mon, 17 Nov 2014 16:52:02 +0200 Subject: Valo menu broken on Android Chrome (#15236) Change-Id: Idadbbdfe0a9abaf1dd7ada339b618890b2be6e06 --- WebContent/VAADIN/themes/valo/components/_valo-menu.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WebContent/VAADIN/themes/valo/components/_valo-menu.scss b/WebContent/VAADIN/themes/valo/components/_valo-menu.scss index 071aceb971..3b71577126 100644 --- a/WebContent/VAADIN/themes/valo/components/_valo-menu.scss +++ b/WebContent/VAADIN/themes/valo/components/_valo-menu.scss @@ -193,6 +193,7 @@ $valo-menu-background-color: scale-color($v-app-background-color, $lightness: if height: $v-unit-size !important; padding-top: 0; padding-bottom: 0; + -webkit-backface-visibility: hidden; } .valo-menu .v-menubar-user-menu { @@ -205,6 +206,7 @@ $valo-menu-background-color: scale-color($v-app-background-color, $lightness: if height: $v-unit-size; color: valo-font-color($v-selection-color, 0.5); max-width: 30%; + -webkit-backface-visibility: hidden; .v-menubar-menuitem { line-height: $v-unit-size - 1px; -- cgit v1.2.3 From ac81f649549c51318bf442589cc01622f5a8b255 Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Mon, 17 Nov 2014 17:12:55 +0200 Subject: Unwanted horizontal scrollbar in Valo menu (#15237) Change-Id: Ic435e3ca741669db6f707961ac66a4c2e30bf765 --- WebContent/VAADIN/themes/valo/components/_valo-menu.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/WebContent/VAADIN/themes/valo/components/_valo-menu.scss b/WebContent/VAADIN/themes/valo/components/_valo-menu.scss index 3b71577126..5ed125b909 100644 --- a/WebContent/VAADIN/themes/valo/components/_valo-menu.scss +++ b/WebContent/VAADIN/themes/valo/components/_valo-menu.scss @@ -330,6 +330,7 @@ $valo-menu-background-color: scale-color($v-app-background-color, $lightness: if padding: 0 round($v-unit-size) 0 round($v-unit-size/2); cursor: pointer; position: relative; + overflow: hidden; text-shadow: valo-text-shadow($font-color: $font-color, $background-color: $bg, $offset: 2px); @include transition(background-color 300ms, color 60ms); -- cgit v1.2.3 From 144d9bd12f2feb3c19278f35805753d801a9c808 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Mon, 10 Nov 2014 20:32:39 +0200 Subject: Also disable annotation scanning after redeploy Change-Id: I67d3374a69416363004e3fad75313296ca636ef8 --- .../vaadin/launcher/DevelopmentServerLauncher.java | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java index 22b075b890..f00a05e810 100644 --- a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java +++ b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java @@ -257,6 +257,7 @@ public class DevelopmentServerLauncher { webappcontext.stop(); server.stop(); webappcontext.start(); + disableAtmosphereAnnotationScan(webappcontext); server.start(); } }); @@ -277,15 +278,7 @@ public class DevelopmentServerLauncher { // Read web.xml to find all configured servlets webappcontext.start(); - // Reconfigure all servlets to avoid startup delay - for (ServletHolder servletHolder : webappcontext.getServletHandler() - .getServlets()) { - if (servletHolder - .getInitParameter("org.atmosphere.cpr.scanClassPath") == null) { - servletHolder.setInitParameter( - "org.atmosphere.cpr.scanClassPath", "false"); - } - } + disableAtmosphereAnnotationScan(webappcontext); try { server.start(); @@ -358,6 +351,19 @@ public class DevelopmentServerLauncher { return "http://localhost:" + port + serverArgs.get("context"); } + private static void disableAtmosphereAnnotationScan( + WebAppContext webappcontext) { + // Reconfigure all servlets to avoid startup delay + for (ServletHolder servletHolder : webappcontext.getServletHandler() + .getServlets()) { + if (servletHolder + .getInitParameter("org.atmosphere.cpr.scanClassPath") == null) { + servletHolder.setInitParameter( + "org.atmosphere.cpr.scanClassPath", "false"); + } + } + } + /** * Assign default value for given key. * -- cgit v1.2.3 From 975b27fc98faa5a341e8687d28061d094cfb486d Mon Sep 17 00:00:00 2001 From: Denis Anisimov Date: Mon, 22 Sep 2014 20:09:36 +0300 Subject: Optimizing and avoiding NPE in RowId and ReadOnlyRowId toString(#10410). Change-Id: I6f16b9c55f661f5f75628ff627a01f8ec35e714e --- .../data/util/sqlcontainer/ReadOnlyRowId.java | 11 ++++-- .../com/vaadin/data/util/sqlcontainer/RowId.java | 46 +++++++--------------- .../data/util/sqlcontainer/TemporaryRowId.java | 2 +- .../data/util/sqlcontainer/ReadOnlyRowIdTest.java | 8 ++++ .../vaadin/data/util/sqlcontainer/RowIdTest.java | 7 ++++ 5 files changed, 39 insertions(+), 35 deletions(-) diff --git a/server/src/com/vaadin/data/util/sqlcontainer/ReadOnlyRowId.java b/server/src/com/vaadin/data/util/sqlcontainer/ReadOnlyRowId.java index dcad8f7c5d..c845cadc7a 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/ReadOnlyRowId.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/ReadOnlyRowId.java @@ -26,18 +26,23 @@ public class ReadOnlyRowId extends RowId { @Override public int hashCode() { - return rowNum.hashCode(); + return getRowNum(); } @Override public boolean equals(Object obj) { - if (obj == null || !(obj instanceof ReadOnlyRowId)) { + if (obj == null || !(ReadOnlyRowId.class.equals(obj.getClass()))) { return false; } - return rowNum.equals(((ReadOnlyRowId) obj).rowNum); + return getRowNum() == (((ReadOnlyRowId) obj).getRowNum()); } public int getRowNum() { return rowNum; } + + @Override + public String toString() { + return String.valueOf(getRowNum()); + } } diff --git a/server/src/com/vaadin/data/util/sqlcontainer/RowId.java b/server/src/com/vaadin/data/util/sqlcontainer/RowId.java index 8674b9dca0..79c16b0f60 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/RowId.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/RowId.java @@ -16,6 +16,7 @@ package com.vaadin.data.util.sqlcontainer; import java.io.Serializable; +import java.util.Arrays; /** * RowId represents identifiers of a single database result set row. @@ -47,47 +48,30 @@ public class RowId implements Serializable { @Override public int hashCode() { - int result = 31; - if (id != null) { - for (Object o : id) { - if (o != null) { - result += o.hashCode(); - } - } - } - return result; + return Arrays.hashCode(getId()); } @Override public boolean equals(Object obj) { - if (obj == null || !(obj instanceof RowId)) { - return false; - } - Object[] compId = ((RowId) obj).getId(); - if (id == null && compId == null) { - return true; - } - if (id.length != compId.length) { + if (obj == null || !(RowId.class.equals(obj.getClass()))) { return false; } - for (int i = 0; i < id.length; i++) { - if ((id[i] == null && compId[i] != null) - || (id[i] != null && !id[i].equals(compId[i]))) { - return false; - } - } - return true; + return Arrays.equals(getId(), ((RowId) obj).getId()); } @Override public String toString() { - StringBuffer s = new StringBuffer(); - for (int i = 0; i < id.length; i++) { - s.append(id[i]); - if (i < id.length - 1) { - s.append("/"); - } + if (getId() == null) { + return ""; + } + StringBuilder builder = new StringBuilder(); + for (Object id : getId()) { + builder.append(id); + builder.append('/'); + } + if (builder.length() > 0) { + return builder.substring(0, builder.length() - 1); } - return s.toString(); + return builder.toString(); } } diff --git a/server/src/com/vaadin/data/util/sqlcontainer/TemporaryRowId.java b/server/src/com/vaadin/data/util/sqlcontainer/TemporaryRowId.java index 6c1e07756f..ca2f25963e 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/TemporaryRowId.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/TemporaryRowId.java @@ -29,7 +29,7 @@ public class TemporaryRowId extends RowId { @Override public boolean equals(Object obj) { - if (obj == null || !(obj instanceof TemporaryRowId)) { + if (obj == null || !(TemporaryRowId.class.equals(obj.getClass()))) { return false; } Object[] compId = ((TemporaryRowId) obj).getId(); diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/ReadOnlyRowIdTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/ReadOnlyRowIdTest.java index 248dc62d93..29968ecf94 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/ReadOnlyRowIdTest.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/ReadOnlyRowIdTest.java @@ -44,4 +44,12 @@ public class ReadOnlyRowIdTest { ReadOnlyRowId rid2 = new ReadOnlyRowId(42); Assert.assertFalse(rid.equals(rid2)); } + + @Test + public void toString_rowNumberIsReturned() { + int i = 1; + ReadOnlyRowId rowId = new ReadOnlyRowId(i); + Assert.assertEquals("Unexpected toString value", String.valueOf(i), + rowId.toString()); + } } diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/RowIdTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/RowIdTest.java index e4ee28ba9e..73f7be9fb2 100644 --- a/server/tests/src/com/vaadin/data/util/sqlcontainer/RowIdTest.java +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/RowIdTest.java @@ -50,4 +50,11 @@ public class RowIdTest { Assert.assertFalse(id.equals("Tudiluu")); Assert.assertFalse(id.equals(new Integer(1337))); } + + @Test + public void toString_defaultCtor_noException() { + RowId rowId = new RowId(); + Assert.assertTrue("Unexpected to string for empty Row Id", rowId + .toString().isEmpty()); + } } -- cgit v1.2.3 From 828f1f0f20a296d97c693dd2acd004d4c90ad5cd Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Sat, 20 Sep 2014 11:52:55 +0300 Subject: Don't iterate all connectors for unregistering (#14714) This reduces the time spent in unregisterRemovedConnectors when updating the text of one Label with about 380 connectors registered from 20 to 2 ms as reported by the Vaadin profiler. Performance when removing lots of connectors remains at about 10 ms for removing 360 connectors. Profiled in Firefox 32 on OS X. Change-Id: I203fd8790f8ccc7c098ee91c44831a5ac6c4a82b --- .../com/vaadin/client/ApplicationConnection.java | 80 ++++++++++++++-------- .../tests/performance/BasicPerformanceTest.java | 25 ++++++- 2 files changed, 76 insertions(+), 29 deletions(-) diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index cba9639067..d7c1c54a2d 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -135,6 +135,11 @@ public class ApplicationConnection implements HasHandlers { * Needed to know where captions might need to get updated */ private FastStringSet parentChangedIds = FastStringSet.create(); + + /** + * Connectors for which the parent has been set to null + */ + private FastStringSet detachedConnectorIds = FastStringSet.create(); } public static final String MODIFIED_CLASSNAME = "v-modified"; @@ -1624,7 +1629,7 @@ public class ApplicationConnection implements HasHandlers { json.getValueMap("dd")); } - unregisterRemovedConnectors(); + unregisterRemovedConnectors(connectorHierarchyUpdateResult.detachedConnectorIds); VConsole.log("handleUIDLMessage: " + (Duration.currentTimeMillis() - processUidlStart) @@ -1722,7 +1727,7 @@ public class ApplicationConnection implements HasHandlers { sendHierarchyChangeEvents(connectorHierarchyUpdateResult.events); // Unregister all the old connectors that have now been removed - unregisterRemovedConnectors(); + unregisterRemovedConnectors(connectorHierarchyUpdateResult.detachedConnectorIds); getLayoutManager().cleanMeasuredSizes(); } @@ -1877,47 +1882,63 @@ public class ApplicationConnection implements HasHandlers { Profiler.leave("sendStateChangeEvents"); } - private void unregisterRemovedConnectors() { - Profiler.enter("unregisterRemovedConnectors"); + private void verifyConnectorHierarchy() { + Profiler.enter("verifyConnectorHierarchy - this is only performed in debug mode"); - int unregistered = 0; JsArrayObject currentConnectors = connectorMap .getConnectorsAsJsArray(); int size = currentConnectors.size(); for (int i = 0; i < size; i++) { ServerConnector c = currentConnectors.get(i); if (c.getParent() != null) { - // only do this check if debug mode is active - if (ApplicationConfiguration.isDebugMode()) { - Profiler.enter("unregisterRemovedConnectors check parent - this is only performed in debug mode"); - // this is slow for large layouts, 25-30% of total - // time for some operations even on modern browsers - if (!c.getParent().getChildren().contains(c)) { - VConsole.error("ERROR: Connector is connected to a parent but the parent does not contain the connector"); - } - Profiler.leave("unregisterRemovedConnectors check parent - this is only performed in debug mode"); + if (!c.getParent().getChildren().contains(c)) { + VConsole.error("ERROR: Connector " + + c.getConnectorId() + + " is connected to a parent but the parent (" + + c.getParent().getConnectorId() + + ") does not contain the connector"); } } else if (c == getUIConnector()) { - // UIConnector for this connection, leave as-is + // UIConnector for this connection, ignore } else if (c instanceof WindowConnector && getUIConnector().hasSubWindow( (WindowConnector) c)) { - // Sub window attached to this UIConnector, leave - // as-is + // Sub window attached to this UIConnector, ignore } else { // The connector has been detached from the - // hierarchy, unregister it and any possible - // children. The UIConnector should never be - // unregistered even though it has no parent. - Profiler.enter("unregisterRemovedConnectors unregisterConnector"); - connectorMap.unregisterConnector(c); - Profiler.leave("unregisterRemovedConnectors unregisterConnector"); - unregistered++; + // hierarchy but was not unregistered. + VConsole.error("ERROR: Connector " + + c.getConnectorId() + + " is not attached to a parent but has not been unregistered"); } } - VConsole.log("* Unregistered " + unregistered + " connectors"); + Profiler.leave("verifyConnectorHierarchy - this is only performed in debug mode"); + } + + private void unregisterRemovedConnectors( + FastStringSet detachedConnectors) { + Profiler.enter("unregisterRemovedConnectors"); + + JsArrayString detachedArray = detachedConnectors.dump(); + for (int i = 0; i < detachedArray.length(); i++) { + ServerConnector connector = connectorMap + .getConnector(detachedArray.get(i)); + + Profiler.enter("unregisterRemovedConnectors unregisterConnector"); + connectorMap.unregisterConnector(connector); + Profiler.leave("unregisterRemovedConnectors unregisterConnector"); + } + + if (ApplicationConfiguration.isDebugMode()) { + // Do some extra checking if we're in debug mode (i.e. debug + // window is open) + verifyConnectorHierarchy(); + } + + VConsole.log("* Unregistered " + detachedArray.length() + + " connectors"); Profiler.leave("unregisterRemovedConnectors"); } @@ -2327,7 +2348,8 @@ public class ApplicationConnection implements HasHandlers { for (int i = 0; i < maybeDetachedArray.length(); i++) { ServerConnector removed = connectorMap .getConnector(maybeDetachedArray.get(i)); - recursivelyDetach(removed, result.events); + recursivelyDetach(removed, result.events, + result.detachedConnectorIds); } Profiler.leave("updateConnectorHierarchy detach removed connectors"); @@ -2339,7 +2361,9 @@ public class ApplicationConnection implements HasHandlers { } private void recursivelyDetach(ServerConnector connector, - JsArrayObject events) { + JsArrayObject events, + FastStringSet detachedConnectors) { + detachedConnectors.add(connector.getConnectorId()); /* * Reset state in an attempt to keep it consistent with the @@ -2400,7 +2424,7 @@ public class ApplicationConnection implements HasHandlers { if (child.getParent() != connector) { continue; } - recursivelyDetach(child, events); + recursivelyDetach(child, events, detachedConnectors); } Profiler.leave("ApplicationConnection recursivelyDetach perform detach"); diff --git a/uitest/src/com/vaadin/tests/performance/BasicPerformanceTest.java b/uitest/src/com/vaadin/tests/performance/BasicPerformanceTest.java index 04fe18fc08..a97f2611d1 100644 --- a/uitest/src/com/vaadin/tests/performance/BasicPerformanceTest.java +++ b/uitest/src/com/vaadin/tests/performance/BasicPerformanceTest.java @@ -4,6 +4,7 @@ import java.util.Iterator; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.util.TestUtils; +import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; @@ -18,6 +19,8 @@ import com.vaadin.ui.themes.Reindeer; public class BasicPerformanceTest extends UI { + private int updateOneCount = 0; + private final VerticalLayout contentLayout = new VerticalLayout(); private int clientLimit; @@ -64,7 +67,7 @@ public class BasicPerformanceTest extends UI { TestUtils.installPerformanceReporting(performanceReportArea); VerticalLayout leftBar = new VerticalLayout(); - leftBar.setSizeUndefined(); + leftBar.setWidth("250px"); leftBar.addComponent(new Label("This is the left bar")); leftBar.addComponent(performanceReportArea); leftBar.addComponent(reportPerformanceButton); @@ -126,6 +129,26 @@ public class BasicPerformanceTest extends UI { } })); + leftBar.addComponent(new Button("Update one label", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + Component child = contentLayout.getComponent(0); + if (child instanceof Panel) { + Panel panel = (Panel) child; + child = panel.getContent(); + } + + AbstractOrderedLayout layout = (AbstractOrderedLayout) ((AbstractOrderedLayout) child) + .getComponent(0); + Label label = (Label) layout.getComponent(0); + + label.setValue("New value " + updateOneCount++); + + updatePerformanceReporting("Update one", 10, 10); + } + })); + leftBar.addComponent(new Button("Clear content", new Button.ClickListener() { @Override -- cgit v1.2.3 From acf88c8ea269404b38e13ae94ad570b3e091a003 Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Tue, 18 Nov 2014 12:51:05 +0200 Subject: Remove IE8 from TextFieldBevelTest. (#14634) Change-Id: Ie37377b0da800cbe2acbd3e14b972e482c188579 --- .../tests/themes/valo/TextFieldBevelTest.java | 64 +++++++++++++--------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/uitest/src/com/vaadin/tests/themes/valo/TextFieldBevelTest.java b/uitest/src/com/vaadin/tests/themes/valo/TextFieldBevelTest.java index ee2cdd41f8..9159b71961 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/TextFieldBevelTest.java +++ b/uitest/src/com/vaadin/tests/themes/valo/TextFieldBevelTest.java @@ -15,8 +15,14 @@ */ package com.vaadin.tests.themes.valo; -import org.junit.Assert; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.List; + import org.junit.Test; +import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.testbench.elements.TextFieldElement; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -28,32 +34,36 @@ import com.vaadin.tests.tb3.MultiBrowserTest; */ public class TextFieldBevelTest extends MultiBrowserTest { + @Override + public List getBrowsersToTest() { + List browsers = super.getBrowsersToTest(); + + // IE8 doesn't support box-shadow. + browsers.remove(Browser.IE8.getDesiredCapabilities()); + + return browsers; + } + @Test - public void testTextFieldBevel() { - String url = getTestUrl(); - StringBuilder defaultValoUi = new StringBuilder( - TextFieldBevel.class.getSimpleName()); - defaultValoUi.append('$'); - defaultValoUi.append(TextFieldBevel.ValoDefaultTextFieldBevel.class - .getSimpleName()); - url = url.replace(TextFieldBevel.class.getSimpleName(), - defaultValoUi.toString()); - getDriver().get(url); - - String defaultBoxShadow = $(TextFieldElement.class).first() - .getCssValue("box-shadow"); - - if (url.contains("restartApplication")) { - openTestURL(); - } else { - openTestURL("restartApplication"); - } - - String boxShadow = $(TextFieldElement.class).first().getCssValue( - "box-shadow"); - - Assert.assertNotEquals( - "Set v-bevel to 'false' doesn't affect 'v-textfield-bevel' value", - defaultBoxShadow, boxShadow); + public void bevelChangesBoxShadow() { + openTestURL(); + String boxShadowWithBevel = getBoxShadow(); + + openTestUrlWithoutBevel(); + String boxShadowWithoutBevel = getBoxShadow(); + + assertThat(boxShadowWithBevel, is(not(boxShadowWithoutBevel))); + } + + private void openTestUrlWithoutBevel() { + getDriver().get( + getTestUrl() + + "$" + + TextFieldBevel.ValoDefaultTextFieldBevel.class + .getSimpleName() + "?restartApplication"); + } + + private String getBoxShadow() { + return $(TextFieldElement.class).first().getCssValue("box-shadow"); } } -- cgit v1.2.3 From bd4c7aa5407951f635e4af17436a6b00e4a8c130 Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Thu, 20 Nov 2014 13:04:08 +0200 Subject: Fix duplicate detection in test locator. Change-Id: I9a6ebfda4e8b09927eb22bec6ddf2989b8104070 --- .../vaadin/tests/tb3/AffectedTB3TestLocator.java | 21 ++++++++------------- .../com/vaadin/tests/tb3/ChangedTB3TestLocator.java | 5 +++-- .../vaadin/tests/tb3/PrivateTB3Configuration.java | 2 +- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/uitest/src/com/vaadin/tests/tb3/AffectedTB3TestLocator.java b/uitest/src/com/vaadin/tests/tb3/AffectedTB3TestLocator.java index a3bee26675..9dfae77ca5 100644 --- a/uitest/src/com/vaadin/tests/tb3/AffectedTB3TestLocator.java +++ b/uitest/src/com/vaadin/tests/tb3/AffectedTB3TestLocator.java @@ -17,7 +17,9 @@ package com.vaadin.tests.tb3; import java.io.IOException; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class AffectedTB3TestLocator extends TB3TestLocator { @@ -42,21 +44,14 @@ public class AffectedTB3TestLocator extends TB3TestLocator { private List> getAffectedTestClasses( List> allTestClasses, List> changedTestClasses) throws IOException { - List> affectedWithPackageTestClasses = getTestClassesWithAffectedPackageName(allTestClasses); - List> affectedTestClasses = new ArrayList>(); - affectedTestClasses.addAll(affectedWithPackageTestClasses); - // Removing duplicate entries before adding changed test classes. - for (Class changedTestClass : changedTestClasses) { - for (Class affectedTestClass : affectedWithPackageTestClasses) { - if (!changedTestClass.getName().equals( - affectedTestClass.getName())) { - affectedTestClasses.add(changedTestClass); + Set testClasses = new HashSet(changedTestClasses); + testClasses + .addAll(getTestClassesWithAffectedPackageName(allTestClasses)); + + List> affectedTestClasses = new ArrayList>(); + affectedTestClasses.addAll(testClasses); - break; - } - } - } return affectedTestClasses; } diff --git a/uitest/src/com/vaadin/tests/tb3/ChangedTB3TestLocator.java b/uitest/src/com/vaadin/tests/tb3/ChangedTB3TestLocator.java index a2f8ceeefa..a6f2e5191a 100644 --- a/uitest/src/com/vaadin/tests/tb3/ChangedTB3TestLocator.java +++ b/uitest/src/com/vaadin/tests/tb3/ChangedTB3TestLocator.java @@ -113,13 +113,14 @@ public class ChangedTB3TestLocator extends TB3TestLocator { } private boolean pathIsExcluded(String path) { - // Exclude temporary junit files and screeenshots. + // Exclude temporary junit files and screenshots. return path.startsWith("uitest/junit") || getScreenshotDirectory().contains(path); } private String getScreenshotDirectory() { - return System.getProperty(PrivateTB3Configuration.SCREENSHOT_DIRECTORY); + return PrivateTB3Configuration + .getProperty(PrivateTB3Configuration.SCREENSHOT_DIRECTORY); } private List getDiffsInHead(Repository repository) diff --git a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java index f2f4af3910..32d0f1065c 100644 --- a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java +++ b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java @@ -67,7 +67,7 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { } } - private static String getProperty(String name) { + protected static String getProperty(String name) { String property = properties.getProperty(name); if (property == null) { property = System.getProperty(name); -- cgit v1.2.3 From 0545cb2999c83b11da55477211b87865bae98bba Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 21 Nov 2014 09:12:21 +0200 Subject: Update to GWT 2.7.0 (#14522) GWT codeserver has been integrated into gwt-dev.jar Change-Id: Ia9cd252482e25ed8e0d69da7c0e702d6407efd8b --- build.properties | 2 +- gwt-files.xml | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/build.properties b/build.properties index 9df1c8d767..286713b616 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.10 -gwt.version=2.7.0.beta1vaadin1 +gwt.version=2.7.0.vaadin1 commons-io.version=2.4 diff --git a/gwt-files.xml b/gwt-files.xml index c0ef583177..26126a7ffb 100644 --- a/gwt-files.xml +++ b/gwt-files.xml @@ -7,44 +7,37 @@ - - - - - - - @@ -124,10 +117,6 @@ - - - - -- cgit v1.2.3 From dac74189ededf7d004b309215f7e9f64a3e4550c Mon Sep 17 00:00:00 2001 From: Fabian Lange Date: Mon, 24 Nov 2014 21:30:59 +0100 Subject: do not create a StringWriter when not needed (#15276) Change-Id: I528f4034ef5cf375be31750bbad9baddcd3a2b64 --- server/src/com/vaadin/server/communication/UIInitHandler.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/server/src/com/vaadin/server/communication/UIInitHandler.java b/server/src/com/vaadin/server/communication/UIInitHandler.java index 356ad25219..8e61370d85 100644 --- a/server/src/com/vaadin/server/communication/UIInitHandler.java +++ b/server/src/com/vaadin/server/communication/UIInitHandler.java @@ -65,8 +65,6 @@ public abstract class UIInitHandler extends SynchronizedRequestHandler { @Override public boolean synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { - StringWriter stringWriter = new StringWriter(); - try { assert UI.getCurrent() == null; @@ -82,14 +80,10 @@ public abstract class UIInitHandler extends SynchronizedRequestHandler { String initialUIDL = getInitialUidl(request, uI); params.put("uidl", initialUIDL); - stringWriter.write(JsonUtil.stringify(params)); + return commitJsonResponse(request, response, JsonUtil.stringify(params)); } catch (JsonException e) { throw new IOException("Error producing initial UIDL", e); - } finally { - stringWriter.close(); } - - return commitJsonResponse(request, response, stringWriter.toString()); } /** -- cgit v1.2.3 From 75ca951246f4c40dbc6914539d2d2d4890d30089 Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Tue, 25 Nov 2014 17:23:45 +0200 Subject: Add getter to SplitterState.positionReversed (#15285) Change-Id: I1e3783d21cb5f2832838dfe36c91c7f6a4ddb313 --- server/src/com/vaadin/ui/AbstractSplitPanel.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/src/com/vaadin/ui/AbstractSplitPanel.java b/server/src/com/vaadin/ui/AbstractSplitPanel.java index 09f881cf46..e9b37f8cff 100644 --- a/server/src/com/vaadin/ui/AbstractSplitPanel.java +++ b/server/src/com/vaadin/ui/AbstractSplitPanel.java @@ -342,11 +342,25 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * Returns the unit of position of the splitter * * @return unit of position of the splitter + * @see #setSplitPosition(float, Unit) */ public Unit getSplitPositionUnit() { return posUnit; } + /** + * Is the split position reversed. By default the split position is measured + * by the first region, but if split position is reversed the measuring is + * done by the second region instead. + * + * @since + * @return {@code true} if reversed, {@code false} otherwise. + * @see #setSplitPosition(float, boolean) + */ + public boolean isSplitPositionReversed() { + return getSplitterState(false).positionReversed; + } + /** * Sets the minimum split position to the given position and unit. If the * split position is reversed, maximum and minimum are also reversed. -- cgit v1.2.3 From 65a4fd14bff1043ab62c045d7d176d2097242fb2 Mon Sep 17 00:00:00 2001 From: Anna Miroshnik Date: Tue, 25 Nov 2014 12:19:05 +0300 Subject: Position tooltips in the visible area (#15129). Based on Mika's reverted patch, with additional fix and test for regression "an empty tooltip appears while the application is initializing". Change-Id: I8237fc9340265708a05a7576a5d9e8e374dc1fea --- client/src/com/vaadin/client/VTooltip.java | 23 ++- .../vaadin/tests/components/TooltipPosition.java | 70 +++++++++ .../tests/components/TooltipPositionTest.java | 173 +++++++++++++++++++++ .../tests/components/menubar/MenuTooltipTest.java | 1 + 4 files changed, 265 insertions(+), 2 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/TooltipPosition.java create mode 100644 uitest/src/com/vaadin/tests/components/TooltipPositionTest.java diff --git a/client/src/com/vaadin/client/VTooltip.java b/client/src/com/vaadin/client/VTooltip.java index edd1273bf5..47a1b71228 100644 --- a/client/src/com/vaadin/client/VTooltip.java +++ b/client/src/com/vaadin/client/VTooltip.java @@ -210,6 +210,14 @@ public class VTooltip extends VOverlay { x = Window.getClientWidth() - offsetWidth - MARGIN + Window.getScrollLeft(); } + + if (tooltipEventMouseX != EVENT_XY_POSITION_OUTSIDE) { + // Do not allow x to be zero, for otherwise the tooltip + // does not close when the mouse is moved (see + // isTooltipOpen()). #15129 + int minX = Window.getScrollLeft() + MARGIN; + x = Math.max(x, minX); + } return x; } @@ -245,6 +253,14 @@ public class VTooltip extends VOverlay { y = Window.getScrollTop(); } } + + if (tooltipEventMouseY != EVENT_XY_POSITION_OUTSIDE) { + // Do not allow y to be zero, for otherwise the tooltip + // does not close when the mouse is moved (see + // isTooltipOpen()). #15129 + int minY = Window.getScrollTop() + MARGIN; + y = Math.max(y, minY); + } return y; } }); @@ -323,6 +339,7 @@ public class VTooltip extends VOverlay { setPopupPosition(tooltipEventMouseX, tooltipEventMouseY); } + private int EVENT_XY_POSITION_OUTSIDE = -5000; private int tooltipEventMouseX; private int tooltipEventMouseY; @@ -332,11 +349,13 @@ public class VTooltip extends VOverlay { } private int getEventX(Event event, boolean isFocused) { - return isFocused ? -5000 : DOM.eventGetClientX(event); + return isFocused ? EVENT_XY_POSITION_OUTSIDE : DOM + .eventGetClientX(event); } private int getEventY(Event event, boolean isFocused) { - return isFocused ? -5000 : DOM.eventGetClientY(event); + return isFocused ? EVENT_XY_POSITION_OUTSIDE : DOM + .eventGetClientY(event); } @Override diff --git a/uitest/src/com/vaadin/tests/components/TooltipPosition.java b/uitest/src/com/vaadin/tests/components/TooltipPosition.java new file mode 100644 index 0000000000..30222722d9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/TooltipPosition.java @@ -0,0 +1,70 @@ +/* + * 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; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +/** + * This UI is used for testing that a tooltip is not positioned partially + * outside the browser window when there is enough space to display it. + * + * @author Vaadin Ltd + */ +public class TooltipPosition extends AbstractTestUI { + + public static final int NUMBER_OF_BUTTONS = 5; + + @Override + protected void setup(VaadinRequest request) { + // These tooltip delay settings can be removed once #13854 is resolved. + getTooltipConfiguration().setOpenDelay(0); + getTooltipConfiguration().setQuickOpenDelay(0); + getTooltipConfiguration().setCloseTimeout(1000); + + VerticalLayout layout = new VerticalLayout(); + layout.setSpacing(true); + layout.setHeight(UI.getCurrent().getPage().getBrowserWindowHeight(), + Unit.PIXELS); + addComponent(layout); + for (int i = 0; i < NUMBER_OF_BUTTONS; i++) { + Button button = new Button("Button"); + button.setDescription(generateTooltipText()); + layout.addComponent(button); + } + } + + private String generateTooltipText() { + StringBuilder result = new StringBuilder(); + for (int i = 0; i < 50; i++) { + result.append("This is the line ").append(i) + .append(" of the long tooltip text.
"); + } + return result.toString(); + } + + @Override + public String getTestDescription() { + return "The tooltips of the buttons should not be clipped when there is enough space to display them."; + } + + @Override + public Integer getTicketNumber() { + return 15129; + } +} diff --git a/uitest/src/com/vaadin/tests/components/TooltipPositionTest.java b/uitest/src/com/vaadin/tests/components/TooltipPositionTest.java new file mode 100644 index 0000000000..4106374d64 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/TooltipPositionTest.java @@ -0,0 +1,173 @@ +/* + * 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; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.Point; +import org.openqa.selenium.StaleElementReferenceException; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebDriver.Window; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.ExpectedCondition; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests that the tooltip is positioned so that it fits in the displayed area. + * + * @author Vaadin Ltd + */ +public class TooltipPositionTest extends MultiBrowserTest { + + @Test + public void testRegression_EmptyTooltipShouldNotBeAppearedDuringInitialization() + throws Exception { + openTestURL(); + + waitForElementVisible(By.cssSelector(".v-tooltip")); + WebElement tooltip = driver.findElement(By.cssSelector(".v-tooltip")); + + Assert.assertTrue( + "This init tooltip with text ' ' is present in the DOM and should be entirely outside the browser window", + isOutsideOfWindow(tooltip)); + } + + @Test + public void testTooltipPosition() throws Exception { + openTestURL(); + for (int i = 0; i < TooltipPosition.NUMBER_OF_BUTTONS; i++) { + ButtonElement button = $(ButtonElement.class).get(i); + // Move the mouse to display the tooltip. + Actions actions = new Actions(driver); + actions.moveToElement(button, 10, 10); + actions.build().perform(); + waitUntil(tooltipToBeInsideWindow(By.cssSelector(".v-tooltip"), + driver.manage().window())); + + if (i < TooltipPosition.NUMBER_OF_BUTTONS - 1) { + // Remove the tooltip by moving the mouse. + actions = new Actions(driver); + actions.moveByOffset(300, 0); + actions.build().perform(); + waitUntil(tooltipNotToBeShown(By.cssSelector(".v-tooltip"), + driver.manage().window())); + } + } + } + + /* + * An expectation for checking that the tooltip found by the given locator + * is present in the DOM and entirely inside the browser window. The + * coordinate of the top left corner of the window is supposed to be (0, 0). + */ + private ExpectedCondition tooltipToBeInsideWindow( + final By tooltipLocator, final Window window) { + return new ExpectedCondition() { + + @Override + public Boolean apply(WebDriver input) { + List elements = findElements(tooltipLocator); + if (elements.isEmpty()) { + return false; + } + WebElement element = elements.get(0); + try { + if (!element.isDisplayed()) { + return false; + } + Point topLeft = element.getLocation(); + int xLeft = topLeft.getX(); + int yTop = topLeft.getY(); + if (xLeft < 0 || yTop < 0) { + return false; + } + Dimension elementSize = element.getSize(); + int xRight = xLeft + elementSize.getWidth() - 1; + int yBottom = yTop + elementSize.getHeight() - 1; + Dimension browserSize = window.getSize(); + return xRight < browserSize.getWidth() + && yBottom < browserSize.getHeight(); + } catch (StaleElementReferenceException e) { + return false; + } + } + + @Override + public String toString() { + return "the tooltip to be displayed inside the window"; + } + }; + }; + + /* + * An expectation for checking that the tooltip found by the given locator + * is not shown in the window, even partially. The top left corner of window + * should have coordinates (0, 0). + */ + private ExpectedCondition tooltipNotToBeShown( + final By tooltipLocator, final Window window) { + return new ExpectedCondition() { + + @Override + public Boolean apply(WebDriver input) { + List elements = findElements(tooltipLocator); + if (elements.isEmpty()) { + return true; + } + WebElement tooltip = elements.get(0); + try { + return isOutsideOfWindow(tooltip); + } catch (StaleElementReferenceException e) { + return true; + } + } + + @Override + public String toString() { + return "the tooltip not to be displayed inside the window"; + } + + }; + } + + private boolean isOutsideOfWindow(WebElement tooltip) { + if (!tooltip.isDisplayed()) { + return true; + } + // The tooltip is shown, at least partially, if + // its intervals of both horizontal and vertical coordinates + // overlap those of the window. + Point topLeft = tooltip.getLocation(); + Dimension tooltipSize = tooltip.getSize(); + Dimension windowSize = driver.manage().window().getSize(); + int xLeft = topLeft.getX(); + int yTop = topLeft.getY(); + int xRight = xLeft + tooltipSize.getWidth() - 1; + int yBottom = yTop + tooltipSize.getHeight() - 1; + boolean overlapHorizontally = !(xRight < 0 || xLeft >= windowSize + .getWidth()); + boolean overlapVertically = !(yBottom < 0 || yTop >= windowSize + .getHeight()); + return !(overlapHorizontally && overlapVertically); + } +} \ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java index 24025b9f39..091f7be954 100644 --- a/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java +++ b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java @@ -49,6 +49,7 @@ public class MenuTooltipTest extends MultiBrowserTest { Coordinates elementCoordinates = getCoordinates($(MenuBarElement.class) .first()); + sleep(1000); Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); -- cgit v1.2.3 From 551c06548831c05e9519836c1e068011b3a95c40 Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Tue, 25 Nov 2014 14:41:48 +0200 Subject: Converted SetCurrentPageFirstItemIndex to TB4. (#15286) Change-Id: Iea990c243e083b3302fd1e448402ac3aa3db08ac --- .../table/SetCurrentPageFirstItemIndex.html | 43 --------------- .../table/SetCurrentPageFirstItemIndexTest.java | 63 ++++++++++++++++++++++ 2 files changed, 63 insertions(+), 43 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndex.html create mode 100644 uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndexTest.java diff --git a/uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndex.html b/uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndex.html deleted file mode 100644 index 904f3b0470..0000000000 --- a/uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndex.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
openrun/com.vaadin.tests.components.table.SetCurrentPageFirstItemIndex?restartApplication
clickvaadin=runcomvaadintestscomponentstableSetCurrentPageFirstItemIndex::/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstableSetCurrentPageFirstItemIndex::/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]
pause500
assertTextvaadin=runcomvaadintestscomponentstableSetCurrentPageFirstItemIndex::/VVerticalLayout[0]/Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]6
- - \ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndexTest.java b/uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndexTest.java new file mode 100644 index 0000000000..8102f82834 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndexTest.java @@ -0,0 +1,63 @@ +/* + * 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.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import junit.framework.Assert; + +import org.junit.Ignore; +import org.junit.Test; +import org.openqa.selenium.NoSuchElementException; + +import com.vaadin.testbench.TestBenchElement; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +@Ignore +// Enable after #15286 is fixed. +public class SetCurrentPageFirstItemIndexTest extends MultiBrowserTest { + + @Test + public void currentPageIndexChangesTwice() { + openTestURL(); + + ButtonElement button = $(ButtonElement.class).first(); + button.click(); // change to 20 + button.click(); // change to 5 + + // When failing, the index stays on 20. + assertThatRowIsVisible(5); + } + + private void assertThatRowIsVisible(int index) { + try { + TableElement table = $(TableElement.class).first(); + TestBenchElement cell = table.getCell(index, 0); + + assertThat(cell.getText(), is(Integer.toString(index + 1))); + } catch (NoSuchElementException e) { + Assert.fail(String.format("Can't locate row for index: %s", index)); + } + } + +} -- cgit v1.2.3 From d9829d6636e046b452fdf6f93194c55db9c3997c Mon Sep 17 00:00:00 2001 From: Sergey Budkin Date: Fri, 7 Nov 2014 12:38:05 +0200 Subject: One pixel discrepancy in headers and rows border with minimal width (#15118) Disabled old patch for VTreeTable, which caused the problem. Change-Id: I3fdf6b0890307b27e32ceff4492cb7d0bfc6b680 --- client/src/com/vaadin/client/ui/VScrollTable.java | 3 +- client/src/com/vaadin/client/ui/VTreeTable.java | 2 + .../components/treetable/MinimalWidthColumns.java | 44 ++++++++++++++++++++++ .../treetable/MinimalWidthColumnsTest.java | 31 +++++++++++++++ 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumns.java create mode 100644 uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumnsTest.java diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 6c241f1033..14e4c658ad 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -5392,6 +5392,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, private Map cellToolTips = new HashMap(); private boolean isDragging = false; private String rowStyle = null; + protected boolean applyZeroWidthFix = true; private VScrollTableRow(int rowKey) { this.rowKey = rowKey; @@ -5497,7 +5498,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, * definition of zero width table cells. Instead, use 1px * and compensate with a negative margin. */ - if (width == 0) { + if (applyZeroWidthFix && width == 0) { wrapperWidth = 1; wrapperStyle.setMarginRight(-1, Unit.PX); } else { diff --git a/client/src/com/vaadin/client/ui/VTreeTable.java b/client/src/com/vaadin/client/ui/VTreeTable.java index 9b7e9702b2..9e5940a2f2 100644 --- a/client/src/com/vaadin/client/ui/VTreeTable.java +++ b/client/src/com/vaadin/client/ui/VTreeTable.java @@ -155,6 +155,8 @@ public class VTreeTable extends VScrollTable { public VTreeTableRow(UIDL uidl, char[] aligns2) { super(uidl, aligns2); + // this fix causes #15118 and doesn't work for treetable anyway + applyZeroWidthFix = false; } @Override diff --git a/uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumns.java b/uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumns.java new file mode 100644 index 0000000000..c4679f739b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumns.java @@ -0,0 +1,44 @@ +package com.vaadin.tests.components.treetable; + +import com.vaadin.annotations.Theme; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.TreeTable; + +@Theme("valo") +public class MinimalWidthColumns extends AbstractTestUI { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + TreeTable tt = new TreeTable(); + tt.addContainerProperty("Foo", String.class, ""); + tt.addContainerProperty("Bar", String.class, ""); + + Object item1 = tt.addItem(new Object[] { "f", "Bar" }, null); + Object item2 = tt.addItem(new Object[] { "Foo2", "Bar2" }, null); + + tt.setParent(item2, item1); + + tt.setColumnWidth("Foo", 0); + tt.setColumnWidth("Bar", 50); + tt.setWidth("300px"); + addComponent(tt); + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(15118); + } + + @Override + protected String getTestDescription() { + return "There should be no 1px discrepancy between vertical borders in headers and rows"; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumnsTest.java b/uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumnsTest.java new file mode 100644 index 0000000000..46c2f397b6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumnsTest.java @@ -0,0 +1,31 @@ +/* + * 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 org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class MinimalWidthColumnsTest extends MultiBrowserTest { + + @Test + public void testFor1pxDifference() throws Exception { + openTestURL(); + sleep(500); + compareScreen("onepixdifference"); + } + +} -- cgit v1.2.3 From a0f4c3dfb37b1e742b74a78d8133b1bb4a399052 Mon Sep 17 00:00:00 2001 From: Fabian Lange Date: Thu, 30 Oct 2014 11:58:26 +0100 Subject: Window modalitycurtain will now respect $v-animations-enabled (#15135) Change-Id: I80beea694c2a103aaf1fb479e1de48c515428fbb --- .../tests-valo-disabled-animations/_variables.scss | 3 ++ .../tests-valo-disabled-animations/styles.scss | 6 ++++ .../VAADIN/themes/valo/components/_window.scss | 11 +++---- .../vaadin/tests/themes/valo/ModalWindowTest.java | 34 ++++++++++++++++++++++ 4 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 WebContent/VAADIN/themes/tests-valo-disabled-animations/_variables.scss create mode 100644 WebContent/VAADIN/themes/tests-valo-disabled-animations/styles.scss create mode 100644 uitest/src/com/vaadin/tests/themes/valo/ModalWindowTest.java diff --git a/WebContent/VAADIN/themes/tests-valo-disabled-animations/_variables.scss b/WebContent/VAADIN/themes/tests-valo-disabled-animations/_variables.scss new file mode 100644 index 0000000000..d2411c675c --- /dev/null +++ b/WebContent/VAADIN/themes/tests-valo-disabled-animations/_variables.scss @@ -0,0 +1,3 @@ +$v-animations-enabled: false; + +@import "../valo/valo"; diff --git a/WebContent/VAADIN/themes/tests-valo-disabled-animations/styles.scss b/WebContent/VAADIN/themes/tests-valo-disabled-animations/styles.scss new file mode 100644 index 0000000000..b941c1b3d1 --- /dev/null +++ b/WebContent/VAADIN/themes/tests-valo-disabled-animations/styles.scss @@ -0,0 +1,6 @@ +@import "variables"; +@import "../tests-valo/valotest"; + +.tests-valo-disabled-animations { + @include valotest; +} diff --git a/WebContent/VAADIN/themes/valo/components/_window.scss b/WebContent/VAADIN/themes/valo/components/_window.scss index ce7a530c98..23fa5338c2 100644 --- a/WebContent/VAADIN/themes/valo/components/_window.scss +++ b/WebContent/VAADIN/themes/valo/components/_window.scss @@ -89,11 +89,12 @@ $v-window-modality-curtain-background-color: #222 !default; left: 0; @include radial-gradient(circle at 50% 50%, $v-window-modality-curtain-background-color, darken($v-window-modality-curtain-background-color, valo-gradient-opacity()), $fallback: $v-window-modality-curtain-background-color); @include opacity(max(0.2, 0.8 - valo-gradient-opacity()/100%)); - @include valo-animate-in-fade($duration: 400ms, $delay: 100ms); - - .v-op12 & { - // Opera 12 has a shitbreak with the fade-in (flickers) - @include animation(none); + @if $v-animations-enabled { + @include valo-animate-in-fade($duration: 400ms, $delay: 100ms); + .v-op12 & { + // Opera 12 has a shitbreak with the fade-in (flickers) + @include animation(none); + } } } diff --git a/uitest/src/com/vaadin/tests/themes/valo/ModalWindowTest.java b/uitest/src/com/vaadin/tests/themes/valo/ModalWindowTest.java new file mode 100644 index 0000000000..b97ce43ed6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/valo/ModalWindowTest.java @@ -0,0 +1,34 @@ +package com.vaadin.tests.themes.valo; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.ModalWindow; +import com.vaadin.tests.tb3.SingleBrowserTest; +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + +public class ModalWindowTest extends SingleBrowserTest { + + @Override + protected Class getUIClass() { + return ModalWindow.class; + } + + @Test + public void modalAnimationsAreDisabled() { + openTestURL("theme=tests-valo-disabled-animations"); + + openModalWindow(); + + WebElement modalityCurtain = findElement(By.className("v-window-modalitycurtain")); + + assertThat(modalityCurtain.getCssValue("-webkit-animation-name"), is("none")); + } + + private void openModalWindow() { + $(ButtonElement.class).get(1).click(); + } +} \ No newline at end of file -- cgit v1.2.3