From c8f212e9a311252468c9649ca3920451e4cd1cd6 Mon Sep 17 00:00:00 2001 From: "denis.magdenkov" Date: Wed, 1 Oct 2014 17:50:30 +0400 Subject: [PATCH] Fix button on immediate upload does not obey setWidth() (#14485) Added sass selector for upload in base theme. Change-Id: Iebf796f0965de6afeac98d6e2a2a9246c9251bab --- .../VAADIN/themes/base/upload/upload.scss | 3 + .../upload/UploadImmediateButtonWidth.java | 55 +++++++++++++++++++ .../UploadImmediateButtonWidthTest.java | 47 ++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidth.java create mode 100644 uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthTest.java diff --git a/WebContent/VAADIN/themes/base/upload/upload.scss b/WebContent/VAADIN/themes/base/upload/upload.scss index 933482764c..e705fc1c78 100644 --- a/WebContent/VAADIN/themes/base/upload/upload.scss +++ b/WebContent/VAADIN/themes/base/upload/upload.scss @@ -9,6 +9,9 @@ position: relative; margin: 0; overflow: hidden; + .v-button{ + width:100%; + } } .v-ff & .#{$primaryStyleName}-immediate, diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidth.java b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidth.java new file mode 100644 index 0000000000..b0314e9907 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidth.java @@ -0,0 +1,55 @@ +/* + * 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.upload; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Upload; +import com.vaadin.ui.VerticalLayout; + +public class UploadImmediateButtonWidth extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout lt = new VerticalLayout(); + lt.setWidth("500px"); + + Upload upload1 = new Upload(); + upload1.setImmediate(true); + upload1.setId("upload1"); + upload1.setWidth("300px"); + lt.addComponent(upload1); + + Upload upload2 = new Upload(); + upload2.setImmediate(true); + upload2.setWidth("50%"); + upload2.setId("upload2"); + lt.addComponent(upload2); + + addComponent(lt); + } + + @Override + protected String getTestDescription() { + return "Width of immediate upload button should obey setWidth()"; + } + + @Override + protected Integer getTicketNumber() { + return 14485; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthTest.java b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthTest.java new file mode 100644 index 0000000000..37dcb47929 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthTest.java @@ -0,0 +1,47 @@ +/* + * 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.upload; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class UploadImmediateButtonWidthTest extends MultiBrowserTest { + + private void checkButtonWidth(String id, int expectedWidth) { + WebElement upload = driver.findElement(By.id(id)); + WebElement button = upload.findElement(By.className("v-button")); + assertEquals("width of button " + id + " is incorrect", expectedWidth, + button.getSize().getWidth()); + } + + @Test + public void buttonWithPixelWidth() { + openTestURL(); + checkButtonWidth("upload1", 300); + } + + @Test + public void buttonWithPercentageWidth() { + openTestURL(); + checkButtonWidth("upload2", 250); + } + +} -- 2.39.5