diff options
author | Denis Anisimov <denis@vaadin.com> | 2014-09-23 22:18:40 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-12-10 21:43:51 +0000 |
commit | 23bdb6e90d970bd4e9ef11c79c095e65b6963414 (patch) | |
tree | 4aab989b74a32704b8e5fa9852e883eba7032b8c /uitest | |
parent | 22b20bc9fc4067a026cf08b5130bd20afa89d27e (diff) | |
download | vaadin-framework-23bdb6e90d970bd4e9ef11c79c095e65b6963414.tar.gz vaadin-framework-23bdb6e90d970bd4e9ef11c79c095e65b6963414.zip |
Notify server side component about clicks in form layout (#6346).
Change-Id: Idc4399dc94b253694c4e0d716d2b65964a2217f8
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/formlayout/FormLayoutClickListener.java | 69 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/formlayout/FormLayoutClickListenerTest.java | 62 |
2 files changed, 131 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/formlayout/FormLayoutClickListener.java b/uitest/src/com/vaadin/tests/components/formlayout/FormLayoutClickListener.java new file mode 100644 index 0000000000..35b8d9ca86 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/formlayout/FormLayoutClickListener.java @@ -0,0 +1,69 @@ +/* + * 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.formlayout; + +import com.vaadin.event.LayoutEvents.LayoutClickEvent; +import com.vaadin.event.LayoutEvents.LayoutClickListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.FormLayout; +import com.vaadin.ui.Label; + +/** + * Test UI for Form layout click listener. + * + * @author Vaadin Ltd + */ +public class FormLayoutClickListener extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + FormLayout layout = new FormLayout(); + + layout.addStyleName("form"); + + Label label = new Label("target"); + label.addStyleName("label"); + layout.addComponent(label); + + layout.addLayoutClickListener(new LayoutClickListener() { + + @Override + public void layoutClick(LayoutClickEvent event) { + log("Child component: " + + (event.getChildComponent() == null ? null : event + .getChildComponent().getStyleName())); + log("Clicked component: " + + (event.getClickedComponent() == null ? null : event + .getClickedComponent().getStyleName())); + log("Source component: " + event.getComponent().getStyleName()); + } + }); + + addComponent(layout); + } + + @Override + protected String getTestDescription() { + return "LayoutClickListener should work in FormLayout"; + } + + @Override + protected Integer getTicketNumber() { + return 6346; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/formlayout/FormLayoutClickListenerTest.java b/uitest/src/com/vaadin/tests/components/formlayout/FormLayoutClickListenerTest.java new file mode 100644 index 0000000000..bcab514a5d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/formlayout/FormLayoutClickListenerTest.java @@ -0,0 +1,62 @@ +/* + * 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.formlayout; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.testbench.elements.FormLayoutElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test for form layout click listener. + * + * @author Vaadin Ltd + */ +public class FormLayoutClickListenerTest extends MultiBrowserTest { + + @Before + public void setUp() { + openTestURL(); + } + + @Test + public void layoutClickListener_clickOnLayout_childAndClickedComponentsAreNull() { + $(FormLayoutElement.class).first().click(); + + Assert.assertEquals("Source component for click event must be form", + "3. Source component: form", getLogRow(0)); + Assert.assertEquals("Clicked component for click event must be null", + "2. Clicked component: null", getLogRow(1)); + Assert.assertEquals("Child component for click event must be null", + "1. Child component: null", getLogRow(2)); + } + + @Test + public void layoutClickListener_clickOnLabel_lableIsChildAndClickedComponent() { + findElement(By.className("label")).click(); + + Assert.assertEquals("Source component for click event must be form", + "3. Source component: form", getLogRow(0)); + Assert.assertEquals("Clicked component for click event must be label", + "2. Clicked component: label", getLogRow(1)); + Assert.assertEquals("Child component for click event must be label", + "1. Child component: label", getLogRow(2)); + } + +} |