3 import static org.testng.Assert.assertFalse;
4 import static org.testng.Assert.assertTrue;
6 import java.awt.Button;
8 import java.awt.event.MouseEvent;
10 import org.testng.annotations.Test;
12 public class PlatformTest
14 Button b = new Button();
17 * isControlDown for Mac should answer true for Meta-down, but not for right
18 * mouse (popup trigger)
20 @Test(groups = "Functional")
21 public void testIsControlDown_mac()
24 boolean isPopupTrigger = false;
25 int buttonNo = MouseEvent.BUTTON1;
29 // not concerned with MouseEvent id, when, x, y, xAbs, yAbs values
30 assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
31 0, 0, clickCount, isPopupTrigger, buttonNo), mac));
33 mods = Event.CTRL_MASK;
34 assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
35 0, 0, clickCount, isPopupTrigger, buttonNo), mac));
37 mods = Event.META_MASK;
38 assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
39 0, 0, clickCount, isPopupTrigger, buttonNo), mac));
41 isPopupTrigger = true;
42 assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
43 0, 0, clickCount, isPopupTrigger, buttonNo), mac));
45 isPopupTrigger = false;
46 buttonNo = MouseEvent.BUTTON2;
48 assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
49 0, 0, clickCount, isPopupTrigger, buttonNo), mac));
53 * If not a Mac, we only care whether CTRL_MASK modifier is set on the mouse
56 @Test(groups = "Functional")
57 public void testIsControlDown_notMac()
60 boolean isPopupTrigger = false;
61 int buttonNo = MouseEvent.BUTTON1;
65 // not concerned with MouseEvent id, when, x, y, xAbs, yAbs values
66 assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
67 0, 0, clickCount, isPopupTrigger, buttonNo), mac));
69 mods = Event.CTRL_MASK;
70 assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
71 0, 0, clickCount, isPopupTrigger, buttonNo), mac));
73 mods = Event.CTRL_MASK | Event.SHIFT_MASK | Event.ALT_MASK;
76 isPopupTrigger = true;
77 assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
78 0, 0, clickCount, isPopupTrigger, buttonNo), mac));