-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix resize at runtime for board (#55)
* Remove row from board. Add docs. Add documentation about nested rows. * Fix resize at runtime for board
- Loading branch information
Showing
5 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
integration-tests/src/main/java/com/vaadin/addon/board/testUI/BoardDynamicResizeUI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.vaadin.addon.board.testUI; | ||
|
||
import com.vaadin.board.Board; | ||
import com.vaadin.server.VaadinRequest; | ||
import com.vaadin.ui.Button; | ||
import com.vaadin.ui.Label; | ||
import com.vaadin.ui.VerticalLayout; | ||
|
||
public class BoardDynamicResizeUI extends AbstractTestUI { | ||
|
||
@Override | ||
protected void init(VaadinRequest request) { | ||
VerticalLayout layout = new VerticalLayout(); | ||
Board board = new Board(); | ||
board.setSizeFull(); | ||
|
||
Label lbl1 = new Label("Label 1"); | ||
Label lbl2 = new Label("Label 2"); | ||
Label lbl3 = new Label("Label 3"); | ||
board.addRow(lbl1, lbl2, lbl3); | ||
|
||
Button button = new Button("resize"); | ||
button.addClickListener(e->{ | ||
board.setWidth("300px"); | ||
}); | ||
layout.addComponents(board, button); | ||
setContent(layout); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
...ation-tests/src/test/java/com/vaadin/addon/board/testbenchtests/BoardDynamicResizeIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.vaadin.addon.board.testbenchtests; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.openqa.selenium.WebElement; | ||
|
||
import com.vaadin.addon.board.testUI.BoardDynamicResizeUI; | ||
import com.vaadin.testbench.By; | ||
import com.vaadin.testbench.elements.ButtonElement; | ||
|
||
public class BoardDynamicResizeIT extends AbstractParallelTest { | ||
|
||
@Override | ||
protected Class<?> getUIClass() { | ||
return BoardDynamicResizeUI.class; | ||
} | ||
|
||
@Test | ||
public void basicLayout_boardTabletSize_twoRowsAndTwoItemsInRow() { | ||
WebElement board = getDriver().findElement(By.tagName("vaadin-board")); | ||
List<WebElement> rowChildren = board.findElements(By.xpath("//vaadin-board/vaadin-board-row/*")); | ||
ButtonElement resizeButton = $(ButtonElement.class).caption("resize").first(); | ||
resizeButton.click(); | ||
|
||
Assert.assertEquals("Lbl1 should have same Y as the board Y coordinate", | ||
board.getLocation().getY(), rowChildren.get(0).getLocation().getY()); | ||
|
||
Assert.assertEquals("Lbl2 should have Y == board.location + lbl1.height", | ||
board.getLocation().getY() + rowChildren.get(0).getSize().getHeight(), | ||
rowChildren.get(1).getLocation().getY()); | ||
|
||
Assert.assertEquals("Lbl3 should have Y == lbl2.location + lbl1.height + lbl2.height", | ||
rowChildren.get(1).getLocation().getY() + rowChildren.get(2).getSize().getHeight(), | ||
rowChildren.get(2).getLocation().getY()); | ||
} | ||
|
||
} |