|
| 1 | +/* |
| 2 | + * Copyright (c) 2016, 2024, 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 | +import javax.swing.JComponent; |
| 25 | +import javax.swing.JLabel; |
| 26 | +import javax.swing.JPanel; |
| 27 | +import javax.swing.JTextField; |
| 28 | +import jtreg.SkippedException; |
| 29 | +import sun.awt.OSInfo; |
| 30 | + |
| 31 | +/* |
| 32 | + * @test |
| 33 | + * @bug 8154816 |
| 34 | + * @summary Caps Lock doesn't work as expected when using Pinyin Simplified input method |
| 35 | + * @requires (os.family == "mac") |
| 36 | + * @modules java.desktop/sun.awt |
| 37 | + * @library /java/awt/regtesthelpers /test/lib |
| 38 | + * @build PassFailJFrame jtreg.SkippedException Util |
| 39 | + * @run main/manual PinyinIMCapsTest |
| 40 | + */ |
| 41 | + |
| 42 | +public class PinyinIMCapsTest { |
| 43 | + private static final String INSTRUCTIONS = """ |
| 44 | + The test verifies if the Caps Lock key works properly with Pinyin |
| 45 | + input method, (i.e. if Caps Lock is pressed, input should be |
| 46 | + switched to lowercase latin letters). |
| 47 | +
|
| 48 | + Test settings: |
| 49 | + Go to "System Preferences -> Keyboard -> Input Sources" and |
| 50 | + add "Pinyin – Traditional" or "Pinyin – Simplified" IM from Chinese language group. |
| 51 | + Set current IM to "Pinyin". |
| 52 | +
|
| 53 | + 1. Set focus to the text field shown below and press Caps Lock key on the keyboard. |
| 54 | + 2. Press "a" character on the keyboard |
| 55 | + 3. If "a" character is displayed in the text field, press "Pass", |
| 56 | + if "A" character is displayed, press "Fail". |
| 57 | + """; |
| 58 | + |
| 59 | + public static void main(String[] args) throws Exception { |
| 60 | + if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) { |
| 61 | + throw new SkippedException("This test is for MacOS only"); |
| 62 | + } |
| 63 | + PassFailJFrame.builder() |
| 64 | + .title("Test Pinyin Input Method") |
| 65 | + .instructions(INSTRUCTIONS) |
| 66 | + .rows((int) INSTRUCTIONS.lines().count() + 2) |
| 67 | + .columns(45) |
| 68 | + .splitUIBottom(PinyinIMCapsTest::createUI) |
| 69 | + .testTimeOut(10) |
| 70 | + .build() |
| 71 | + .awaitAndCheck(); |
| 72 | + } |
| 73 | + |
| 74 | + private static JComponent createUI() { |
| 75 | + JPanel panel = new JPanel(); |
| 76 | + JTextField input = new JTextField(20); |
| 77 | + panel.add(new JLabel("Text field:")); |
| 78 | + panel.add(input); |
| 79 | + return panel; |
| 80 | + } |
| 81 | +} |
| 82 | + |
0 commit comments