author | ssreedharan |
Fri, 24 Nov 2017 13:18:36 +0530 | |
changeset 47974 | 9ec74010cadf |
permissions | -rw-r--r-- |
47974
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
1 |
/* |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
4 |
* |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
8 |
* |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
13 |
* accompanied this code). |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
14 |
* |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
18 |
* |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
21 |
* questions. |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
22 |
*/ |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
23 |
/* |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
24 |
* @test |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
25 |
* @key headful |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
26 |
* @bug 8176072 |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
27 |
* @summary Checks whether reading attributes are obtained for Japanese IME |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
28 |
* @requires (os.family == "windows") |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
29 |
* @run main/manual JapaneseReadingAttributes |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
30 |
*/ |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
31 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
32 |
/** |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
33 |
* This test requires a manual intervention as the keyboard layout has to be |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
34 |
* changed to Japanese IME. Once the keyboard layout has been selected, click on |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
35 |
* Start Test to start the automated tests. Will run two passes, first with an |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
36 |
* enter key in between to generate the yomigana for the first block of |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
37 |
* characters. The second without the intermediate enter key. Without the fix, |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
38 |
* there will be a mismatch in the reading attributes obtained. |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
39 |
*/ |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
40 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
41 |
import java.awt.BorderLayout; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
42 |
import java.awt.Dimension; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
43 |
import java.awt.FlowLayout; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
44 |
import java.awt.Robot; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
45 |
import java.awt.event.InputMethodEvent; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
46 |
import java.awt.event.InputMethodListener; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
47 |
import java.awt.event.WindowAdapter; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
48 |
import java.awt.event.WindowEvent; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
49 |
import javax.swing.JButton; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
50 |
import javax.swing.JFrame; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
51 |
import javax.swing.JPanel; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
52 |
import javax.swing.JTextArea; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
53 |
import javax.swing.SwingUtilities; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
54 |
import javax.swing.WindowConstants; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
55 |
import java.awt.event.KeyEvent; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
56 |
import java.text.AttributedCharacterIterator; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
57 |
import java.util.ArrayList; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
58 |
import java.util.concurrent.CountDownLatch; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
59 |
import javax.swing.JLabel; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
60 |
import javax.swing.JTextField; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
61 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
62 |
public class JapaneseReadingAttributes { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
63 |
private static boolean testPassed = false; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
64 |
private static boolean startTest = false; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
65 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
66 |
private static JFrame frame = null; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
67 |
private static JLabel lblTestStatus = null; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
68 |
private static JTextField textFieldMain = null; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
69 |
private static JTextField textFieldReading = null; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
70 |
private static String testResult; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
71 |
private static String readingPass1; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
72 |
private static String readingPass2; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
73 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
74 |
private static final CountDownLatch testStartLatch = new CountDownLatch(1); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
75 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
76 |
public static void main(String[] args) throws Exception { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
77 |
SwingUtilities.invokeAndWait(() -> { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
78 |
setupUI(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
79 |
}); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
80 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
81 |
testStartLatch.await(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
82 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
83 |
if (startTest) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
84 |
glyphTest(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
85 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
86 |
frame.dispose(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
87 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
88 |
if (testPassed) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
89 |
System.out.println(testResult); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
90 |
} else { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
91 |
throw new RuntimeException(testResult); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
92 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
93 |
} else { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
94 |
throw new RuntimeException("User has not executed the test"); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
95 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
96 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
97 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
98 |
private static void setupUI() { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
99 |
String description = " 1. Go to \"Language Preferences -> Add a Language" |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
100 |
+ "\" and add \"Japanese\"\n" |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
101 |
+ " 2. Set current IM to \"Japanese\" \n" |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
102 |
+ " 3. Try typing in the text field to ensure" |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
103 |
+ " that Japanese IME has been successfully" |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
104 |
+ " selected \n" |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
105 |
+ " 4. Now click on \"Start Test\" button \n"; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
106 |
String title = "Reading Attributes test Japanese IME (Windows)"; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
107 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
108 |
frame = new JFrame(title); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
109 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
110 |
JPanel mainPanel = new JPanel(new BorderLayout()); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
111 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
112 |
JPanel textEditPanel = new JPanel(new FlowLayout()); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
113 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
114 |
textFieldMain = new JTextField(20); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
115 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
116 |
textFieldReading = new JTextField(20); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
117 |
textFieldReading.setEditable(false); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
118 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
119 |
textEditPanel.add(textFieldMain); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
120 |
textEditPanel.add(textFieldReading); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
121 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
122 |
mainPanel.add(textEditPanel, BorderLayout.CENTER); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
123 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
124 |
JTextArea textArea = new JTextArea(description); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
125 |
textArea.setEditable(false); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
126 |
final JButton btnStartTest = new JButton("Start Test"); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
127 |
final JButton btnCancelTest = new JButton("Cancel Test"); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
128 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
129 |
btnStartTest.addActionListener((e) -> { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
130 |
btnStartTest.setEnabled(false); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
131 |
btnCancelTest.setEnabled(false); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
132 |
startTest = true; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
133 |
testStartLatch.countDown(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
134 |
}); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
135 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
136 |
btnCancelTest.addActionListener((e) -> { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
137 |
frame.dispose(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
138 |
testStartLatch.countDown(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
139 |
}); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
140 |
mainPanel.add(textArea, BorderLayout.NORTH); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
141 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
142 |
JPanel buttonPanel = new JPanel(new FlowLayout()); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
143 |
buttonPanel.add(btnStartTest); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
144 |
buttonPanel.add(btnCancelTest); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
145 |
mainPanel.add(buttonPanel, BorderLayout.SOUTH); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
146 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
147 |
lblTestStatus = new JLabel(""); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
148 |
lblTestStatus.setMinimumSize(new Dimension(250, 20)); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
149 |
lblTestStatus.setPreferredSize(new Dimension(250, 20)); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
150 |
lblTestStatus.setVisible(true); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
151 |
textEditPanel.add(lblTestStatus); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
152 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
153 |
frame.add(mainPanel); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
154 |
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
155 |
frame.pack(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
156 |
frame.setLocationRelativeTo(null); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
157 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
158 |
frame.addWindowListener(new WindowAdapter() { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
159 |
@Override |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
160 |
public void windowClosing(WindowEvent e) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
161 |
testStartLatch.countDown(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
162 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
163 |
@Override |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
164 |
public void windowOpened( WindowEvent e ){ |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
165 |
textFieldMain.requestFocusInWindow(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
166 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
167 |
}); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
168 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
169 |
textFieldMain.addInputMethodListener(new InputMethodListener() { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
170 |
@Override |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
171 |
public void caretPositionChanged(InputMethodEvent event) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
172 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
173 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
174 |
@Override |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
175 |
public void inputMethodTextChanged(InputMethodEvent event) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
176 |
AttributedCharacterIterator itr = event.getText(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
177 |
if (itr != null) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
178 |
int toCopy = event.getCommittedCharacterCount(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
179 |
if (toCopy > 0) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
180 |
itr.first(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
181 |
StringBuilder yomigana = new StringBuilder( |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
182 |
textFieldReading.getText()); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
183 |
while (toCopy-- > 0) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
184 |
if (itr.getIndex() == itr.getRunStart( |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
185 |
AttributedCharacterIterator.Attribute.READING)) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
186 |
java.text.Annotation annotatedText |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
187 |
= (java.text.Annotation) itr. |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
188 |
getAttribute(AttributedCharacterIterator.Attribute.READING); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
189 |
yomigana.append(annotatedText.getValue()); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
190 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
191 |
itr.next(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
192 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
193 |
textFieldReading.setText(yomigana.toString()); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
194 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
195 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
196 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
197 |
}); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
198 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
199 |
frame.setVisible(true); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
200 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
201 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
202 |
private static void glyphTest() throws Exception { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
203 |
Robot robotKeySimulator = new Robot(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
204 |
performTasks(robotKeySimulator); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
205 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
206 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
207 |
public static void performTasks(Robot robotForKeyInput) throws Exception { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
208 |
lblTestStatus.setText("Running Tests.."); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
209 |
robotForKeyInput.setAutoDelay(500); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
210 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
211 |
ArrayList<Integer> keyCodesToUse = new ArrayList<Integer>(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
212 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
213 |
keyCodesToUse.add(KeyEvent.VK_A); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
214 |
keyCodesToUse.add(KeyEvent.VK_B); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
215 |
keyCodesToUse.add(KeyEvent.VK_E); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
216 |
keyCodesToUse.add(KeyEvent.VK_SPACE); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
217 |
keyCodesToUse.add(KeyEvent.VK_SPACE); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
218 |
keyCodesToUse.add(KeyEvent.VK_ENTER); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
219 |
keyCodesToUse.add(KeyEvent.VK_S); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
220 |
keyCodesToUse.add(KeyEvent.VK_I); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
221 |
keyCodesToUse.add(KeyEvent.VK_N); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
222 |
keyCodesToUse.add(KeyEvent.VK_Z); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
223 |
keyCodesToUse.add(KeyEvent.VK_O); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
224 |
keyCodesToUse.add(KeyEvent.VK_U); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
225 |
keyCodesToUse.add(KeyEvent.VK_SPACE); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
226 |
keyCodesToUse.add(KeyEvent.VK_ENTER); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
227 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
228 |
textFieldMain.requestFocusInWindow(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
229 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
230 |
robotForKeyInput.waitForIdle(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
231 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
232 |
enterInput(robotForKeyInput, keyCodesToUse); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
233 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
234 |
SwingUtilities.invokeAndWait(() -> { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
235 |
readingPass1 = textFieldReading.getText(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
236 |
}); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
237 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
238 |
if (setTaskStatus(readingPass1, 1)) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
239 |
keyCodesToUse.remove((Integer) KeyEvent.VK_ENTER); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
240 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
241 |
enterInput(robotForKeyInput, keyCodesToUse); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
242 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
243 |
SwingUtilities.invokeAndWait(() -> { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
244 |
readingPass2 = textFieldReading.getText(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
245 |
}); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
246 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
247 |
if (setTaskStatus(readingPass2, 2)) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
248 |
if (readingPass1.equals(readingPass2)) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
249 |
testPassed = true; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
250 |
testResult = "Test Passed : Same reading attribute " |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
251 |
+ "obtained from both passes "; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
252 |
lblTestStatus.setText(testResult); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
253 |
} else { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
254 |
testResult = "Test Failed : Reading attribute from Pass 1 <" |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
255 |
+ readingPass1 + "> != Reading attribute " |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
256 |
+ "from Pass 2 <" + readingPass2 + ">"; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
257 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
258 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
259 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
260 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
261 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
262 |
private static void enterInput(Robot robotKeyInput, |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
263 |
ArrayList<Integer> keyInputs) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
264 |
textFieldReading.setText(""); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
265 |
textFieldMain.setText(""); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
266 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
267 |
String strKeyInput = "KeyPress=>"; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
268 |
int nOfKeyInputs = keyInputs.size(); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
269 |
for (int i = 0; i < nOfKeyInputs; i++) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
270 |
int keyToUse = keyInputs.get(i); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
271 |
robotKeyInput.keyPress(keyToUse); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
272 |
robotKeyInput.keyRelease(keyToUse); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
273 |
strKeyInput += (Integer.toHexString(keyToUse)) + ":"; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
274 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
275 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
276 |
System.out.println(strKeyInput); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
277 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
278 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
279 |
public static boolean setTaskStatus(String readingValue, int passCount) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
280 |
boolean status = false; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
281 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
282 |
if (!readingValue.isEmpty()) { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
283 |
testResult = "Attribute : " + readingValue |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
284 |
+ "read from pass " + Integer.toString(passCount); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
285 |
status = true; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
286 |
} else { |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
287 |
testResult = "Failed to read Reading attribute from pass " |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
288 |
+ Integer.toString(passCount); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
289 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
290 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
291 |
lblTestStatus.setText(testResult); |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
292 |
|
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
293 |
return status; |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
294 |
} |
9ec74010cadf
8176072: READING attributes are not available on TSF
ssreedharan
parents:
diff
changeset
|
295 |
} |