Skip to content

Commit

Permalink
8328631: Convert java/awt/InputMethods/InputMethodsTest/InputMethodsT…
Browse files Browse the repository at this point in the history
…est.java applet test to manual

Reviewed-by: prr
  • Loading branch information
Alexander Zvegintsev committed Mar 21, 2024
1 parent 700d2b9 commit 4308017
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 89 deletions.

This file was deleted.

105 changes: 56 additions & 49 deletions test/jdk/java/awt/InputMethods/InputMethodsTest/InputMethodsTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -21,68 +21,75 @@
* questions.
*/

import java.awt.TextArea;
import java.awt.TextField;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JComponent;

/*
@test
@bug 7146572 8024122
@summary Check if 'enableInputMethods' works properly for TextArea and TextField on Linux platform
@author a.stepanov
@run applet/manual=yesno InputMethodsTest.html
* @test
* @bug 7146572 8024122
* @summary Check if 'enableInputMethods' works properly for TextArea and TextField on Linux platform
* @requires (os.family == "linux")
* @library /java/awt/regtesthelpers
* @build PassFailJFrame
* @run main/manual InputMethodsTest
*/


import java.applet.Applet;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;


public class InputMethodsTest extends Applet {

TextArea txtArea = null;
TextField txtField = null;
JButton btnIM = null;
boolean inputMethodsEnabled = true;

public void init() {
this.setLayout(new BorderLayout());
public class InputMethodsTest {

private static final String INSTRUCTIONS = """
Test run requires some Japanese input method to be installed.
To test the JDK-7146572 fix, please follow these steps:
1. Enable the input method.
2. Type Japanese in the text area and the text field to the right.
2. Press the "Disable Input Methods" button.
3. Try typing Japanese again.
4. If input methods are not disabled, then press fail;
otherwise, press pass.
""";

static boolean inputMethodsEnabled = true;

public static void main(String[] args) throws Exception {
PassFailJFrame
.builder()
.title("InputMethodsTest Instructions")
.instructions(INSTRUCTIONS)
.splitUIRight(InputMethodsTest::createPanel)
.testTimeOut(10)
.rows(10)
.columns(40)
.build()
.awaitAndCheck();
}

public void start() {
public static JComponent createPanel() {
Box verticalBox = Box.createVerticalBox();

setSize(350, 200);
TextArea textArea = new TextArea();
verticalBox.add(textArea);

JPanel panel = new JPanel();
panel.setLayout(new GridLayout(2, 1));
TextField textField = new TextField();
verticalBox.add(textField);

txtArea = new TextArea();
panel.add(txtArea);
JButton btnIM = new JButton();
setBtnText(btnIM);

txtField = new TextField();
panel.add(txtField);

add(panel, BorderLayout.CENTER);

btnIM = new JButton();
setBtnText();

btnIM.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
inputMethodsEnabled = !inputMethodsEnabled;
setBtnText();
txtArea.enableInputMethods(inputMethodsEnabled);
txtField.enableInputMethods(inputMethodsEnabled);
}
btnIM.addActionListener(e -> {
inputMethodsEnabled = !inputMethodsEnabled;
setBtnText(btnIM);
textArea.enableInputMethods(inputMethodsEnabled);
textField.enableInputMethods(inputMethodsEnabled);
});

add(btnIM, BorderLayout.SOUTH);

validate();
setVisible(true);
verticalBox.add(btnIM);
return verticalBox;
}

private void setBtnText() {
private static void setBtnText(JButton btnIM) {
String s = inputMethodsEnabled ? "Disable" : "Enable";
btnIM.setText(s + " Input Methods");
}
Expand Down

1 comment on commit 4308017

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.