Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2020-01-24 04:45:29 -0500
committerPaul Pazderski2020-01-24 04:51:56 -0500
commit80d6d8185c50e595d04777fee496592b79fe457b (patch)
tree5c8a9e33fb5c1e7c3db46a87edfda7e90e1f2a19 /tests/org.eclipse.swt.tests.win32
parent7acd691f9ffed2a27738618d89ec42d31ab16eb2 (diff)
downloadeclipse.platform.swt-80d6d8185c50e595d04777fee496592b79fe457b.tar.gz
eclipse.platform.swt-80d6d8185c50e595d04777fee496592b79fe457b.tar.xz
eclipse.platform.swt-80d6d8185c50e595d04777fee496592b79fe457b.zip
Bug 512629 - Move unstable fullscreen test to manual tests
Change-Id: I24cc721bcbe0813c23cdce874b7188ecc0ced0ca Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
Diffstat (limited to 'tests/org.eclipse.swt.tests.win32')
-rw-r--r--tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug512629_test_fullscreen_before_open.java154
1 files changed, 154 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug512629_test_fullscreen_before_open.java b/tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug512629_test_fullscreen_before_open.java
new file mode 100644
index 0000000000..2a2a4f1b6b
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/tests/win32/snippets/Bug512629_test_fullscreen_before_open.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Paul Pazderski and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Paul Pazderski - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.win32.snippets;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.function.Function;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Shell;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Manual test to check a bunch of uncommon combinations of shell open/hide and
+ * setFullscreen.
+ * Unfortunately not stable enough for an automated test and not working on Linux.
+ */
+public class Bug512629_test_fullscreen_before_open {
+
+ Shell shell;
+ Shell testShell;
+
+ @Before
+ public void setUp() {
+ shell = new Shell();
+ }
+
+ @After
+ public void tearDown() {
+ shell.getDisplay().dispose();
+ }
+
+ private void createShell(int shellStyle) {
+ if (testShell != null) {
+ testShell.dispose();
+ }
+ testShell = new Shell(shell, shellStyle);
+ testShell.setSize(100,300);
+ testShell.setText("Shell");
+ testShell.setLayout(new FillLayout());
+ }
+
+ @Test
+ public void test_setFullscreen() {
+ Function<Shell, Boolean> looksLikeNormalWindow = s -> {
+ Rectangle monitorRect = s.getMonitor().getClientArea();
+ Rectangle shellSize = s.getClientArea();
+ return shellSize.width < monitorRect.width * 0.8 && shellSize.height < monitorRect.height * 0.8;
+ };
+ Function<Shell, Boolean> looksLikeMaximizedWindow = s -> {
+ Rectangle monitorRect = s.getMonitor().getClientArea();
+ Rectangle shellSize = s.getClientArea();
+ return shellSize.width > monitorRect.width * 0.8 && shellSize.height > monitorRect.height * 0.8
+ && shellSize.width <= monitorRect.width && shellSize.height <= monitorRect.height;
+ };
+ Function<Shell, Boolean> looksLikeFullscreen = s -> {
+ Rectangle monitorRect = s.getMonitor().getClientArea();
+ Rectangle shellSize = s.getClientArea();
+ return shellSize.width >= monitorRect.width && shellSize.height >= monitorRect.height;
+ };
+
+ Function<Shell, Boolean> hasTrimming = s -> {
+ Rectangle clientArea = s.getClientArea();
+ Point size = s.getSize();
+ return s.isVisible() && size.y - clientArea.height > 10;
+ };
+
+ Runnable setFullscreenBeforeOpen = () -> {
+ testShell.setFullScreen(true);
+ testShell.open();
+ };
+ Runnable setFullscreenAfterOpen = () -> {
+ testShell.open();
+ testShell.setFullScreen(true);
+ };
+ Runnable openHideSetFullscreenOpen = () -> {
+ testShell.open();
+ testShell.setVisible(false);
+ testShell.setFullScreen(true);
+ testShell.setVisible(true);
+ };
+ Runnable oscillateFullscreenBeforeOpen = () -> {
+ testShell.setFullScreen(true);
+ testShell.setFullScreen(false);
+ testShell.setFullScreen(true);
+ testShell.open();
+ };
+ Runnable toggleFullscreenWhileHidden = () -> {
+ testShell.open();
+ testShell.setFullScreen(true);
+ testShell.setVisible(false);
+ testShell.setFullScreen(false);
+ testShell.setVisible(true);
+ testShell.setFullScreen(true);
+ };
+
+ for (Runnable setFullscreenAndOpen : new Runnable[] { setFullscreenBeforeOpen, setFullscreenAfterOpen,
+ openHideSetFullscreenOpen, oscillateFullscreenBeforeOpen, toggleFullscreenWhileHidden }) {
+ for (int shellStyle : new int[] { SWT.SHELL_TRIM, SWT.DIALOG_TRIM, SWT.NO_TRIM, SWT.BORDER }) {
+ createShell(shellStyle);
+ setFullscreenAndOpen.run();
+ assertTrue("Not fullscreen.", looksLikeFullscreen.apply(testShell));
+ assertFalse("Not fullscreen.", hasTrimming.apply(testShell));
+ assertTrue(testShell.getFullScreen());
+ assertFalse(testShell.getMaximized());
+ testShell.setFullScreen(false);
+ assertTrue("Window not restored.", looksLikeNormalWindow.apply(testShell));
+ assertTrue(hasTrimming.apply(testShell) == ((shellStyle & SWT.TITLE) != 0));
+ assertFalse(testShell.getFullScreen());
+ assertFalse(testShell.getMaximized());
+
+ createShell(shellStyle);
+ testShell.setMaximized(true);
+ assertTrue(testShell.getMaximized());
+ setFullscreenAndOpen.run();
+ assertTrue("Not fullscreen.", looksLikeFullscreen.apply(testShell));
+ assertFalse("Not fullscreen.", hasTrimming.apply(testShell));
+ assertTrue(testShell.getFullScreen());
+ assertFalse(testShell.getMaximized());
+ testShell.setFullScreen(false);
+ assertTrue("Not maximized.", looksLikeMaximizedWindow.apply(testShell));
+ assertTrue(hasTrimming.apply(testShell) == ((shellStyle & SWT.TITLE) != 0));
+ assertFalse(testShell.getFullScreen());
+ assertTrue(testShell.getMaximized());
+ }
+ }
+
+ createShell(SWT.SHELL_TRIM);
+ testShell.setFullScreen(false);
+ testShell.open();
+ assertTrue("Window not restored.", looksLikeNormalWindow.apply(testShell));
+ assertTrue("Lost trimming.", hasTrimming.apply(testShell));
+ assertFalse(testShell.getFullScreen());
+ assertFalse(testShell.getMaximized());
+ }
+}
+

Back to the top