summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorSauli Tähkäpää <sauli@vaadin.com>2014-10-12 23:42:28 +0300
committerSauli Tähkäpää <sauli@vaadin.com>2014-10-29 10:46:08 +0200
commit3e9e19fc57b963e8a2e6c0d3c9a1bdafbc8e4b04 (patch)
tree3953592ac145231d7daa3842d3ad4da98cd39134 /uitest
parent6a7afc477caec242cbe67a7cb5d36b0a2c59cd97 (diff)
downloadvaadin-framework-3e9e19fc57b963e8a2e6c0d3c9a1bdafbc8e4b04.tar.gz
vaadin-framework-3e9e19fc57b963e8a2e6c0d3c9a1bdafbc8e4b04.zip
Set v-disabled on Button inside Upload when disabled. (#14655)
Change-Id: Ic28c8e4020eddae32a71b5c7f9da0ad61f2f7af9
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/upload/DisabledUploadButton.java41
-rw-r--r--uitest/src/com/vaadin/tests/components/upload/DisabledUploadButtonTest.java55
2 files changed, 96 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/upload/DisabledUploadButton.java b/uitest/src/com/vaadin/tests/components/upload/DisabledUploadButton.java
new file mode 100644
index 0000000000..dcf2ac2784
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/upload/DisabledUploadButton.java
@@ -0,0 +1,41 @@
+package com.vaadin.tests.components.upload;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Upload;
+
+public class DisabledUploadButton extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final Upload upload = new Upload();
+
+ addComponent(upload);
+
+ addButton("Set readonly", new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ upload.setReadOnly(true);
+ }
+ });
+
+ addButton("Set disabled", new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ upload.setEnabled(false);
+ }
+ });
+ }
+
+ @Override
+ public String getDescription() {
+ return "Upload button should be disabled when upload "
+ + "is set to readonly and/or disabled";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14655;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/upload/DisabledUploadButtonTest.java b/uitest/src/com/vaadin/tests/components/upload/DisabledUploadButtonTest.java
new file mode 100644
index 0000000000..cc97b4d7d1
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/upload/DisabledUploadButtonTest.java
@@ -0,0 +1,55 @@
+package com.vaadin.tests.components.upload;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.UploadElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class DisabledUploadButtonTest extends MultiBrowserTest {
+
+ @Override
+ public void setup() throws Exception {
+ super.setup();
+ openTestURL();
+ }
+
+ private String getUploadButtonClass() {
+ WebElement uploadButton = getUploadButton();
+
+ return uploadButton.getAttribute("class");
+ }
+
+ private void clickButton(String caption) {
+ $(ButtonElement.class).caption(caption).first().click();
+ }
+
+ private WebElement getUploadButton() {
+ UploadElement upload = $(UploadElement.class).first();
+ return upload.findElement(By.className("v-button"));
+ }
+
+ @Test
+ public void buttonIsReadonly() {
+ assertThat(getUploadButtonClass(), not(containsString("v-disabled")));
+
+ clickButton("Set readonly");
+
+ assertThat(getUploadButtonClass(), containsString("v-disabled"));
+ }
+
+ @Test
+ public void buttonIsDisabled() {
+ assertThat(getUploadButtonClass(), not(containsString("v-disabled")));
+
+ clickButton("Set disabled");
+
+ assertThat(getUploadButtonClass(), containsString("v-disabled"));
+ }
+} \ No newline at end of file