瀏覽代碼

Add body style name when reconnecting (#18838)

Change-Id: I7ff28587780fbd1c68b065b3edc670a879e8551e
tags/7.6.0.alpha6
Artur Signell 8 年之前
父節點
當前提交
154396df74

+ 1
- 0
client/src/com/vaadin/client/communication/DefaultConnectionStateHandler.java 查看文件

@@ -365,6 +365,7 @@ public class DefaultConnectionStateHandler implements ConnectionStateHandler {
* Called when the reconnect dialog should be hidden.
*/
protected void hideDialog() {
reconnectDialog.setReconnecting(false);
reconnectDialog.hide();
}


+ 9
- 0
client/src/com/vaadin/client/communication/DefaultReconnectDialog.java 查看文件

@@ -18,6 +18,8 @@ package com.vaadin.client.communication;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.dom.client.BodyElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Style.Visibility;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@@ -38,6 +40,7 @@ import com.vaadin.client.ui.VOverlay;
public class DefaultReconnectDialog extends VOverlay implements ReconnectDialog {

private static final String STYLE_RECONNECTING = "active";
private static final String STYLE_BODY_RECONNECTING = "v-reconnecting";

public Label label;

@@ -68,6 +71,12 @@ public class DefaultReconnectDialog extends VOverlay implements ReconnectDialog
@Override
public void setReconnecting(boolean reconnecting) {
setStyleName(STYLE_RECONNECTING, reconnecting);
BodyElement body = Document.get().getBody();
if (reconnecting) {
body.addClassName(STYLE_BODY_RECONNECTING);
} else {
body.removeClassName(STYLE_BODY_RECONNECTING);
}

// Click to refresh after giving up
if (!reconnecting) {

+ 17
- 0
uitest/src/com/vaadin/tests/application/ReconnectDialogUITest.java 查看文件

@@ -30,6 +30,23 @@ import com.vaadin.tests.tb3.MultiBrowserTestWithProxy;
@TestCategory("communication")
public class ReconnectDialogUITest extends MultiBrowserTestWithProxy {

@Test
public void reconnectTogglesBodyStyle() throws JSchException {
openTestURL();
getButton().click();
disconnectProxy();
getButton().click();
waitForReconnectDialogPresent();
WebElement body = findElement(By.xpath("//body"));
Assert.assertTrue("Body should have a style name when reconnecting",
hasCssClass(body, "v-reconnecting"));
connectProxy();
waitForReconnectDialogToDisappear();
Assert.assertFalse(
"Body should no longer have a style name when reconnected",
hasCssClass(body, "v-reconnecting"));
}

@Test
public void reconnectDialogShownAndDisappears() throws JSchException {
openTestURL();

Loading…
取消
儲存