diff options
8 files changed, 200 insertions, 34 deletions
diff --git a/WebContent/VAADIN/themes/base/upload/upload.scss b/WebContent/VAADIN/themes/base/upload/upload.scss index e705fc1c78..f8e707446c 100644 --- a/WebContent/VAADIN/themes/base/upload/upload.scss +++ b/WebContent/VAADIN/themes/base/upload/upload.scss @@ -4,12 +4,11 @@ white-space: nowrap; } - .#{$primaryStyleName}-immediate { position: relative; margin: 0; overflow: hidden; - .v-button{ + .v-button { width:100%; } } @@ -39,4 +38,4 @@ text-align: left; } -}
\ No newline at end of file +} diff --git a/WebContent/VAADIN/themes/valo/components/_upload.scss b/WebContent/VAADIN/themes/valo/components/_upload.scss index c301be060a..07a51f03ef 100644 --- a/WebContent/VAADIN/themes/valo/components/_upload.scss +++ b/WebContent/VAADIN/themes/valo/components/_upload.scss @@ -1,7 +1,7 @@ /** * * - * @param {string} $primary-stylename (v-upload) - + * @param {string} $primary-stylename (v-upload) - * * @group upload */ @@ -10,6 +10,10 @@ @include valo-widget-style; } + .#{$primary-stylename}-immediate .v-button { + width: 100%; + } + .#{$primary-stylename}-immediate input[type="file"] { @include opacity(0); z-index: 2; @@ -20,4 +24,4 @@ border: none; background: transparent; } -}
\ No newline at end of file +} diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidth.java b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidth.java index b0314e9907..48dd96bc43 100644 --- a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidth.java +++ b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidth.java @@ -20,31 +20,38 @@ import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Upload; import com.vaadin.ui.VerticalLayout; +// We're explicitly testing only immediate uploads here because non-immediate +// width issues still require planning before we can provide a fix. 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); + + // Let's use a separate layout without margins to make the + // button widths not dependent on the selected theme. + VerticalLayout layout = new VerticalLayout(); + layout.setWidth("500px"); + + layout.addComponent(getImmediateUpload("upload1", "300px")); + layout.addComponent(getImmediateUpload("upload2", "50%")); + layout.addComponent(getImmediateUpload("upload3", "")); + + addComponent(layout); + } + + private Upload getImmediateUpload(String id, String width) { + Upload upload = new Upload(); + + upload.setId(id); + upload.setWidth(width); + upload.setImmediate(true); + + return upload; } @Override protected String getTestDescription() { - return "Width of immediate upload button should obey setWidth()"; + return "Width of the upload button should obey setWidth() when using immediate"; } @Override diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthChameleonTest.java b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthChameleonTest.java new file mode 100644 index 0000000000..a0d6d471fb --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthChameleonTest.java @@ -0,0 +1,36 @@ +/* + * 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.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.closeTo; + +import com.vaadin.ui.themes.*; +import org.junit.Test; + +public class UploadImmediateButtonWidthChameleonTest extends + UploadImmediateButtonWidthTest { + + @Override + protected String getTheme() { + return ChameleonTheme.THEME_NAME; + } + + @Test + public void immediateButtonWithUndefinedWidth() { + assertThat(getButtonWidth("upload3"), closeTo(69, 4)); + } +} diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthReindeerTest.java b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthReindeerTest.java new file mode 100644 index 0000000000..c22e416a25 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthReindeerTest.java @@ -0,0 +1,36 @@ +/* + * 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.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.closeTo; + +import com.vaadin.ui.themes.*; +import org.junit.Test; + +public class UploadImmediateButtonWidthReindeerTest extends + UploadImmediateButtonWidthTest { + + @Override + protected String getTheme() { + return Reindeer.THEME_NAME; + } + + @Test + public void immediateButtonWithUndefinedWidth() { + assertThat(getButtonWidth("upload3"), closeTo(67, 8)); + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthRunoTest.java b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthRunoTest.java new file mode 100644 index 0000000000..0ab4fbbc7e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthRunoTest.java @@ -0,0 +1,36 @@ +/* + * 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.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.closeTo; + +import com.vaadin.ui.themes.*; +import org.junit.Test; + +public class UploadImmediateButtonWidthRunoTest extends + UploadImmediateButtonWidthTest { + + @Override + protected String getTheme() { + return Runo.THEME_NAME; + } + + @Test + public void immediateButtonWithUndefinedWidth() { + assertThat(getButtonWidth("upload3"), closeTo(72, 6)); + } +} diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthTest.java b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthTest.java index 37dcb47929..b2a29c92e3 100644 --- a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthTest.java +++ b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.components.upload; -import static org.junit.Assert.assertEquals; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -23,25 +24,36 @@ import org.openqa.selenium.WebElement; import com.vaadin.testbench.By; import com.vaadin.tests.tb3.MultiBrowserTest; -public class UploadImmediateButtonWidthTest extends MultiBrowserTest { +public abstract class UploadImmediateButtonWidthTest extends MultiBrowserTest { - private void checkButtonWidth(String id, int expectedWidth) { + protected abstract String getTheme(); + + protected double getButtonWidth(String id) { 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()); + + return button.getSize().getWidth(); } - @Test - public void buttonWithPixelWidth() { - openTestURL(); - checkButtonWidth("upload1", 300); + @Override + protected Class<?> getUIClass() { + return UploadImmediateButtonWidth.class; + } + + @Override + public void setup() throws Exception { + super.setup(); + + openTestURL(String.format("theme=%s", getTheme())); } @Test - public void buttonWithPercentageWidth() { - openTestURL(); - checkButtonWidth("upload2", 250); + public void immediateButtonWithPixelWidth() { + assertThat(getButtonWidth("upload1"), is(300.0)); } + @Test + public void immediateButtonWithPercentageWidth() { + assertThat(getButtonWidth("upload2"), is(250.0)); + } } diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthValoTest.java b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthValoTest.java new file mode 100644 index 0000000000..9d8fe6ba9e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/upload/UploadImmediateButtonWidthValoTest.java @@ -0,0 +1,36 @@ +/* + * 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.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.closeTo; + +import com.vaadin.ui.themes.*; +import org.junit.Test; + +public class UploadImmediateButtonWidthValoTest extends + UploadImmediateButtonWidthTest { + + @Override + protected String getTheme() { + return ValoTheme.THEME_NAME; + } + + @Test + public void immediateButtonWithUndefinedWidth() { + assertThat(getButtonWidth("upload3"), closeTo(89, 2)); + } +} |