Test8158478.java revision 15032:d17715657da3
190075Sobrien/* 290075Sobrien * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 390075Sobrien * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 490075Sobrien * 590075Sobrien * This code is free software; you can redistribute it and/or modify it 690075Sobrien * under the terms of the GNU General Public License version 2 only, as 790075Sobrien * published by the Free Software Foundation. 890075Sobrien * 990075Sobrien * This code is distributed in the hope that it will be useful, but WITHOUT 1090075Sobrien * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1190075Sobrien * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1290075Sobrien * version 2 for more details (a copy is included in the LICENSE file that 1390075Sobrien * accompanied this code). 1490075Sobrien * 1590075Sobrien * You should have received a copy of the GNU General Public License version 1690075Sobrien * 2 along with this work; if not, write to the Free Software Foundation, 1790075Sobrien * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1890075Sobrien * 1990075Sobrien * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2090075Sobrien * or visit www.oracle.com if you need additional information or have any 2190075Sobrien * questions. 2290075Sobrien */ 2390075Sobrien 2490075Sobrien /* 2590075Sobrien* @test 26169689Skan* @bug 8158478 27169689Skan* @requires (os.family == "linux") 2890075Sobrien* @summary To Verify X11 Keysym unicode for topt 2990075Sobrien* @run main/manual Test8158478 3090075Sobrien */ 3190075Sobrienimport java.awt.Button; 3290075Sobrienimport java.awt.Frame; 3390075Sobrienimport java.awt.GridBagConstraints; 3490075Sobrienimport java.awt.GridBagLayout; 3590075Sobrienimport java.awt.Panel; 3690075Sobrienimport java.awt.TextArea; 3790075Sobrienimport java.awt.event.ActionEvent; 3890075Sobrienimport java.awt.event.ActionListener; 3990075Sobrienimport java.util.concurrent.CountDownLatch; 4090075Sobrien 4190075Sobrienpublic class Test8158478 { 42132718Skan 4390075Sobrien public static void main(String args[]) throws Exception { 4490075Sobrien final CountDownLatch latch = new CountDownLatch(1); 4590075Sobrien 4690075Sobrien X11KeysymTest test = new X11KeysymTest(latch); 47169689Skan Thread T1 = new Thread(test); 4890075Sobrien T1.start(); 4990075Sobrien 5090075Sobrien // wait for latch to complete 5190075Sobrien latch.await(); 5290075Sobrien 5390075Sobrien if (test.testResult == false) { 5490075Sobrien throw new RuntimeException("User Clicked Fail! " 5590075Sobrien + "Wrong Unicode Character"); 5690075Sobrien } 5790075Sobrien } 5890075Sobrien} 5990075Sobrien 6090075Sobrienclass X11KeysymTest implements Runnable { 6190075Sobrien 6290075Sobrien private static GridBagLayout layout; 6390075Sobrien private static Panel mainControlPanel; 6490075Sobrien private static Panel resultButtonPanel; 6590075Sobrien private static TextArea instructionTextArea; 6690075Sobrien private static Button passButton; 6790075Sobrien private static Button failButton; 6890075Sobrien private static Frame mainFrame; 6990075Sobrien private static TextArea testArea; 70169689Skan private final CountDownLatch latch; 7190075Sobrien public volatile boolean testResult = false; 7290075Sobrien 7390075Sobrien public X11KeysymTest(CountDownLatch latch) { 7490075Sobrien this.latch = latch; 7590075Sobrien } 7690075Sobrien 7790075Sobrien @Override 7890075Sobrien public void run() { 7990075Sobrien createUI(); 8090075Sobrien } 8190075Sobrien 8290075Sobrien public final void createUI() { 8390075Sobrien 8490075Sobrien mainFrame = new Frame("X11 Keysym Test"); 8590075Sobrien layout = new GridBagLayout(); 8690075Sobrien mainControlPanel = new Panel(layout); 8790075Sobrien resultButtonPanel = new Panel(layout); 8890075Sobrien 8990075Sobrien GridBagConstraints gbc = new GridBagConstraints(); 9090075Sobrien String instructions 9190075Sobrien = "INSTRUCTIONS:" 9290075Sobrien + "\n Have a custom X11 keyboard layout with" 9390075Sobrien + " \"topt\" assigned to some key: " 9490075Sobrien + "\n Map \"topt\" key to \"Caps_Lock\" by executing" 9590075Sobrien + " following command in Terminal:" 9690075Sobrien + "\n xmodmap -e \"keysym Caps_Lock = topt\"." 9790075Sobrien + "\n Go to TextArea below and press \"CAPSLOCK\" key" 9890075Sobrien + "\n If Symbol: " + "\u252c" + " is displayed then test Pass," 9990075Sobrien + "\n If Symbol: " + "\u242c" + " is displayed then test Fail," 10090075Sobrien + "\n Execute the below command to reset the above settigs, " 10190075Sobrien + "\n setxkbmap -layout us"; 10290075Sobrien 10390075Sobrien instructionTextArea = new TextArea(); 10490075Sobrien instructionTextArea.setText(instructions); 10590075Sobrien instructionTextArea.setEnabled(true); 10690075Sobrien 10790075Sobrien gbc.gridx = 0; 108169689Skan gbc.gridy = 0; 109169689Skan gbc.fill = GridBagConstraints.HORIZONTAL; 110169689Skan mainControlPanel.add(instructionTextArea, gbc); 111169689Skan 112169689Skan testArea = new TextArea("TextArea"); 113169689Skan gbc.gridx = 0; 11490075Sobrien gbc.gridy = 1; 11590075Sobrien mainControlPanel.add(testArea, gbc); 11690075Sobrien passButton = new Button("Pass"); 117132718Skan passButton.setActionCommand("Pass"); 118217396Skib passButton.addActionListener((ActionEvent e) -> { 119217396Skib testResult = true; 120 mainFrame.dispose(); 121 latch.countDown(); 122 123 }); 124 failButton = new Button("Fail"); 125 failButton.setActionCommand("Fail"); 126 failButton.addActionListener(new ActionListener() { 127 @Override 128 public void actionPerformed(ActionEvent e) { 129 testResult = false; 130 mainFrame.dispose(); 131 latch.countDown(); 132 } 133 }); 134 gbc.gridx = 0; 135 gbc.gridy = 0; 136 resultButtonPanel.add(passButton, gbc); 137 gbc.gridx = 1; 138 gbc.gridy = 0; 139 resultButtonPanel.add(failButton, gbc); 140 141 gbc.gridx = 0; 142 gbc.gridy = 2; 143 mainControlPanel.add(resultButtonPanel, gbc); 144 145 mainFrame.add(mainControlPanel); 146 mainFrame.pack(); 147 mainFrame.setVisible(true); 148 } 149 150} 151 152