Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAparna Argade2019-06-01 10:00:05 -0400
committerAparna Argade2019-06-01 11:08:36 -0400
commit464aefb3e17cd20e06ef52158b359d9550aafb09 (patch)
tree1fb55cbd4baed3cef5dc9de2eb8f1969cbffb6ba
parente36ff52c3ce02f5e46489a543bb1d5de5d363035 (diff)
downloadorg.eclipse.swtbot-464aefb3e17cd20e06ef52158b359d9550aafb09.tar.gz
org.eclipse.swtbot-464aefb3e17cd20e06ef52158b359d9550aafb09.tar.xz
org.eclipse.swtbot-464aefb3e17cd20e06ef52158b359d9550aafb09.zip
Fix tests for MacOS- SWTBotListTest, TableTest and TreeTest
Get expected statemask using SWT.MOD1 instead of SWT.CTRL for multiple selection and unselection tests. Change-Id: I8f0d24d2b7743a017f0eb775aabcd44af8861538 Signed-off-by: Aparna Argade <aprsac@yahoo.com>
-rw-r--r--org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotListTest.java13
-rw-r--r--org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTableTest.java29
-rw-r--r--org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeTest.java23
3 files changed, 39 insertions, 26 deletions
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotListTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotListTest.java
index 45fb7f7a..f8459a1a 100644
--- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotListTest.java
+++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotListTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2018 Ketan Padegaonkar and others.
+ * Copyright (c) 2008, 2019 Ketan Padegaonkar and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,6 +17,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.List;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.SWTBotAssert;
@@ -172,8 +173,10 @@ public class SWTBotListTest extends AbstractControlExampleTest {
{
SWTBotText text = bot.textInGroup("Listeners");
String[] events = SWTUtils.getText(text.widget).split("\n");
- String stateMask1 = (select) ? "0x0" : "0x40000";
- String stateMask2 = (select) ? "0x80000" : "0xc0000";
+ String stateMaskMulti1 = "0x" + Integer.toHexString(SWT.NONE | SWT.MOD1);
+ String stateMaskMulti2 = "0x" + Integer.toHexString(SWT.BUTTON1 | SWT.MOD1);
+ String stateMask1 = "0x" + Integer.toHexString(select ? SWT.NONE : SWT.NONE | SWT.MOD1);
+ String stateMask2 = "0x" + Integer.toHexString(select ? SWT.BUTTON1 : SWT.BUTTON1 | SWT.MOD1);
int i = 0;
i = events[i].startsWith("Paint") ? (i + 1) : i;
SWTBotAssert.assertContains("MouseEnter [6]: MouseEvent{List {} ", events[i++]);
@@ -186,8 +189,8 @@ public class SWTBotListTest extends AbstractControlExampleTest {
SWTBotAssert.assertContains("MouseUp [4]: MouseEvent{List {} ", events[i]);
SWTBotAssert.assertContains("stateMask=" + stateMask2, events[i++]);
if (select) { //statemasks are changed only for select for further items
- stateMask1 ="0x40000";
- stateMask2 = "0xc0000";
+ stateMask1 = stateMaskMulti1;
+ stateMask2 = stateMaskMulti2;
}
i = events[i].startsWith("Paint") ? (i + 1) : i;
SWTBotAssert.assertContains("MouseDown [3]: MouseEvent{List {} ", events[i]);
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTableTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTableTest.java
index ec9a90a2..03c2d77e 100644
--- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTableTest.java
+++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTableTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2017 Ketan Padegaonkar and others.
+ * Copyright (c) 2008, 2019 Ketan Padegaonkar and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -18,6 +18,7 @@ import static org.junit.Assert.fail;
import java.util.ArrayList;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swtbot.swt.finder.test.AbstractControlExampleTest;
import org.eclipse.swtbot.swt.finder.utils.TableCollection;
@@ -128,13 +129,15 @@ public class SWTBotTableTest extends AbstractControlExampleTest {
table.unselect();
assertEquals(0, table.selectionCount());
- //event.item should contain the item getting unselected, stateMask should reflect CTRL key
- assertEventMatches(text, "MouseDown [3]: MouseEvent{Table {} time=0 data=null button=1 stateMask=0x40000 x=0 y=0 count=1}");
- assertEventMatches(text, "Selection [13]: SelectionEvent{Table {} time=0 data=null item=TableItem {Index:1} detail=0 x=0 y=0 width=0 height=0 stateMask=0xc0000 text=null doit=true}");
- assertEventMatches(text, "MouseUp [4]: MouseEvent{Table {} time=0 data=null button=1 stateMask=0xc0000 x=0 y=0 count=1}");
-
- assertEventMatches(text, "Selection [13]: SelectionEvent{Table {} time=0 data=null item=TableItem {Index:2} detail=0 x=0 y=0 width=0 height=0 stateMask=0xc0000 text=null doit=true}");
- assertEventMatches(text, "Selection [13]: SelectionEvent{Table {} time=0 data=null item=TableItem {Index:3} detail=0 x=0 y=0 width=0 height=0 stateMask=0xc0000 text=null doit=true}");
+ //event.item should contain the item getting unselected, stateMask should reflect CTRL/COMMAND key
+ String stateMaskMulti1 = "0x" + Integer.toHexString(SWT.NONE | SWT.MOD1);
+ String stateMaskMulti2 = "0x" + Integer.toHexString(SWT.BUTTON1 | SWT.MOD1);
+ assertEventMatches(text, "MouseDown [3]: MouseEvent{Table {} time=0 data=null button=1 stateMask=" + stateMaskMulti1 + " x=0 y=0 count=1}");
+ assertEventMatches(text, "Selection [13]: SelectionEvent{Table {} time=0 data=null item=TableItem {Index:1} detail=0 x=0 y=0 width=0 height=0 stateMask=" + stateMaskMulti2 + " text=null doit=true}");
+ assertEventMatches(text, "MouseUp [4]: MouseEvent{Table {} time=0 data=null button=1 stateMask=" + stateMaskMulti2 + " x=0 y=0 count=1}");
+
+ assertEventMatches(text, "Selection [13]: SelectionEvent{Table {} time=0 data=null item=TableItem {Index:2} detail=0 x=0 y=0 width=0 height=0 stateMask=" + stateMaskMulti2 + " text=null doit=true}");
+ assertEventMatches(text, "Selection [13]: SelectionEvent{Table {} time=0 data=null item=TableItem {Index:3} detail=0 x=0 y=0 width=0 height=0 stateMask=" + stateMaskMulti2 + " text=null doit=true}");
}
@Test
@@ -192,10 +195,12 @@ public class SWTBotTableTest extends AbstractControlExampleTest {
assertEventMatches(text, "MouseUp [4]: MouseEvent{Table {} time=0 data=null button=1 stateMask=0x80000 x=0 y=0 count=1}");
// subsequent selection: event.item should contain the second selected item,
- //stateMask should reflect CTRL key
- assertEventMatches(text, "MouseDown [3]: MouseEvent{Table {} time=0 data=null button=1 stateMask=0x40000 x=0 y=0 count=1}");
- assertEventMatches(text, "Selection [13]: SelectionEvent{Table {} time=0 data=null item=TableItem {Index:10} detail=0 x=0 y=0 width=0 height=0 stateMask=0xc0000 text=null doit=true}");
- assertEventMatches(text, "MouseUp [4]: MouseEvent{Table {} time=0 data=null button=1 stateMask=0xc0000 x=0 y=0 count=1}");
+ //stateMask should reflect CTRL/COMMAND key
+ String stateMaskMulti1 = "0x" + Integer.toHexString(SWT.NONE | SWT.MOD1);
+ String stateMaskMulti2 = "0x" + Integer.toHexString(SWT.BUTTON1 | SWT.MOD1);
+ assertEventMatches(text, "MouseDown [3]: MouseEvent{Table {} time=0 data=null button=1 stateMask=" + stateMaskMulti1 + " x=0 y=0 count=1}");
+ assertEventMatches(text, "Selection [13]: SelectionEvent{Table {} time=0 data=null item=TableItem {Index:10} detail=0 x=0 y=0 width=0 height=0 stateMask=" + stateMaskMulti2 + " text=null doit=true}");
+ assertEventMatches(text, "MouseUp [4]: MouseEvent{Table {} time=0 data=null button=1 stateMask=" + stateMaskMulti2 + " x=0 y=0 count=1}");
}
@Test
diff --git a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeTest.java b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeTest.java
index fb1870e5..954b4f00 100644
--- a/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeTest.java
+++ b/org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/widgets/SWTBotTreeTest.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.fail;
import java.util.ArrayList;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.Widget;
@@ -144,10 +145,12 @@ public class SWTBotTreeTest extends AbstractControlExampleTest {
bot.button("Clear").click();
tree.unselect();
assertEquals(0, tree.selectionCount());
- //event.item should contain the item getting unselected, stateMask should reflect CTRL key
- assertEventMatches(text, "MouseDown [3]: MouseEvent{Tree {} time=0 data=null button=1 stateMask=0x40000 x=0 y=0 count=1}");
- assertEventMatches(text, "Selection [13]: SelectionEvent{Tree {} time=0 data=null item=TreeItem {Node 2} detail=0 x=0 y=0 width=0 height=0 stateMask=0xc0000 text=null doit=true}");
- assertEventMatches(text, "MouseUp [4]: MouseEvent{Tree {} time=0 data=null button=1 stateMask=0xc0000 x=0 y=0 count=1}");
+ //event.item should contain the item getting unselected, stateMask should reflect CTRL/COMMAND key
+ String stateMaskMulti1 = "0x" + Integer.toHexString(SWT.NONE | SWT.MOD1);
+ String stateMaskMulti2 = "0x" + Integer.toHexString(SWT.BUTTON1 | SWT.MOD1);
+ assertEventMatches(text, "MouseDown [3]: MouseEvent{Tree {} time=0 data=null button=1 stateMask=" + stateMaskMulti1 + " x=0 y=0 count=1}");
+ assertEventMatches(text, "Selection [13]: SelectionEvent{Tree {} time=0 data=null item=TreeItem {Node 2} detail=0 x=0 y=0 width=0 height=0 stateMask=" + stateMaskMulti2 + " text=null doit=true}");
+ assertEventMatches(text, "MouseUp [4]: MouseEvent{Tree {} time=0 data=null button=1 stateMask=" + stateMaskMulti2 + " x=0 y=0 count=1}");
}
@Test
@@ -217,16 +220,18 @@ public class SWTBotTreeTest extends AbstractControlExampleTest {
SWTBotText text = bot.textInGroup("Listeners");
// first selection: event.item should contain the first selected item,
- // stateMask should not reflect CTRL key
+ // stateMask should not reflect CTRL/COMMAND key
assertEventMatches(text, "MouseDown [3]: MouseEvent{Tree {} time=0 data=null button=1 stateMask=0x0 x=0 y=0 count=1}");
assertEventMatches(text, "Selection [13]: SelectionEvent{Tree {} time=0 data=null item=TreeItem {Node 2} detail=0 x=0 y=0 width=0 height=0 stateMask=0x80000 text=null doit=true}");
assertEventMatches(text, "MouseUp [4]: MouseEvent{Tree {} time=0 data=null button=1 stateMask=0x80000 x=0 y=0 count=1}");
// subsequent selection: event.item should contain the second selected item,
- // stateMask should reflect CTRL key
- assertEventMatches(text, "MouseDown [3]: MouseEvent{Tree {} time=0 data=null button=1 stateMask=0x40000 x=0 y=0 count=1}");
- assertEventMatches(text, "Selection [13]: SelectionEvent{Tree {} time=0 data=null item=TreeItem {Node 3} detail=0 x=0 y=0 width=0 height=0 stateMask=0xc0000 text=null doit=true}");
- assertEventMatches(text, "MouseUp [4]: MouseEvent{Tree {} time=0 data=null button=1 stateMask=0xc0000 x=0 y=0 count=1}");
+ // stateMask should reflect CTRL/COMMAND key
+ String stateMaskMulti1 = "0x" + Integer.toHexString(SWT.NONE | SWT.MOD1);
+ String stateMaskMulti2 = "0x" + Integer.toHexString(SWT.BUTTON1 | SWT.MOD1);
+ assertEventMatches(text, "MouseDown [3]: MouseEvent{Tree {} time=0 data=null button=1 stateMask=" + stateMaskMulti1 + " x=0 y=0 count=1}");
+ assertEventMatches(text, "Selection [13]: SelectionEvent{Tree {} time=0 data=null item=TreeItem {Node 3} detail=0 x=0 y=0 width=0 height=0 stateMask=" + stateMaskMulti2 + " text=null doit=true}");
+ assertEventMatches(text, "MouseUp [4]: MouseEvent{Tree {} time=0 data=null button=1 stateMask=" + stateMaskMulti2 + " x=0 y=0 count=1}");
}
@Test

Back to the top