The change to not show loading indicator for JS RPC was done in
15a53d305e
and looks like a refactoring
error.
Change-Id: If2a2818e0c4adc06479ecaf17764bf53fc89c095
tags/7.7.1
@@ -226,10 +226,12 @@ public class ServerRpcQueue { | |||
*/ | |||
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)) { |
@@ -0,0 +1,38 @@ | |||
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()); | |||
} | |||
} |
@@ -0,0 +1,11 @@ | |||
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(); | |||
}); | |||
} |
@@ -0,0 +1,29 @@ | |||
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()); | |||
} | |||
} |
@@ -1015,15 +1015,20 @@ public abstract class AbstractTB3Test extends ParallelTest { | |||
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(); | |||
} | |||
}); | |||
} |