Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.util

File PlatformTest.java

 
testIsControlDown_mac: expected [false] but found [true]
 

Code metrics

0
31
3
1
111
64
3
0.1
10.33
3
1

Classes

Class Line # Actions
PlatformTest 35 31 3 17
0.550%
 

Contributing tests

This file is covered by 2 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.util;
22   
23    import static org.testng.Assert.assertFalse;
24    import static org.testng.Assert.assertTrue;
25   
26    import jalview.gui.JvOptionPane;
27   
28    import java.awt.Button;
29    import java.awt.Event;
30    import java.awt.event.MouseEvent;
31   
32    import org.testng.annotations.BeforeClass;
33    import org.testng.annotations.Test;
34   
 
35    public class PlatformTest
36    {
37   
 
38  1 toggle @BeforeClass(alwaysRun = true)
39    public void setUpJvOptionPane()
40    {
41  1 JvOptionPane.setInteractiveMode(false);
42  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
43    }
44   
45    Button b = new Button();
46   
47    /**
48    * isControlDown for Mac should answer true for Meta-down, but not for right
49    * mouse (popup trigger)
50    */
 
51  0 toggle @Test(groups = "Functional")
52    public void testIsControlDown_mac()
53    {
54  0 int clickCount = 1;
55  0 boolean isPopupTrigger = false;
56  0 int buttonNo = MouseEvent.BUTTON1;
57  0 boolean mac = true;
58   
59  0 int mods = 0;
60    // not concerned with MouseEvent id, when, x, y, xAbs, yAbs values
61  0 assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
62    0, 0, clickCount, isPopupTrigger, buttonNo), mac));
63   
64  0 mods = Event.CTRL_MASK;
65  0 Test failure here assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
66    0, 0, clickCount, isPopupTrigger, buttonNo), mac));
67   
68  0 mods = Event.META_MASK;
69  0 assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
70    0, 0, clickCount, isPopupTrigger, buttonNo), mac));
71   
72  0 isPopupTrigger = true;
73  0 assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
74    0, 0, clickCount, isPopupTrigger, buttonNo), mac));
75   
76  0 isPopupTrigger = false;
77  0 buttonNo = MouseEvent.BUTTON2;
78  0 mods = 0;
79  0 assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
80    0, 0, clickCount, isPopupTrigger, buttonNo), mac));
81    }
82   
83    /**
84    * If not a Mac, we only care whether CTRL_MASK modifier is set on the mouse
85    * event
86    */
 
87  1 toggle @Test(groups = "Functional")
88    public void testIsControlDown_notMac()
89    {
90  1 int clickCount = 1;
91  1 boolean isPopupTrigger = false;
92  1 int buttonNo = MouseEvent.BUTTON1;
93  1 boolean mac = false;
94   
95  1 int mods = 0;
96    // not concerned with MouseEvent id, when, x, y, xAbs, yAbs values
97  1 assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
98    0, 0, clickCount, isPopupTrigger, buttonNo), mac));
99   
100  1 mods = Event.CTRL_MASK;
101  1 assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
102    0, 0, clickCount, isPopupTrigger, buttonNo), mac));
103   
104  1 mods = Event.CTRL_MASK | Event.SHIFT_MASK | Event.ALT_MASK;
105  1 clickCount = 2;
106  1 buttonNo = 2;
107  1 isPopupTrigger = true;
108  1 assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0,
109    0, 0, clickCount, isPopupTrigger, buttonNo), mac));
110    }
111    }