Skip to content

Commit 9d1da5b

Browse files
committed
8328631: Convert java/awt/InputMethods/InputMethodsTest/InputMethodsTest.java applet test to manual
Backport-of: 43080173e88c8f53cd54c9096c79f3144007fd97
1 parent dd3f559 commit 9d1da5b

File tree

2 files changed

+56
-89
lines changed

2 files changed

+56
-89
lines changed

test/jdk/java/awt/InputMethods/InputMethodsTest/InputMethodsTest.html

Lines changed: 0 additions & 40 deletions
This file was deleted.

test/jdk/java/awt/InputMethods/InputMethodsTest/InputMethodsTest.java

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -21,68 +21,75 @@
2121
* questions.
2222
*/
2323

24+
import java.awt.TextArea;
25+
import java.awt.TextField;
26+
import javax.swing.Box;
27+
import javax.swing.JButton;
28+
import javax.swing.JComponent;
2429

2530
/*
26-
@test
27-
@bug 7146572 8024122
28-
@summary Check if 'enableInputMethods' works properly for TextArea and TextField on Linux platform
29-
@author a.stepanov
30-
@run applet/manual=yesno InputMethodsTest.html
31+
* @test
32+
* @bug 7146572 8024122
33+
* @summary Check if 'enableInputMethods' works properly for TextArea and TextField on Linux platform
34+
* @requires (os.family == "linux")
35+
* @library /java/awt/regtesthelpers
36+
* @build PassFailJFrame
37+
* @run main/manual InputMethodsTest
3138
*/
3239

33-
34-
import java.applet.Applet;
35-
import java.awt.*;
36-
import javax.swing.*;
37-
import java.awt.event.*;
38-
39-
40-
public class InputMethodsTest extends Applet {
41-
42-
TextArea txtArea = null;
43-
TextField txtField = null;
44-
JButton btnIM = null;
45-
boolean inputMethodsEnabled = true;
46-
47-
public void init() {
48-
this.setLayout(new BorderLayout());
40+
public class InputMethodsTest {
41+
42+
private static final String INSTRUCTIONS = """
43+
Test run requires some Japanese input method to be installed.
44+
45+
To test the JDK-7146572 fix, please follow these steps:
46+
1. Enable the input method.
47+
2. Type Japanese in the text area and the text field to the right.
48+
2. Press the "Disable Input Methods" button.
49+
3. Try typing Japanese again.
50+
4. If input methods are not disabled, then press fail;
51+
otherwise, press pass.
52+
""";
53+
54+
static boolean inputMethodsEnabled = true;
55+
56+
public static void main(String[] args) throws Exception {
57+
PassFailJFrame
58+
.builder()
59+
.title("InputMethodsTest Instructions")
60+
.instructions(INSTRUCTIONS)
61+
.splitUIRight(InputMethodsTest::createPanel)
62+
.testTimeOut(10)
63+
.rows(10)
64+
.columns(40)
65+
.build()
66+
.awaitAndCheck();
4967
}
5068

51-
public void start() {
69+
public static JComponent createPanel() {
70+
Box verticalBox = Box.createVerticalBox();
5271

53-
setSize(350, 200);
72+
TextArea textArea = new TextArea();
73+
verticalBox.add(textArea);
5474

55-
JPanel panel = new JPanel();
56-
panel.setLayout(new GridLayout(2, 1));
75+
TextField textField = new TextField();
76+
verticalBox.add(textField);
5777

58-
txtArea = new TextArea();
59-
panel.add(txtArea);
78+
JButton btnIM = new JButton();
79+
setBtnText(btnIM);
6080

61-
txtField = new TextField();
62-
panel.add(txtField);
63-
64-
add(panel, BorderLayout.CENTER);
65-
66-
btnIM = new JButton();
67-
setBtnText();
68-
69-
btnIM.addActionListener(new ActionListener() {
70-
@Override
71-
public void actionPerformed(ActionEvent e) {
72-
inputMethodsEnabled = !inputMethodsEnabled;
73-
setBtnText();
74-
txtArea.enableInputMethods(inputMethodsEnabled);
75-
txtField.enableInputMethods(inputMethodsEnabled);
76-
}
81+
btnIM.addActionListener(e -> {
82+
inputMethodsEnabled = !inputMethodsEnabled;
83+
setBtnText(btnIM);
84+
textArea.enableInputMethods(inputMethodsEnabled);
85+
textField.enableInputMethods(inputMethodsEnabled);
7786
});
7887

79-
add(btnIM, BorderLayout.SOUTH);
80-
81-
validate();
82-
setVisible(true);
88+
verticalBox.add(btnIM);
89+
return verticalBox;
8390
}
8491

85-
private void setBtnText() {
92+
private static void setBtnText(JButton btnIM) {
8693
String s = inputMethodsEnabled ? "Disable" : "Enable";
8794
btnIM.setText(s + " Input Methods");
8895
}

0 commit comments

Comments
 (0)