From 264ee7696568827815604f1e22ce7e330775b3ce Mon Sep 17 00:00:00 2001 From: Ilia Motornyi Date: Thu, 9 Mar 2017 09:29:20 +0200 Subject: Fix Upload and push in TabSheet (#8782) Also fixes JSNI calls in compatibility Upload component. Fixes #8728 for the compatibility package --- .../components/upload/UploadInTabsheetV7.java | 41 ++++++++++++++++++++++ .../components/upload/UploadInTabsheetV7Test.java | 39 ++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 uitest/src/main/java/com/vaadin/tests/components/upload/UploadInTabsheetV7.java create mode 100644 uitest/src/test/java/com/vaadin/tests/components/upload/UploadInTabsheetV7Test.java (limited to 'uitest') diff --git a/uitest/src/main/java/com/vaadin/tests/components/upload/UploadInTabsheetV7.java b/uitest/src/main/java/com/vaadin/tests/components/upload/UploadInTabsheetV7.java new file mode 100644 index 0000000000..64de1cde1d --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/upload/UploadInTabsheetV7.java @@ -0,0 +1,41 @@ +package com.vaadin.tests.components.upload; + +import com.vaadin.annotations.Push; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.Label; +import com.vaadin.v7.ui.Upload; + +import java.io.ByteArrayOutputStream; + +/** + * Test UI for case where Upload is in a TabSheet and Tab is changed directly + * after Upload Succeed + */ +@Push +public class UploadInTabsheetV7 extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + TabSheet t = new TabSheet(); + Upload upload = new Upload("Upload", (filename, mimeType) -> new + ByteArrayOutputStream()); + upload.setImmediate(false); + upload.addSucceededListener(event -> upload.getUI().access(()->{ + t.setSelectedTab(1); + })); + upload.setWidthUndefined(); + + t.addComponent(upload); + t.addComponent(new Label("Second tab")); + + addComponent(t); + } + + @Override + protected Integer getTicketNumber() { + return 8728; + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/UploadInTabsheetV7Test.java b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadInTabsheetV7Test.java new file mode 100644 index 0000000000..051cf7a56e --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/upload/UploadInTabsheetV7Test.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2016 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.testbench.elements.UploadElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.internal.WrapsElement; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.LocalFileDetector; +import org.openqa.selenium.remote.RemoteWebElement; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.List; + +/** + * Verifies that there's no client side errors when changing a tab containing + * Upload right after uploading is succeeded (#8728) + */ +public class UploadInTabsheetV7Test extends UploadInTabsheetTest { +} -- cgit v1.2.3