2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import static org.testng.Assert.assertFalse;
24 import static org.testng.Assert.assertTrue;
26 import jalview.gui.JvOptionPane;
28 import java.awt.Button;
29 import java.awt.Event;
30 import java.awt.event.MouseEvent;
32 import org.testng.annotations.BeforeClass;
33 import org.testng.annotations.Test;
35 public class PlatformTest
38 @BeforeClass(alwaysRun = true)
39 public void setUpJvOptionPane()
41 JvOptionPane.setInteractiveMode(false);
42 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
45 Button b = new Button();
48 * isControlDown for Mac should answer true for Meta-down, but not for right
49 * mouse (popup trigger)
51 @Test(groups = "Functional")
52 public void testIsControlDown_mac()
55 boolean isPopupTrigger = false;
56 int buttonNo = MouseEvent.BUTTON1;
60 // not concerned with MouseEvent id, when, x, y, xAbs, yAbs values
61 assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
62 0, 0, clickCount, isPopupTrigger, buttonNo), mac));
64 mods = Event.CTRL_MASK;
65 assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
66 0, 0, clickCount, isPopupTrigger, buttonNo), mac));
68 mods = Event.META_MASK;
69 assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
70 0, 0, clickCount, isPopupTrigger, buttonNo), mac));
72 isPopupTrigger = true;
73 assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
74 0, 0, clickCount, isPopupTrigger, buttonNo), mac));
76 isPopupTrigger = false;
77 buttonNo = MouseEvent.BUTTON2;
79 assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
80 0, 0, clickCount, isPopupTrigger, buttonNo), mac));
84 * If not a Mac, we only care whether CTRL_MASK modifier is set on the mouse
87 @Test(groups = "Functional")
88 public void testIsControlDown_notMac()
91 boolean isPopupTrigger = false;
92 int buttonNo = MouseEvent.BUTTON1;
96 // not concerned with MouseEvent id, when, x, y, xAbs, yAbs values
97 assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
98 0, 0, clickCount, isPopupTrigger, buttonNo), mac));
100 mods = Event.CTRL_MASK;
101 assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
102 0, 0, clickCount, isPopupTrigger, buttonNo), mac));
104 mods = Event.CTRL_MASK | Event.SHIFT_MASK | Event.ALT_MASK;
107 isPopupTrigger = true;
108 assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
109 0, 0, clickCount, isPopupTrigger, buttonNo), mac));