Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaked layouttester tests to be more informative. (#11800) #11813

Merged
merged 5 commits into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private void buildLayout() {
}
layout.setMargin(false);
layout.setSpacing(false);
layout.setHeight("300px");
layout.setHeight("100px");
layout.setWidth("200px");
layout.addComponent(components[i]);
layout.setComponentAlignment(components[i], alignments[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ public ExpandButton(final AbstractComponent c1,
}
Table t1 = getTestTable();
Table t2 = getTestTable();
t1.setSizeFull();
t2.setSizeFull();
l2.addComponent(t1);
l2.addComponent(t2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ protected void setup(VaadinRequest request) {
private void buildLayout() {
Table t1 = getTestTable();
Table t2 = getTestTable();
t1.setSizeFull();
t2.setSizeFull();
l2.addComponent(t1);
l2.setMargin(false);
l2.setSpacing(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ public abstract class BaseLayoutTestUI extends AbstractReindeerTestUI {
protected static final String CALENDAR_32_PNG = "../runo/icons/16/calendar.png";
protected static final String LOCK_16_PNG = "../runo/icons/16/lock.png";
protected static final String GLOBE_16_PNG = "../runo/icons/16/globe.png";
public Alignment[] alignments = { Alignment.TOP_CENTER, Alignment.TOP_LEFT,
Alignment.TOP_RIGHT, Alignment.BOTTOM_CENTER, Alignment.BOTTOM_LEFT,
Alignment.BOTTOM_RIGHT, Alignment.MIDDLE_CENTER,
Alignment.MIDDLE_LEFT, Alignment.MIDDLE_RIGHT };
public Alignment[] alignments = new Alignment[] { Alignment.TOP_LEFT,
Alignment.TOP_CENTER, Alignment.TOP_RIGHT, Alignment.MIDDLE_LEFT,
Alignment.MIDDLE_CENTER, Alignment.MIDDLE_RIGHT,
Alignment.BOTTOM_LEFT, Alignment.BOTTOM_CENTER,
Alignment.BOTTOM_RIGHT };

public final String[] CAPTIONS = { "", "VeryLongOneWordCaption",
"Very long caption of 50 approximately symbols aaaaaaaaaaaa aaaaaa aaa " };
Expand Down Expand Up @@ -74,7 +75,8 @@ protected void init() {
private void fillComponents() {
for (int i = 0; i < components.length; i++) {
String name = "Field" + i;
TextField field = new TextField();
TextField field = new TextField(alignments[i].getVerticalAlignment()
+ " " + alignments[i].getHorizontalAlignment());
field.setValue(name);
components[i] = field;
}
Expand All @@ -91,9 +93,7 @@ protected void getLayoutForLayoutSizing(final String compType) {
l2.setMargin(false);

final AbstractComponent c1 = getTestTable();
c1.setSizeFull();
final AbstractComponent c2 = getTestTable();
c2.setSizeFull();

class SetSizeButton extends Button {
SetSizeButton(final String size) {
Expand All @@ -106,6 +106,7 @@ class SetSizeButton extends Button {
} else if (compType == "component") {
c2.setHeight(size);
c2.setWidth(size);
c2.setCaption("Configured width");
}
});
}
Expand Down Expand Up @@ -135,11 +136,13 @@ class SetSizeButton extends Button {
newLabel.setSizeUndefined();
l2.addComponent(newLabel);
});
btn2.setCaption(btn2.getCaption() + " + add Label");
}

protected Table getTestTable() {
Table t = new Table();
t.setPageLength(5);
t.setSizeFull();
t.setCaption("100% default width");
t.addContainerProperty("test", String.class, null);
t.addItem(new Object[] { "qwertyuiop asdfghjköäxccvbnm,m,." }, 1);
t.addItem(new Object[] { "YGVYTCTCTRXRXRXRX" }, 2);
Expand Down Expand Up @@ -207,6 +210,12 @@ protected AbstractLayout createLabelsFields(
protected void setup(VaadinRequest request) {
mainLayout.setMargin(false);
mainLayout.setSpacing(false);
mainLayout.setSizeUndefined();
getLayout().setSizeUndefined();
if (getLayout().getParent() instanceof VerticalLayout) {
((VerticalLayout) getLayout().getParent()).setSizeUndefined();
}

mainLayout.addComponent(l1);
mainLayout.addComponent(l2);
addComponent(mainLayout);
Expand All @@ -226,8 +235,8 @@ protected void setLayoutMeasures(AbstractOrderedLayout l1,
AbstractOrderedLayout l2, String w, String h) {
l1.setWidth(w);
l1.setHeight(h);
l2.setWidth(h);
l2.setHeight(w);
l2.setWidth(w);
l2.setHeight(h);
}

protected void setDefaultForVertical(AbstractOrderedLayout l1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class GridAlignment extends GridBaseLayoutTestUI {
protected void setup(VaadinRequest request) {
buildLayout();
super.setup(request);
layout.setSizeFull();
}

/**
Expand All @@ -16,8 +17,6 @@ protected void setup(VaadinRequest request) {
private void buildLayout() {
layout.setColumns(3);
layout.setRows(3);
// layout.setHeight("600px");
// layout.setWidth("900px");
for (int i = 0; i < components.length; i++) {
layout.addComponent(components[i]);
layout.setComponentAlignment(components[i], alignments[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public GridBaseLayoutTestUI() {

@Override
protected void setup(VaadinRequest request) {
layout.setMargin(true);
layout.setSizeFull();
layout.setSizeUndefined();
getUI().setContent(layout);
}

Expand All @@ -33,9 +32,7 @@ protected void getLayoutForLayoutSizing(final String compType) {
layout.setMargin(false);

final AbstractComponent c1 = getTestTable();
c1.setSizeFull();
final AbstractComponent c2 = getTestTable();
c2.setSizeFull();

class SetSizeButton extends Button {
SetSizeButton(final String size) {
Expand All @@ -48,11 +45,12 @@ class SetSizeButton extends Button {
} else if (compType == "component") {
c2.setHeight(size);
c2.setWidth(size);
c2.setCaption("Configured width");
}
});
}
}
Button btn1 = new SetSizeButton("550px");
Button btn1 = new SetSizeButton("350px");
Button btn2 = new SetSizeButton("-1px");
Button btn3 = new SetSizeButton("75%");
Button btn4 = new SetSizeButton("100%");
Expand All @@ -74,5 +72,6 @@ class SetSizeButton extends Button {
newLabel.setSizeUndefined();
layout.addComponent(newLabel);
});
btn2.setCaption(btn2.getCaption() + " + add Label");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public class GridComponentSizing extends GridBaseLayoutTestUI {
protected void setup(VaadinRequest request) {
getLayoutForLayoutSizing("component");
super.setup(request);
layout.setSizeFull();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.Link;
Expand All @@ -19,4 +20,13 @@ protected void setup(VaadinRequest request) {
layout.addComponent(createLabelsFields(TabSheet.class, true, ""));
super.setup(request);
}

@Override
protected void setLayoutMeasures(AbstractOrderedLayout l1,
AbstractOrderedLayout l2, String w, String h) {
super.setLayoutMeasures(l1, l2, "400px", "-1px");
l1.setSpacing(true);
l2.setSpacing(true);
mainLayout.setSpacing(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class GridLayoutExpand extends GridBaseLayoutTestUI {
protected void setup(VaadinRequest request) {
buildLayout();
super.setup(request);
layout.setSizeFull();
}

private void buildLayout() {
Expand All @@ -27,8 +28,6 @@ public ExpandButton(final int i1, final int i2, final float e1,
}
Table t1 = getTestTable();
Table t2 = getTestTable();
t1.setSizeFull();
t2.setSizeFull();
layout.setColumns(4);
layout.setRows(4);
layout.addComponent(new ExpandButton(1, 2, 1.0f, 0.0f), 0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ protected void setup(VaadinRequest request) {
private void buildLayout() {
Table t1 = getTestTable();
Table t2 = getTestTable();
t1.setSizeFull();
t2.setSizeFull();
t1.setSizeUndefined();
t2.setSizeUndefined();

final Button btn1 = new Button("Toggle margin on/off");
btn1.addClickListener(event -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Label;
Expand Down Expand Up @@ -31,4 +32,10 @@ private void buildLayout() {
layout.addComponent(createLabelsFields(CheckBox.class, true, ""));

}

@Override
protected void setDefaultForVertical(AbstractOrderedLayout l1,
AbstractOrderedLayout l2) {
setLayoutMeasures(l1, l2, "800px", "800px");
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,76 @@
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Label;

public class GridLayoutSizing extends GridBaseLayoutTestUI {

@Override
protected void setup(VaadinRequest request) {
getLayoutForLayoutSizing("layout");
super.setup(request);
layout.setSizeFull();
}

@Override
protected void getLayoutForLayoutSizing(final String compType) {

layout.setSpacing(false);
layout.setMargin(false);

final AbstractComponent c1 = getTestTable();
final AbstractComponent c2 = getTestTable();

class SetSizeButton extends Button {
SetSizeButton(final String size) {
super();
setCaption("Set size " + size);
addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
if (compType == "layout") {
layout.setHeight(size);
layout.setWidth(size);
} else if (compType == "component") {
c2.setHeight(size);
c2.setWidth(size);
} else {
}

}
});
}

}
Button btn1 = new SetSizeButton("600px");
Button btn2 = new SetSizeButton("-1px");
Button btn3 = new SetSizeButton("75%");
Button btn4 = new SetSizeButton("100%");

layout.addComponent(btn1);
layout.addComponent(btn2);
layout.addComponent(btn3);
layout.addComponent(btn4);
layout.addComponent(c1);
layout.addComponent(new Label(
"<div style='height: 1px'></div><hr /><div style='height: 1px'></div>",
ContentMode.HTML));
layout.addComponent(c2);
btn2.addClickListener(new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
Label newLabel = new Label("--- NEW LABEL ---");
newLabel.setSizeUndefined();
layout.addComponent(newLabel);
}
});
btn2.setCaption(btn2.getCaption() + " + add Label");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.tests.layouts.layouttester.BaseAddReplaceMove;
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.HorizontalLayout;

public class HAddReplaceMove extends BaseAddReplaceMove {
Expand All @@ -12,4 +13,10 @@ public HAddReplaceMove() {
super(HorizontalLayout.class);
}

@Override
protected void setLayoutMeasures(AbstractOrderedLayout l1,
AbstractOrderedLayout l2, String w, String h) {
super.setLayoutMeasures(l1, l2, "1200px", h);
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.vaadin.tests.layouts.layouttester.HLayout;

import com.vaadin.tests.layouts.layouttester.BaseAlignment;
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.HorizontalLayout;

public class HAlignment extends BaseAlignment {
Expand All @@ -9,4 +10,10 @@ public HAlignment() {
super(HorizontalLayout.class);
}

@Override
protected void setLayoutMeasures(AbstractOrderedLayout l1,
AbstractOrderedLayout l2, String w, String h) {
super.setLayoutMeasures(l1, l2, "1000px", "200px");
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
package com.vaadin.tests.layouts.layouttester.HLayout;

import java.util.Iterator;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.layouts.layouttester.BaseComponentSizing;
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;

public class HComponentSizing extends BaseComponentSizing {

public HComponentSizing() {
super(HorizontalLayout.class);
}

@Override
protected void setup(VaadinRequest request) {
super.setup(request);
Iterator<Component> iterator = l2.iterator();
while (iterator.hasNext()) {
Component component = iterator.next();
if (component instanceof Label) {
component.setWidth("30px");
}
}
}

@Override
protected void setLayoutMeasures(AbstractOrderedLayout l1,
AbstractOrderedLayout l2, String w, String h) {
super.setLayoutMeasures(l1, l2, "900px", h);
l1.setSizeUndefined();
}
}
Loading