diff --git a/vaadin-dialog-flow-parent/vaadin-dialog-flow-integration-tests/src/main/java/com/vaadin/flow/component/dialog/tests/ModalityDialogsPage.java b/vaadin-dialog-flow-parent/vaadin-dialog-flow-integration-tests/src/main/java/com/vaadin/flow/component/dialog/tests/ModalityDialogsPage.java deleted file mode 100644 index 9d4687cc8c1..00000000000 --- a/vaadin-dialog-flow-parent/vaadin-dialog-flow-integration-tests/src/main/java/com/vaadin/flow/component/dialog/tests/ModalityDialogsPage.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2000-2025 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.flow.component.dialog.tests; - -import com.vaadin.flow.component.ModalityMode; -import com.vaadin.flow.component.dialog.Dialog; -import com.vaadin.flow.component.html.Div; -import com.vaadin.flow.component.html.Hr; -import com.vaadin.flow.component.html.NativeButton; -import com.vaadin.flow.router.Route; - -/** - * Page created for testing purposes. Not suitable for demos. - * - * @author Vaadin Ltd. - * - */ -@Route("vaadin-dialog/dialog-modality") -public class ModalityDialogsPage extends Div { - - private Log log = new Log(); - - public ModalityDialogsPage() { - Dialog strictModalDialog = createStrictModalDialog(); - - Dialog visualModalDialog = createVisualModalDialog(); - - Dialog nonModalDialog = setupNonModalDialog(); - - NativeButton openModal = new NativeButton("Open STRICT modal dialog", - event -> strictModalDialog.open()); - openModal.setId("open-strict-modal-dialog"); - - NativeButton openVisualModal = new NativeButton( - "Open VISUAL modal dialog", event -> visualModalDialog.open()); - openVisualModal.setId("open-visual-modal-dialog"); - - NativeButton addModal = new NativeButton("Add modal dialog to UI", - event -> add(strictModalDialog)); - addModal.setId("add-modal-dialog"); - - NativeButton enableCloseOnOutsideClick = new NativeButton( - "Enable close on outside click", - event -> strictModalDialog.setCloseOnOutsideClick(true)); - enableCloseOnOutsideClick.setId("enable-close-on-outside-click"); - - NativeButton openNonModal = new NativeButton("Open non modal dialog", - event -> nonModalDialog.open()); - openNonModal.setId("open-non-modal-dialog"); - - NativeButton log = new NativeButton("Log", - event -> this.log.log("Clicked")); - log.setId("log"); - - final NativeButton showStrictModal = new NativeButton( - "Show Hidden Modal", e -> strictModalDialog.setVisible(true)); - showStrictModal.setId("show-strict-modal"); - - final NativeButton showVisualModal = new NativeButton( - "Show Visual Modal", e -> visualModalDialog.setVisible(true)); - showVisualModal.setId("show-visual-modal"); - - add(openModal, addModal, enableCloseOnOutsideClick, showStrictModal, - openVisualModal, showVisualModal, openNonModal, log, new Hr(), - this.log); - } - - private Dialog setupNonModalDialog() { - final Dialog nonModalDialog = createNonModalDialog(); - nonModalDialog - .add(new NativeButton("close", e -> nonModalDialog.close())); - return nonModalDialog; - } - - private Dialog createVisualModalDialog() { - Dialog visualModalDialog = new Dialog(); - visualModalDialog.setModality(ModalityMode.VISUAL); - visualModalDialog.setCloseOnOutsideClick(false); - final NativeButton modalClose = new NativeButton("close", - e -> visualModalDialog.close()); - modalClose.setId("close"); - final NativeButton hide = new NativeButton("hide", - e -> visualModalDialog.setVisible(false)); - hide.setId("hide"); - visualModalDialog.add(modalClose, hide); - return visualModalDialog; - } - - private Dialog createStrictModalDialog() { - Dialog modalDialog = new Dialog(); - modalDialog.setModality(ModalityMode.STRICT); - modalDialog.setCloseOnOutsideClick(false); - final NativeButton modalClose = new NativeButton("close", - e -> modalDialog.close()); - modalClose.setId("close"); - final NativeButton hide = new NativeButton("hide", - e -> modalDialog.setVisible(false)); - hide.setId("hide"); - modalDialog.add(modalClose, hide); - - Dialog nonModalDialog = createNonModalDialog(); - - final NativeButton closeSub = new NativeButton("close", - e -> nonModalDialog.close()); - closeSub.setId("close-sub"); - final NativeButton logSub = new NativeButton("log", - e -> log.log("sub-click")); - logSub.setId("log-sub"); - nonModalDialog.add(closeSub, logSub); - - final NativeButton openSubDialog = new NativeButton("open dialog", - e -> nonModalDialog.open()); - openSubDialog.setId("open-sub"); - modalDialog.add(openSubDialog); - - return modalDialog; - } - - private Dialog createNonModalDialog() { - Dialog nonModalDialog = new Dialog(); - - nonModalDialog.setCloseOnOutsideClick(false); - nonModalDialog.setModality(ModalityMode.MODELESS); - - return nonModalDialog; - } - - public static class Log extends Div { - - public static final String LOG_ID = "log-output"; - - private int logCount; - - public Log() { - setId(LOG_ID); - } - - public void log(String msg) { - Div div = new Div(); - div.addClassName("log"); - logCount++; - div.setText(logCount + ". " + msg); - add(div); - } - } - -} diff --git a/vaadin-dialog-flow-parent/vaadin-dialog-flow-integration-tests/src/test/java/com/vaadin/flow/component/dialog/tests/ModalityDialogsPageIT.java b/vaadin-dialog-flow-parent/vaadin-dialog-flow-integration-tests/src/test/java/com/vaadin/flow/component/dialog/tests/ModalityDialogsPageIT.java deleted file mode 100644 index 8c7f868f061..00000000000 --- a/vaadin-dialog-flow-parent/vaadin-dialog-flow-integration-tests/src/test/java/com/vaadin/flow/component/dialog/tests/ModalityDialogsPageIT.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2000-2025 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.flow.component.dialog.tests; - -import static com.vaadin.flow.component.dialog.tests.ModalityDialogsPage.Log.LOG_ID; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.vaadin.flow.component.dialog.testbench.DialogElement; -import com.vaadin.flow.component.html.testbench.DivElement; -import com.vaadin.flow.component.html.testbench.NativeButtonElement; -import com.vaadin.flow.testutil.TestPath; - -@TestPath("vaadin-dialog/dialog-modality") -public class ModalityDialogsPageIT extends AbstractDialogIT { - - @Before - public void init() { - open(); - Assert.assertEquals("No log messages should exist on open", 0, - $(DivElement.class).id(LOG_ID).$("div").all().size()); - } - - @Test - public void openNonModalDialog_logButtonClickable() { - $(NativeButtonElement.class).id("open-non-modal-dialog").click(); - verifyNumberOfDialogs(1); - - $(NativeButtonElement.class).id("log").click(); - - verifyOpened(); - Assert.assertEquals("Click should have resulted in a log message", 1, - $(DivElement.class).id(LOG_ID).$("div").all().size()); - - getDialog().$(NativeButtonElement.class).first().click(); - - verifyClosedAndRemoved(); - } - - @Test - public void openVisualModalDialog_modalityCurtainVisible_logButtonClickable() { - $(NativeButtonElement.class).id("open-visual-modal-dialog").click(); - verifyNumberOfDialogs(1); - - getDialog().$("*").id("overlay").$(DivElement.class).id("backdrop"); - - // Even with the modality curtain, button is programmatically clickable. - $(NativeButtonElement.class).id("log").click(); - - verifyOpened(); - Assert.assertEquals("Click should have resulted in a log message", 1, - $(DivElement.class).id(LOG_ID).$("div").all().size()); - - getDialog().$(NativeButtonElement.class).first().click(); - - verifyClosedAndRemoved(); - } - - @Test - public void openStrictModalDialog_removeBackdrop_logClickNotAccepted() { - $(NativeButtonElement.class).id("open-strict-modal-dialog").click(); - final DivElement backdrop = getDialog().$("*").id("overlay") - .$(DivElement.class).id("backdrop"); - - executeScript("arguments[0].remove()", backdrop); - - Assert.assertFalse("Backdrop was not removed from dom", - getOverlayComponent(getDialog()).$(DivElement.class) - .withAttribute("id", "backdrop").exists()); - - $(NativeButtonElement.class).id("log").click(); - - verifyOpened(); - Assert.assertEquals("Click on button should not generate a log message", - 0, $(DivElement.class).id(LOG_ID).$("div").all().size()); - - getDialog().$(NativeButtonElement.class).id("close").click(); - - verifyClosedAndRemoved(); - - $(NativeButtonElement.class).id("log").click(); - - Assert.assertEquals("Click should have resulted in a log message", 1, - $(DivElement.class).id(LOG_ID).$("div").all().size()); - } - - @Test - public void openStrictModalDialog_outsideClickToCloseDialog_logButtonClickable() { - $(NativeButtonElement.class).id("add-modal-dialog").click(); - $(NativeButtonElement.class).id("enable-close-on-outside-click") - .click(); - $(NativeButtonElement.class).id("open-strict-modal-dialog").click(); - - // Click anything to close dialog - $("body").first().click(); - verifyClosed(); - - // Now that dialog is closed, verify that click events work - $(NativeButtonElement.class).id("log").click(); - Assert.assertEquals("Click should have resulted in a log message", 1, - $(DivElement.class).id(LOG_ID).$("div").all().size()); - } - - @Test - public void openStrictModalDialog_openNonModalOnTop_nonModalCanBeUsed() { - $(NativeButtonElement.class).id("open-strict-modal-dialog").click(); - - final DialogElement dialog = getDialog(); - dialog.$(NativeButtonElement.class).id("open-sub").click(); - - verifyNumberOfDialogs(2); - - final DialogElement subDialog = getDialogs().get(1); - subDialog.$(NativeButtonElement.class).id("log-sub").click(); - - Assert.assertEquals("Click should have resulted in a log message", 1, - $(DivElement.class).id(LOG_ID).$("div").all().size()); - - subDialog.$(NativeButtonElement.class).id("close-sub").click(); - - dialog.$(NativeButtonElement.class).id("close").click(); - - verifyClosedAndRemoved(); - } - - @Test - public void openStrictModalDialog_hideComponent_logClickAccepted() { - $(NativeButtonElement.class).id("open-strict-modal-dialog").click(); - - getDialog().$(NativeButtonElement.class).id("hide").click(); - - verifyOpened(); - Assert.assertFalse("Dialog should be hidden", - getDialog().isDisplayed()); - - $(NativeButtonElement.class).id("log").click(); - - Assert.assertEquals("Click should have resulted in a log message", 1, - $(DivElement.class).id(LOG_ID).$("div").all().size()); - - $(NativeButtonElement.class).id("show-strict-modal").click(); - - getDialog().$(NativeButtonElement.class).id("close").click(); - - verifyClosedAndRemoved(); - } - - @Test - public void openVisualModalDialog_hideComponent_logClickAccepted() { - $(NativeButtonElement.class).id("open-visual-modal-dialog").click(); - - getDialog().$(NativeButtonElement.class).id("hide").click(); - - verifyOpened(); - Assert.assertFalse("Dialog should be hidden", - getDialog().isDisplayed()); - - $(NativeButtonElement.class).id("log").click(); - - Assert.assertEquals("Click should have resulted in a log message", 1, - $(DivElement.class).id(LOG_ID).$("div").all().size()); - - $(NativeButtonElement.class).id("show-visual-modal").click(); - - getDialog().$(NativeButtonElement.class).id("close").click(); - - verifyClosedAndRemoved(); - } -} diff --git a/vaadin-dialog-flow-parent/vaadin-dialog-flow/src/main/java/com/vaadin/flow/component/dialog/Dialog.java b/vaadin-dialog-flow-parent/vaadin-dialog-flow/src/main/java/com/vaadin/flow/component/dialog/Dialog.java index b5b8e57e4d8..1fb2f068ee0 100644 --- a/vaadin-dialog-flow-parent/vaadin-dialog-flow/src/main/java/com/vaadin/flow/component/dialog/Dialog.java +++ b/vaadin-dialog-flow-parent/vaadin-dialog-flow/src/main/java/com/vaadin/flow/component/dialog/Dialog.java @@ -662,7 +662,7 @@ public void setModality(ModalityMode mode) { this.modality = Objects.requireNonNull(mode, "ModalityMode must not be null"); getElement().setProperty("modeless", mode == ModalityMode.MODELESS); - getUI().ifPresent(ui -> ui.setChildComponentModal(this, mode)); + applyModality(); } /** @@ -933,9 +933,7 @@ public Element getElement() { @Override public void setVisible(boolean visible) { super.setVisible(visible); - - getUI().ifPresent(ui -> ui.setChildComponentModal(this, - visible && isModal() ? getModality() : ModalityMode.MODELESS)); + applyModality(); } /** @@ -1007,8 +1005,8 @@ public void setOpened(boolean opened) { } private void doSetOpened(boolean opened, boolean fromClient) { - setModality(opened && isModal()); getElement().setProperty("opened", opened); + applyModality(); fireEvent(new OpenedChangeEvent(this, fromClient)); } @@ -1022,13 +1020,6 @@ public boolean isOpened() { return getElement().getProperty("opened", false); } - private void setModality(boolean modal) { - if (isAttached()) { - getUI().ifPresent(ui -> ui.setChildComponentModal(this, - modal ? getModality() : ModalityMode.MODELESS)); - } - } - /** * Add a listener for when the dialog's opened state changes. *
@@ -1139,6 +1130,7 @@ protected void onAttach(AttachEvent attachEvent) { initHeaderFooterRenderer(); updateVirtualChildNodeIds(); registerClientCloseHandler(); + applyModality(); } /** @@ -1259,4 +1251,12 @@ public Style getStyle() { throw new UnsupportedOperationException( "Dialog does not support adding styles"); } + + private void applyModality() { + getUI().ifPresent(ui -> { + boolean modal = isOpened() && isVisible() + && modality == ModalityMode.STRICT; + ui.setChildComponentModal(this, modal); + }); + } } diff --git a/vaadin-dialog-flow-parent/vaadin-dialog-flow/src/test/java/com/vaadin/flow/component/dialog/DialogModalityTest.java b/vaadin-dialog-flow-parent/vaadin-dialog-flow/src/test/java/com/vaadin/flow/component/dialog/DialogModalityTest.java new file mode 100644 index 00000000000..e3176c6580e --- /dev/null +++ b/vaadin-dialog-flow-parent/vaadin-dialog-flow/src/test/java/com/vaadin/flow/component/dialog/DialogModalityTest.java @@ -0,0 +1,250 @@ +/* + * Copyright 2000-2025 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.flow.component.dialog; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import com.vaadin.flow.component.ModalityMode; +import com.vaadin.flow.component.UI; +import com.vaadin.flow.server.VaadinSession; + +public class DialogModalityTest { + private final UI ui = new UI(); + private final Dialog dialog = new Dialog(); + + @Before + public void setup() { + UI.setCurrent(ui); + + VaadinSession session = Mockito.mock(VaadinSession.class); + Mockito.when(session.hasLock()).thenReturn(true); + ui.getInternals().setSession(session); + } + + @After + public void teardown() { + UI.setCurrent(null); + } + + @Test + public void defaults() { + Assert.assertTrue(dialog.isModal()); + Assert.assertEquals(ModalityMode.VISUAL, dialog.getModality()); + Assert.assertFalse(dialog.getElement().getProperty("modeless", false)); + } + + @Test + public void setModal_isModal() { + dialog.setModal(true); + Assert.assertTrue(dialog.isModal()); + Assert.assertEquals(ModalityMode.STRICT, dialog.getModality()); + Assert.assertFalse(dialog.getElement().getProperty("modeless", false)); + + dialog.setModal(false); + Assert.assertFalse(dialog.isModal()); + Assert.assertEquals(ModalityMode.MODELESS, dialog.getModality()); + Assert.assertTrue(dialog.getElement().getProperty("modeless", false)); + } + + @Test + public void setModality_getModality() { + dialog.setModality(ModalityMode.STRICT); + Assert.assertTrue(dialog.isModal()); + Assert.assertEquals(ModalityMode.STRICT, dialog.getModality()); + Assert.assertFalse(dialog.getElement().getProperty("modeless", false)); + + dialog.setModality(ModalityMode.VISUAL); + Assert.assertTrue(dialog.isModal()); + Assert.assertEquals(ModalityMode.VISUAL, dialog.getModality()); + Assert.assertFalse(dialog.getElement().getProperty("modeless", false)); + + dialog.setModality(ModalityMode.MODELESS); + Assert.assertFalse(dialog.isModal()); + Assert.assertEquals(ModalityMode.MODELESS, dialog.getModality()); + Assert.assertTrue(dialog.getElement().getProperty("modeless", false)); + } + + @Test + public void strictModal() { + // Auto added + dialog.setModality(ModalityMode.STRICT); + dialog.open(); + fakeClientResponse(); + Assert.assertTrue(isServerSideModal()); + + // Manually added + dialog.close(); + fakeClientResponse(); + Assert.assertFalse(isServerSideModal()); + + ui.add(dialog); + dialog.open(); + Assert.assertTrue(isServerSideModal()); + } + + @Test + public void strictModal_onlyModalWhenOpened() { + // Regression test to verify that setting modality or visibility does + // not make the dialog modal before it is opened + dialog.setModality(ModalityMode.MODELESS); + dialog.setVisible(false); + + ui.add(dialog); + + dialog.setModality(ModalityMode.STRICT); + Assert.assertFalse(isServerSideModal()); + + dialog.setVisible(true); + Assert.assertFalse(isServerSideModal()); + + dialog.open(); + Assert.assertTrue(isServerSideModal()); + } + + @Test + public void strictModal_toggleVisibility() { + dialog.setModality(ModalityMode.STRICT); + + ui.add(dialog); + dialog.open(); + Assert.assertTrue(isServerSideModal()); + + dialog.setVisible(false); + Assert.assertFalse(isServerSideModal()); + + dialog.setVisible(true); + Assert.assertTrue(isServerSideModal()); + } + + @Test + public void strictModal_toggleModality() { + ui.add(dialog); + dialog.setModality(ModalityMode.STRICT); + dialog.open(); + Assert.assertTrue(isServerSideModal()); + + dialog.setModality(ModalityMode.MODELESS); + Assert.assertFalse(isServerSideModal()); + + dialog.setModality(ModalityMode.STRICT); + Assert.assertTrue(isServerSideModal()); + } + + @Test + public void strictModal_toggleOpened() { + ui.add(dialog); + dialog.setModality(ModalityMode.STRICT); + dialog.open(); + Assert.assertTrue(isServerSideModal()); + + dialog.close(); + Assert.assertFalse(isServerSideModal()); + + dialog.open(); + Assert.assertTrue(isServerSideModal()); + } + + @Test + public void strictModal_toggleAttached() { + ui.add(dialog); + dialog.setModality(ModalityMode.STRICT); + dialog.open(); + Assert.assertTrue(isServerSideModal()); + + dialog.removeFromParent(); + Assert.assertFalse(isServerSideModal()); + + ui.add(dialog); + Assert.assertTrue(isServerSideModal()); + } + + @Test + public void strictModal_openSecondDialog_addedToFirstDialog() { + dialog.setModality(ModalityMode.STRICT); + ui.add(dialog); + dialog.open(); + + // Auto-added dialog should be added to current modal + Dialog secondDialog = new Dialog(); + secondDialog.open(); + fakeClientResponse(); + + Assert.assertEquals(dialog, secondDialog.getParent().orElse(null)); + } + + @Test + public void visualModal() { + // Auto added + dialog.setModality(ModalityMode.VISUAL); + dialog.open(); + fakeClientResponse(); + Assert.assertFalse(isServerSideModal()); + + // Manually added + dialog.close(); + fakeClientResponse(); + Assert.assertFalse(isServerSideModal()); + + ui.add(dialog); + dialog.open(); + Assert.assertFalse(isServerSideModal()); + } + + @Test + public void visualModal_openSecondDialog_addedToUI() { + dialog.setModality(ModalityMode.VISUAL); + ui.add(dialog); + dialog.open(); + + Dialog secondDialog = new Dialog(); + secondDialog.open(); + fakeClientResponse(); + + Assert.assertEquals(ui, secondDialog.getParent().orElse(null)); + } + + @Test + public void modeless() { + // Auto added + dialog.setModality(ModalityMode.MODELESS); + dialog.open(); + fakeClientResponse(); + Assert.assertFalse(isServerSideModal()); + + // Manually added + dialog.close(); + fakeClientResponse(); + Assert.assertFalse(isServerSideModal()); + + ui.add(dialog); + dialog.open(); + Assert.assertFalse(isServerSideModal()); + } + + private boolean isServerSideModal() { + return dialog == ui.getInternals().getActiveModalComponent(); + } + + private void fakeClientResponse() { + ui.getInternals().getStateTree().runExecutionsBeforeClientResponse(); + ui.getInternals().getStateTree().collectChanges(ignore -> { + }); + } +} diff --git a/vaadin-dialog-flow-parent/vaadin-dialog-flow/src/test/java/com/vaadin/flow/component/dialog/DialogTest.java b/vaadin-dialog-flow-parent/vaadin-dialog-flow/src/test/java/com/vaadin/flow/component/dialog/DialogTest.java index 6a25e53e6be..6786cd0e7f8 100644 --- a/vaadin-dialog-flow-parent/vaadin-dialog-flow/src/test/java/com/vaadin/flow/component/dialog/DialogTest.java +++ b/vaadin-dialog-flow-parent/vaadin-dialog-flow/src/test/java/com/vaadin/flow/component/dialog/DialogTest.java @@ -29,7 +29,6 @@ import com.vaadin.flow.component.ComponentEventListener; import com.vaadin.flow.component.ComponentUtil; import com.vaadin.flow.component.HasStyle; -import com.vaadin.flow.component.ModalityMode; import com.vaadin.flow.component.UI; import com.vaadin.flow.component.html.Div; import com.vaadin.flow.component.html.Span; @@ -179,51 +178,6 @@ public void setResizable_dialogCanBeResizable() { dialog.getElement().getProperty("resizable", false)); } - @Test - public void isModal_trueByDefault() { - Dialog dialog = new Dialog(); - - // Element's api "modeless" acts inverted to Flow's api "modal": - // modeless is false and modal is true by default - Assert.assertTrue("modal is true by default", - !dialog.getElement().getProperty("modeless", false)); - } - - @Test - public void setModal_dialogCanBeModeless() { - Dialog dialog = new Dialog(); - dialog.setModal(false); - - // Element's api "modeless" acts inverted to Flow's api "modal": - // modeless is false and modal is true by default - Assert.assertFalse("modal can be set to false", - !dialog.getElement().getProperty("modeless", false)); - } - - @Test - public void getModality_visualByDefault() { - Dialog dialog = new Dialog(); - - Assert.assertEquals(ModalityMode.VISUAL, dialog.getModality()); - } - - @Test - public void setModality() { - Dialog dialog = new Dialog(); - - dialog.setModality(ModalityMode.STRICT); - Assert.assertEquals(ModalityMode.STRICT, dialog.getModality()); - Assert.assertFalse(dialog.getElement().getProperty("modeless", false)); - - dialog.setModality(ModalityMode.VISUAL); - Assert.assertEquals(ModalityMode.VISUAL, dialog.getModality()); - Assert.assertFalse(dialog.getElement().getProperty("modeless", false)); - - dialog.setModality(ModalityMode.MODELESS); - Assert.assertEquals(ModalityMode.MODELESS, dialog.getModality()); - Assert.assertTrue(dialog.getElement().getProperty("modeless", false)); - } - @Test public void getRole_defaultDialog() { Dialog dialog = new Dialog();