aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2020-04-06 12:25:50 +0300
committerGitHub <noreply@github.com>2020-04-06 12:25:50 +0300
commitf42cb187854186191ebaad73b3ad0c187cbb76a6 (patch)
tree09979d30e761efe970752a6f09d5d836cdf9c911 /uitest
parent240cdce985bfc08a6e2869d1de52718227706640 (diff)
downloadvaadin-framework-f42cb187854186191ebaad73b3ad0c187cbb76a6.tar.gz
vaadin-framework-f42cb187854186191ebaad73b3ad0c187cbb76a6.zip
Allow setting Upload button caption as HTML, move data to SharedState. (#11940)
Fixes #11810
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/upload/UploadHtmlCaption.java40
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/upload/UploadHtmlCaptionTest.java67
2 files changed, 107 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/UploadHtmlCaption.java b/uitest/src/main/java/com/vaadin/tests/components/upload/UploadHtmlCaption.java
new file mode 100644
index 0000000000..b48092d14a
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/upload/UploadHtmlCaption.java
@@ -0,0 +1,40 @@
+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 UploadHtmlCaption extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Upload upload = new Upload();
+ upload.setImmediateMode(false);
+ upload.setButtonCaption("<b>Submit button</b>");
+ upload.setCaption("This is the caption of the <b>entire</b> component");
+ addComponent(upload);
+
+ Button toggleButtonCaption = new Button("Toggle button caption",
+ e -> upload.setButtonCaptionAsHtml(
+ !upload.isButtonCaptionAsHtml()));
+ toggleButtonCaption.setId("toggleButtonCaption");
+ addComponent(toggleButtonCaption);
+
+ Button toggleComponentCaption = new Button("Toggle component caption",
+ e -> upload.setCaptionAsHtml(!upload.isCaptionAsHtml()));
+ toggleComponentCaption.setId("toggleComponentCaption");
+ addComponent(toggleComponentCaption);
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11810;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "It should be possible to set component caption and submit button caption "
+ + "to allow HTML display mode independently of each other.";
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/UploadHtmlCaptionTest.java b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadHtmlCaptionTest.java
new file mode 100644
index 0000000000..0008e78351
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadHtmlCaptionTest.java
@@ -0,0 +1,67 @@
+package com.vaadin.tests.components.upload;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.UploadElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class UploadHtmlCaptionTest extends MultiBrowserTest {
+
+ @Test
+ public void htmlCaptionToggle() {
+ openTestURL();
+
+ UploadElement upload = $(UploadElement.class).first();
+ WebElement submitButtonCaption = upload
+ .findElement(By.className("v-button-caption"));
+ WebElement componentCaption = findElement(By.className("v-caption"));
+ ButtonElement toggleButtonCaption = $(ButtonElement.class)
+ .id("toggleButtonCaption");
+ ButtonElement toggleComponentCaption = $(ButtonElement.class)
+ .id("toggleComponentCaption");
+
+ assertTrue(
+ "Unexpected submit button caption: "
+ + submitButtonCaption.getText(),
+ submitButtonCaption.getText().contains("<b>"));
+ assertTrue(
+ "Unexpected component caption: " + componentCaption.getText(),
+ componentCaption.getText().contains("<b>"));
+
+ toggleButtonCaption.click();
+
+ assertFalse(
+ "Unexpected submit button caption: "
+ + submitButtonCaption.getText(),
+ submitButtonCaption.getText().contains("<b>"));
+ assertTrue(
+ "Unexpected component caption: " + componentCaption.getText(),
+ componentCaption.getText().contains("<b>"));
+
+ toggleComponentCaption.click();
+
+ assertFalse(
+ "Unexpected submit button caption: "
+ + submitButtonCaption.getText(),
+ submitButtonCaption.getText().contains("<b>"));
+ assertFalse(
+ "Unexpected component caption: " + componentCaption.getText(),
+ componentCaption.getText().contains("<b>"));
+
+ toggleButtonCaption.click();
+
+ assertTrue(
+ "Unexpected submit button caption: "
+ + submitButtonCaption.getText(),
+ submitButtonCaption.getText().contains("<b>"));
+ assertFalse(
+ "Unexpected component caption: " + componentCaption.getText(),
+ componentCaption.getText().contains("<b>"));
+ }
+}