Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEric Williams2019-03-14 15:19:48 +0000
committerEric Williams2019-03-14 15:32:45 +0000
commitecc666275b3b7b87d3be7da23a89327dd32efdc4 (patch)
treec827d81c25c703e2d8a3866d1728bc4a25a194b7 /tests
parentc0b245e799efea834a2f7ff826a012a9e707c15d (diff)
downloadeclipse.platform.swt-ecc666275b3b7b87d3be7da23a89327dd32efdc4.tar.gz
eclipse.platform.swt-ecc666275b3b7b87d3be7da23a89327dd32efdc4.tar.xz
eclipse.platform.swt-ecc666275b3b7b87d3be7da23a89327dd32efdc4.zip
Bug 545406: [GTK3] Text: order of setBackground/setForeground matters
GTK-CSS parsing doesn't handle selection foreground colors well, instead use manual foreground GdkRGBA tracking just like for background colors. Change-Id: Ib9a02df6c6845b35f95d2e57093e9b371e134846 Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug545406_TextForegroundNotApplied.java45
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Text.java19
2 files changed, 64 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug545406_TextForegroundNotApplied.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug545406_TextForegroundNotApplied.java
new file mode 100644
index 0000000000..4332541bae
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug545406_TextForegroundNotApplied.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Red Hat 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:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class Bug545406_TextForegroundNotApplied {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+
+ final Shell shell = new Shell(display);
+ shell.setLayout(new FillLayout());
+
+ final Text text = new Text(shell, SWT.BORDER | SWT.MULTI);
+ text.setBackground(display.getSystemColor(SWT.COLOR_DARK_GRAY));
+ text.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
+
+ shell.setSize(300, 150);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Text.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Text.java
index cf8c36329f..d99dc98d53 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Text.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Text.java
@@ -24,6 +24,7 @@ import org.eclipse.swt.events.SegmentListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Point;
@@ -1155,6 +1156,24 @@ public void test_setFontLorg_eclipse_swt_graphics_Font() {
}
@Test
+public void test_setForegroundAfterBackground() {
+ makeCleanEnvironment(false);
+ Color gray = text.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
+ Color white = text.getDisplay().getSystemColor(SWT.COLOR_WHITE);
+ Color defaultForeground = text.getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND);
+
+ text.setBackground(gray);
+ assertEquals(text.getForeground(), defaultForeground);
+ text.setForeground(white);
+ assertEquals(text.getForeground(), white);
+ assertEquals(text.getBackground(), gray);
+
+ gray.dispose();
+ white.dispose();
+ defaultForeground.dispose();
+}
+
+@Test
public void test_setOrientationI() {
text.setOrientation(SWT.RIGHT_TO_LEFT);
if ((text.getStyle() & SWT.MIRRORED) != 0) {

Back to the top