From 1856423be3ad100679b9ac38656dd610c0061a76 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sauli=20T=C3=A4hk=C3=A4p=C3=A4=C3=A4?= Date: Sun, 6 Jul 2014 14:37:48 +0300 Subject: [PATCH] Convert CustomComponentChildVisibility to TB4. Change-Id: I8d1a61df37eb3af1f5c0ebcdcf3097df59a44652 --- .../CustomComponentChildVisibility.html | 47 ------------------- .../CustomComponentChildVisibility.java | 21 ++++----- .../CustomComponentChildVisibilityTest.java | 29 ++++++++++++ 3 files changed, 39 insertions(+), 58 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.html create mode 100644 uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibilityTest.java diff --git a/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.html b/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.html deleted file mode 100644 index ac2f0452b3..0000000000 --- a/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.customcomponent.CustomComponentChildVisibility?debug&restartApplication
assertTextvaadin=runcomvaadintestscomponentscustomcomponentCustomComponentChildVisibility::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VCustomComponent[0]/VPanel[0]/VLabel[0]In panel
mouseClickvaadin=runcomvaadintestscomponentscustomcomponentCustomComponentChildVisibility::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VCheckBox[0]/domChild[0]7,7
assertElementNotPresentvaadin=runcomvaadintestscomponentscustomcomponentCustomComponentChildVisibility::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VCustomComponent[0]/VPanel[0]/VLabel[0]In panel
mouseClickvaadin=runcomvaadintestscomponentscustomcomponentCustomComponentChildVisibility::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VCheckBox[0]/domChild[0]7,7
assertTextvaadin=runcomvaadintestscomponentscustomcomponentCustomComponentChildVisibility::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VCustomComponent[0]/VPanel[0]/VLabel[0]In panel
- - diff --git a/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.java b/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.java index a9899b2815..48484165ff 100644 --- a/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.java +++ b/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.java @@ -15,11 +15,9 @@ */ package com.vaadin.tests.components.customcomponent; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.CheckBox; +import com.vaadin.ui.Button; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; @@ -28,20 +26,21 @@ public class CustomComponentChildVisibility extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { + Label label = new Label("In panel"); + label.setId("label"); final CustomComponent cc = new CustomComponent(new Panel( - "In CustomComponent", new Label("In panel"))); + "In CustomComponent", label)); - final CheckBox cb = new CheckBox("CustomComponent visible"); - cb.setValue(true); - cb.setImmediate(true); - cb.addValueChangeListener(new ValueChangeListener() { + Button hideButton = new Button("Hide CustomComponent"); + hideButton.addClickListener(new Button.ClickListener() { @Override - public void valueChange(ValueChangeEvent event) { - cc.setVisible(cb.getValue()); + public void buttonClick(Button.ClickEvent event) { + cc.setVisible(false); } }); + addComponent(cc); - addComponent(cb); + addComponent(hideButton); } diff --git a/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibilityTest.java b/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibilityTest.java new file mode 100644 index 0000000000..4e0204604b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibilityTest.java @@ -0,0 +1,29 @@ +package com.vaadin.tests.components.customcomponent; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class CustomComponentChildVisibilityTest extends MultiBrowserTest { + + @Test + public void childVisibilityIsSet() { + openTestURL(); + + assertTrue(isChildElementVisible()); + + $(ButtonElement.class).first().click(); + + assertFalse(isChildElementVisible()); + } + + private boolean isChildElementVisible() { + return $(LabelElement.class).all().size() > 1; + } + + +} \ No newline at end of file -- 2.39.5