Added a test case for bug 998476. No fix, just a test case verifying the bug.
This commit is contained in:
parent
b4155c3264
commit
00961b633f
5 changed files with 220 additions and 95 deletions
|
@ -490,6 +490,11 @@ Contributor(s): ______________________________________.
|
|||
<param name="my.included.source.file"
|
||||
value="org/thdl/tib/input/DuffPaneTest.java"/>
|
||||
</antcall>
|
||||
<antcall target="our-internal-javac-task">
|
||||
<param name="mybin" value="${junitbin}"/>
|
||||
<param name="my.included.source.file"
|
||||
value="org/thdl/tib/input/TinyTest.java"/>
|
||||
</antcall>
|
||||
<antcall target="our-internal-javac-task">
|
||||
<param name="mybin" value="${junitbin}"/>
|
||||
<param name="my.included.source.file"
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
<formatter type="xml"/><!-- If not XML, then 'ant -buildfile
|
||||
build.xml check-report' will fail. -->
|
||||
<test name="org.thdl.tib.input.DuffPaneTest"/>
|
||||
<test name="org.thdl.tib.input.TinyTest"/>
|
||||
</junit>
|
||||
</target>
|
||||
<target name="run-one-junit-test"
|
||||
|
|
|
@ -31,85 +31,17 @@ import org.thdl.util.ThdlOptions;
|
|||
* Tests {@link org.thdl.tib.input.Duffpane} at the unit level to see
|
||||
* that the various keyboards work as expected.
|
||||
*/
|
||||
public class DuffPaneTest extends TestCase {
|
||||
/** A DuffPane that uses THDL's extended Wylie keyboard: */
|
||||
private DuffPane dp;
|
||||
|
||||
/** Sets us up a DuffPane. */
|
||||
protected void setUp() {
|
||||
// We don't want to use options.txt:
|
||||
ThdlOptions.forTestingOnlyInitializeWithoutDefaultOptionsFile();
|
||||
|
||||
// We don't want to load the TM or TMW font files ourselves:
|
||||
ThdlOptions.setUserPreference("thdl.rely.on.system.tmw.fonts", true);
|
||||
ThdlOptions.setUserPreference("thdl.rely.on.system.tm.fonts", true);
|
||||
ThdlOptions.setUserPreference("thdl.debug", true);
|
||||
|
||||
dp = new DuffPane();
|
||||
dp.enableCaretManaging();
|
||||
dp.registerKeyboard();
|
||||
public class DuffPaneTest extends DuffPaneTestBase {
|
||||
/**
|
||||
* Plain vanilla constructor for DuffPaneTest.
|
||||
* @param arg0
|
||||
*/
|
||||
public DuffPaneTest(String arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
/** Tears us down a DuffPane. */
|
||||
protected void tearDown() {
|
||||
// let GC do its worst with dp. We're all set.
|
||||
dp = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plain vanilla constructor for DuffPaneTest.
|
||||
* @param arg0
|
||||
*/
|
||||
public DuffPaneTest(String arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
/** Invokes a text UI and runs all this class's tests. */
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(DuffPaneTest.class);
|
||||
}
|
||||
|
||||
/** After ensuring that the caret is at the very end of the
|
||||
* DuffPane's text, and that nothing is selected, this tells the
|
||||
* DuffPane that the user has pressed key. */
|
||||
private void fireKeypressWithoutModifiers(char key) {
|
||||
dp.performKeyStroke(0, new String(new char[] { key }));
|
||||
}
|
||||
|
||||
private void fireKeysWithoutModifiers(String x) {
|
||||
for (int i = 0; i < x.length(); i++) {
|
||||
fireKeypressWithoutModifiers(x.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureKeysGiveCorrectWylie(String wylie) {
|
||||
ensureKeysGiveCorrectWylie(wylie, wylie);
|
||||
}
|
||||
|
||||
private void e(String wylie) {
|
||||
ensureKeysGiveCorrectWylie(wylie);
|
||||
}
|
||||
|
||||
private void e(String in, String out) {
|
||||
ensureKeysGiveCorrectWylie(in, out);
|
||||
}
|
||||
|
||||
private void noExceptions(String keys) {
|
||||
dp.newDocument(); // initialize to a blank canvas.
|
||||
fireKeysWithoutModifiers(keys);
|
||||
// no assertion -- if an exception happens, then and only then
|
||||
// the test fails.
|
||||
}
|
||||
|
||||
private void ensureKeysGiveCorrectWylie(String keys, String wylie) {
|
||||
dp.newDocument(); // initialize to a blank canvas.
|
||||
fireKeysWithoutModifiers(keys);
|
||||
boolean passes = wylie.equals(dp.getWylie(new boolean[] { false }));
|
||||
if (!passes) {
|
||||
System.out.println("Congrats! These keys, \"" + keys
|
||||
+ "\", give this wylie, \"" + dp.getWylie(new boolean[] { false })
|
||||
+ "\", not the expected \"" + wylie + "\"");
|
||||
}
|
||||
assertTrue(passes);
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(DuffPaneTest.class);
|
||||
}
|
||||
|
||||
/** Tests that we tibwn.ini is consistent. If t+r+ne actually
|
||||
|
@ -1147,24 +1079,6 @@ public class DuffPaneTest extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
private void enableEWTSKeyboard() {
|
||||
new JskadKeyboard("EWTS for DuffPaneTest",
|
||||
null,
|
||||
null).activate(dp);
|
||||
}
|
||||
|
||||
private void enableACIPKeyboard() {
|
||||
new JskadKeyboard("Asian Classics Input Project (ACIP) FOR DuffPaneTest",
|
||||
"acip_keyboard.ini",
|
||||
null).activate(dp);
|
||||
}
|
||||
|
||||
private void enableSambhotaKeyboard() {
|
||||
new JskadKeyboard("Sambhota Keymap One FOR DuffPaneTest",
|
||||
"sambhota_keyboard_1.ini",
|
||||
null).activate(dp);
|
||||
}
|
||||
|
||||
/** Tests performing a few keystrokes in the ACIP keyboard,
|
||||
* turning those into our internal representation (IR), and then
|
||||
* converting the result to Extended Wylie. These test cases are
|
||||
|
|
129
source/org/thdl/tib/input/DuffPaneTestBase.java
Normal file
129
source/org/thdl/tib/input/DuffPaneTestBase.java
Normal file
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
The contents of this file are subject to the THDL Open Community License
|
||||
Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License on the THDL web site
|
||||
(http://www.thdl.org/).
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific terms governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Initial Developer of this software is the Tibetan and Himalayan Digital
|
||||
Library (THDL). Portions created by the THDL are Copyright 2002-2003 THDL.
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
package org.thdl.tib.input;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import org.thdl.util.ThdlOptions;
|
||||
|
||||
/**
|
||||
* @author David Chandler
|
||||
*
|
||||
* A base class whose subclasses tests {@link
|
||||
* org.thdl.tib.input.Duffpane} at the unit level. */
|
||||
public abstract class DuffPaneTestBase extends TestCase {
|
||||
/** A DuffPane that uses THDL's extended Wylie keyboard: */
|
||||
private DuffPane dp;
|
||||
|
||||
/** Sets us up a DuffPane. */
|
||||
protected void setUp() {
|
||||
// We don't want to use options.txt:
|
||||
ThdlOptions.forTestingOnlyInitializeWithoutDefaultOptionsFile();
|
||||
|
||||
// We don't want to load the TM or TMW font files ourselves:
|
||||
ThdlOptions.setUserPreference("thdl.rely.on.system.tmw.fonts", true);
|
||||
ThdlOptions.setUserPreference("thdl.rely.on.system.tm.fonts", true);
|
||||
ThdlOptions.setUserPreference("thdl.debug", true);
|
||||
|
||||
dp = new DuffPane();
|
||||
dp.enableCaretManaging();
|
||||
dp.registerKeyboard();
|
||||
}
|
||||
|
||||
/** Tears us down a DuffPane. */
|
||||
protected void tearDown() {
|
||||
// let GC do its worst with dp. We're all set.
|
||||
dp = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plain vanilla constructor for DuffPaneTestBase.
|
||||
* @param arg0
|
||||
*/
|
||||
public DuffPaneTestBase(String arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
/** After ensuring that the caret is at the very end of the
|
||||
* DuffPane's text, and that nothing is selected, this tells the
|
||||
* DuffPane that the user has pressed key. */
|
||||
private void fireKeypressWithoutModifiers(char key) {
|
||||
dp.performKeyStroke(0, new String(new char[] { key }));
|
||||
}
|
||||
|
||||
private void fireKeysWithoutModifiers(String x) {
|
||||
for (int i = 0; i < x.length(); i++) {
|
||||
fireKeypressWithoutModifiers(x.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
protected void ensureKeysGiveCorrectWylie(String wylie) {
|
||||
ensureKeysGiveCorrectWylie(wylie, wylie);
|
||||
}
|
||||
|
||||
protected void e(String wylie) {
|
||||
ensureKeysGiveCorrectWylie(wylie);
|
||||
}
|
||||
|
||||
protected void e(String in, String out) {
|
||||
ensureKeysGiveCorrectWylie(in, out);
|
||||
}
|
||||
|
||||
protected void noExceptions(String keys) {
|
||||
dp.newDocument(); // initialize to a blank canvas.
|
||||
fireKeysWithoutModifiers(keys);
|
||||
// no assertion -- if an exception happens, then and only then
|
||||
// the test fails.
|
||||
}
|
||||
|
||||
protected void ensureKeysGiveCorrectWylie(String keys, String wylie) {
|
||||
dp.newDocument(); // initialize to a blank canvas.
|
||||
fireKeysWithoutModifiers(keys);
|
||||
boolean passes = wylie.equals(dp.getWylie(new boolean[] { false }));
|
||||
if (!passes) {
|
||||
System.out.println("Congrats! These keys, \"" + keys
|
||||
+ "\", give this wylie, \"" + dp.getWylie(new boolean[] { false })
|
||||
+ "\", not the expected \"" + wylie + "\"");
|
||||
}
|
||||
assertTrue(passes);
|
||||
}
|
||||
|
||||
protected void enableEWTSKeyboard() {
|
||||
new JskadKeyboard("EWTS for DuffPaneTest",
|
||||
null,
|
||||
null).activate(dp);
|
||||
}
|
||||
|
||||
protected void enableACIPKeyboard() {
|
||||
new JskadKeyboard("Asian Classics Input Project (ACIP) FOR DuffPaneTest",
|
||||
"acip_keyboard.ini",
|
||||
null).activate(dp);
|
||||
}
|
||||
|
||||
protected void enableSambhotaKeyboard() {
|
||||
new JskadKeyboard("Sambhota Keymap One FOR DuffPaneTest",
|
||||
"sambhota_keyboard_1.ini",
|
||||
null).activate(dp);
|
||||
}
|
||||
}
|
||||
// FIXME: EWTS needs a list of "native" stacks in it.
|
||||
|
76
source/org/thdl/tib/input/TinyTest.java
Normal file
76
source/org/thdl/tib/input/TinyTest.java
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
The contents of this file are subject to the THDL Open Community License
|
||||
Version 1.0 (the "License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License on the THDL web site
|
||||
(http://www.thdl.org/).
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific terms governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Initial Developer of this software is the Tibetan and Himalayan Digital
|
||||
Library (THDL). Portions created by the THDL are Copyright 2002-2003 THDL.
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
package org.thdl.tib.input;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import org.thdl.util.ThdlOptions;
|
||||
|
||||
/**
|
||||
@author David Chandler
|
||||
|
||||
Tests TMW->EWTS (and indirectly, the EWTS->TMW keyboard). This test
|
||||
is separate from DuffPaneTest for the following reasons:
|
||||
|
||||
<p>This JUnit test is meant to do very little. That way you can
|
||||
change it to do something interesting and turn the logging way up to
|
||||
get insight. Why JUnit? Because our Ant build system makes this
|
||||
very easy to run via 'ant check-one
|
||||
-Dsoletest=org.thdl.tib.input.TinyTest. */
|
||||
public class TinyTest extends DuffPaneTestBase {
|
||||
public TinyTest(String a0) {
|
||||
super(a0);
|
||||
}
|
||||
|
||||
/** Tests this part of bug 998476:
|
||||
|
||||
<pre>
|
||||
TMW -> EWTS conversion errors
|
||||
The following incorrect conversion are happening:
|
||||
|
||||
dga'o -> dag'o
|
||||
bsad -> bas.d
|
||||
'da'i -> 'ad'i
|
||||
|
||||
'da'i should produce 'da'i since the genitive particle 'i can
|
||||
only be appended to syllables that end with vowel or
|
||||
with a chung ('). For instance sgra + 'i = sgra'i, nam
|
||||
mkha' + 'i = nam mkha'i. The case here is 'da' + 'i = 'da'i.
|
||||
syllable 'ad can't take the genitive 'i, so 'ad'i is invalid.
|
||||
|
||||
Of course this is a hypothetical syllable with no meaning,
|
||||
but following the rules 'ad would be correct. 'da would be
|
||||
mistaken. "In two-lettered words, the first is always the
|
||||
root letter." (losang thonden's modern tibetan language,
|
||||
pag 41).
|
||||
</pre>
|
||||
|
||||
*/
|
||||
public void testBug998476() {
|
||||
enableEWTSKeyboard();
|
||||
e("dga'o", "dag'o"); // FIXME: this is a bug
|
||||
e("bsad", "bas.d"); // FIXME: this is a bug
|
||||
e("'da'i", "'ad'i"); // FIXME: this is a bug
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in a new issue