*/
public boolean showLoadingIndicator() {
for (MethodInvocation invocation : getAll()) {
- if (isLegacyVariableChange(invocation)) {
- // Always show loading indicator for legacy requests
+ if (isLegacyVariableChange(invocation)
+ || isJavascriptRpc(invocation)) {
+ // Always show loading indicator for legacy and JS requests as
+ // they have no @NoLoadingIndicator they can use
return true;
- } else if (!isJavascriptRpc(invocation)) {
+ } else {
Type type = new Type(invocation.getInterfaceName(), null);
Method method = type.getMethod(invocation.getMethodName());
if (!TypeDataStore.isNoLoadingIndicator(method)) {
--- /dev/null
+package com.vaadin.tests.components.javascriptcomponent;
+
+import com.vaadin.annotations.JavaScript;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.AbstractJavaScriptComponent;
+import com.vaadin.ui.JavaScriptFunction;
+import com.vaadin.ui.Label;
+
+import elemental.json.JsonArray;
+
+public class JSComponentLoadingIndicator extends AbstractTestUI {
+
+ @JavaScript({ "JSComponent.js" })
+ public class JSComponent extends AbstractJavaScriptComponent {
+ public JSComponent() {
+ addFunction("test", new JavaScriptFunction() {
+ @Override
+ public void call(JsonArray arguments) {
+ try {
+ Thread.sleep(1000);
+ Label label = new Label("pong");
+ label.addStyleName("pong");
+ addComponent(label);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+ }
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ addComponent(new JSComponent());
+ }
+
+}
--- /dev/null
+com_vaadin_tests_components_javascriptcomponent_JSComponentLoadingIndicator_JSComponent = function()
+{
+ var connector = this;
+ var e = this.getElement();
+
+ e.innerText="click me to ping server";
+ e.id="js";
+ e.addEventListener("click", function() {
+ connector.test();
+ });
+}
\ No newline at end of file
--- /dev/null
+package com.vaadin.tests.components.javascriptcomponent;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class JSComponentLoadingIndicatorTest extends SingleBrowserTest {
+
+ @Test
+ public void ensureLoadingIndicatorShown() {
+ openTestURL();
+ testBench().disableWaitForVaadin();
+
+ WebElement js = findElement(By.id("js"));
+ js.click();
+ waitUntilLoadingIndicatorVisible();
+ waitUntilLoadingIndicatorNotVisible();
+ Assert.assertEquals(1, findElements(By.className("pong")).size());
+
+ js.click();
+ waitUntilLoadingIndicatorVisible();
+ waitUntilLoadingIndicatorNotVisible();
+ Assert.assertEquals(2, findElements(By.className("pong")).size());
+ }
+
+}
return loadingIndicator.isDisplayed();
}
- protected void waitUntilLoadingIndicatorNotVisible() {
+ protected void waitUntilLoadingIndicatorVisible() {
waitUntil(new ExpectedCondition<Boolean>() {
-
@Override
public Boolean apply(WebDriver input) {
- WebElement loadingIndicator = input.findElement(By
- .className("v-loading-indicator"));
+ return isLoadingIndicatorVisible();
+ }
+ });
+ }
- return !loadingIndicator.isDisplayed();
+ protected void waitUntilLoadingIndicatorNotVisible() {
+ waitUntil(new ExpectedCondition<Boolean>() {
+ @Override
+ public Boolean apply(WebDriver input) {
+ return !isLoadingIndicatorVisible();
}
});
}