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
*/ | */ | ||||
public boolean showLoadingIndicator() { | public boolean showLoadingIndicator() { | ||||
for (MethodInvocation invocation : getAll()) { | 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; | return true; | ||||
} else if (!isJavascriptRpc(invocation)) { | |||||
} else { | |||||
Type type = new Type(invocation.getInterfaceName(), null); | Type type = new Type(invocation.getInterfaceName(), null); | ||||
Method method = type.getMethod(invocation.getMethodName()); | Method method = type.getMethod(invocation.getMethodName()); | ||||
if (!TypeDataStore.isNoLoadingIndicator(method)) { | if (!TypeDataStore.isNoLoadingIndicator(method)) { |
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()); | |||||
} | |||||
} |
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(); | |||||
}); | |||||
} |
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(); | return loadingIndicator.isDisplayed(); | ||||
} | } | ||||
protected void waitUntilLoadingIndicatorNotVisible() { | |||||
protected void waitUntilLoadingIndicatorVisible() { | |||||
waitUntil(new ExpectedCondition<Boolean>() { | waitUntil(new ExpectedCondition<Boolean>() { | ||||
@Override | @Override | ||||
public Boolean apply(WebDriver input) { | 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(); | |||||
} | } | ||||
}); | }); | ||||
} | } |