Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRolf Theunissen2019-03-27 19:56:16 +0000
committerLars Vogel2019-04-02 07:36:51 +0000
commita352fe3d2cc4c9803306f45213aea789cf998600 (patch)
tree6228d4d6ba1dcd74fbb707ff4a9c7c3b4027aa80 /tests
parent7f8c58240779633cf9da3c223f3c63c8b98da68c (diff)
downloadeclipse.platform.swt-a352fe3d2cc4c9803306f45213aea789cf998600.tar.gz
eclipse.platform.swt-a352fe3d2cc4c9803306f45213aea789cf998600.tar.xz
eclipse.platform.swt-a352fe3d2cc4c9803306f45213aea789cf998600.zip
Bug 297510 - [Widgets] Calling Composite#setFocus() before shell is
opened sets focus to nowhere Instead of calling forceFocus, call setFocus on when the focus is restored, GTK already uses this behavior. This will propagate the focus to a child of a Container, when a shell becomes visible and active. Change-Id: I1dccdf08820342d6d6253d50ac76e5c41ff0d76b Signed-off-by: Rolf Theunissen <rolf.theunissen@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CCombo.java16
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_TableTree.java21
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Composite.java19
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java3
4 files changed, 51 insertions, 8 deletions
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CCombo.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CCombo.java
index 6f74ff0994..3430946c55 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CCombo.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CCombo.java
@@ -116,12 +116,6 @@ public void test_computeSizeIIZ() {
public void test_getChildren() {
}
-@Override
-@Test
-public void test_isFocusControl() {
- assertTrue(!ccombo.isFocusControl());
-}
-
@Test
public void test_paste() {
if (SwtTestUtil.isCocoa) {
@@ -213,6 +207,16 @@ public void test_setFocus() {
@Override
@Test
+public void test_setFocus_toChild_afterOpen() {
+}
+
+@Override
+@Test
+public void test_setFocus_toChild_beforeOpen() {
+}
+
+@Override
+@Test
public void test_setFontLorg_eclipse_swt_graphics_Font() {
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_TableTree.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_TableTree.java
index 492adae203..1801b195ea 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_TableTree.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_TableTree.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -16,6 +16,7 @@ package org.eclipse.swt.tests.junit;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
@@ -107,6 +108,24 @@ public void test_selectAll() {
selectAll_helper("selectAll()", new TableTreeItem[] {});
}
+@Override
+@Test
+public void test_setFocus_toChild_afterOpen() {
+ shell.open();
+ composite.setFocus();
+ shell.forceActive();
+ assertTrue("First child widget should have focus", tableTree.getTable().isFocusControl());
+}
+
+@Override
+@Test
+public void test_setFocus_toChild_beforeOpen() {
+ composite.setFocus();
+ shell.open();
+ shell.forceActive();
+ assertTrue("First child widget should have focus", tableTree.getTable().isFocusControl());
+}
+
@Test
public void test_setSelection$Lorg_eclipse_swt_custom_TableTreeItem() {
/* FUTURE: Should also add sub-nodes, and test both single and multi with those.
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Composite.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Composite.java
index 0d1b6bc884..cba3712644 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Composite.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Composite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -115,6 +115,23 @@ public void test_setVisibility_and_sizing() {
compSize.x > 100 && compSize.y > 100); // If this is 1x1 or 0x0 then there was some fault in layout.
}
+@Test
+public void test_setFocus_toChild_afterOpen() {
+ Button focusChild = new Button(composite, SWT.PUSH);
+ shell.open();
+ shell.forceActive();
+ composite.setFocus();
+ assertTrue("First child widget should have focus", focusChild.isFocusControl());
+}
+
+@Test
+public void test_setFocus_toChild_beforeOpen() {
+ Button focusChild = new Button(composite, SWT.PUSH);
+ composite.setFocus();
+ shell.open();
+ shell.forceActive();
+ assertTrue("First child widget should have focus", focusChild.isFocusControl());
+}
@Test
public void test_setTabList$Lorg_eclipse_swt_widgets_Control() {
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java
index 6ec23321b3..17312a4ba6 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java
@@ -522,6 +522,9 @@ public void test_isEnabled() {
@Test
public void test_isFocusControl() {
assertFalse(control.isFocusControl());
+ shell.open();
+ shell.forceActive();
+ assertEquals("Unexpected focus", control.forceFocus(), control.isFocusControl());
}
@Test
public void test_isReparentable() {

Back to the top