1 /*
2  * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.
8  *
9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 
24 /*
25   @test %I% %E%
26   @key headful
27   @bug 6315717
28   @summary verifies that system property sun.awt.enableExtraMouseButtons might be set to false by the System class API.
29   @author Andrei Dmitriev : area=awt.mouse
30   @run main SystemPropTest_5
31  */
32 //1)
33 // - Use System.setProperty("sun.awt.enableExtraMouseButtons", "false")
34 // - Verifies that System.getProperty("sun.awt.enableExtraMouseButtons") returns false
35 // - Verifies that Toolkit.areExtraMouseButtonsEnabled() returns false.
36 //2)
37 // - Use System.setProperty("sun.awt.enableExtraMouseButtons", "true")
38 // - Verifies that System.getProperty("sun.awt.enableExtraMouseButtons") returns true
39 // - Verifies that Toolkit.areExtraMouseButtonsEnabled() returns false still.
40 
41 import java.awt.*;
42 
43 public class SystemPropTest_5 {
main(String []s)44     public static void main(String []s){
45         System.out.println("STAGE 1");
46         System.setProperty("sun.awt.enableExtraMouseButtons", "false");
47         boolean propValue = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons"));
48         if (propValue){
49             throw new RuntimeException("TEST FAILED(1) : System property sun.awt.enableExtraMouseButtons = " + propValue);
50         }
51         if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
52             throw new RuntimeException("TEST FAILED(1) : Toolkit.areExtraMouseButtonsEnabled() returns true");
53         }
54 
55         System.out.println("STAGE 2");
56         System.setProperty("sun.awt.enableExtraMouseButtons", "true");
57         propValue = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons"));
58         if (!propValue){
59             throw new RuntimeException("TEST FAILED(2) : System property sun.awt.enableExtraMouseButtons = " + propValue);
60         }
61         if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
62             throw new RuntimeException("TEST FAILED(2) : Toolkit.areExtraMouseButtonsEnabled() returns true");
63         }
64         System.out.println("Test passed.");
65     }
66 }
67