001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package com.sun.midp.chameleon.input;
028:
029: import com.sun.midp.i3test.TestCase;
030:
031: public class TestNativeInputMode extends TestCase {
032:
033: /**
034: * Overridden from TestCase parent. This method will kick off each
035: * individual test
036: */
037: public void testNativeInputMode() {
038: /*
039: String [] cn = InputModeFactory.getJavaInputModeClassNames();
040: for (int i=0;i<cn.length;i++) {
041: System.out.print("'"+cn[i]+"' ");
042: }
043: System.out.println(";");
044: int [] ci = InputModeFactory.getNativeInputModeIds();
045: for (int i=0;i<ci.length;i++) {
046: System.out.print("'"+ci[i]+"' ");
047: }
048: System.out.println(";");
049: */
050: int[] ci = InputModeFactory.getInputModeIds();
051: if (getVerbose()) {
052: for (int i = 0; i < ci.length; i++) {
053: System.out.print("'" + ci[i] + "' ");
054: }
055: System.out.println(";");
056: }
057:
058: NativeInputMode nim = new NativeInputMode();
059: nim.initialize(1);
060:
061: info("map:");
062: boolean[][] ismap = nim.getIsConstraintsMap();
063: if (getVerbose()) {
064: for (int j = 0; j < ismap.length; j++) {
065: for (int i = 0; i < ismap[j].length; i++) {
066: System.out.print(" " + (ismap[j][i] ? "t" : "f"));
067: }
068: System.out.println(" ");
069: }
070: System.out.println(";");
071: }
072:
073: assertEquals("id ", 1, nim.id);
074: assertTrue("supportsConstraints ", true == nim
075: .supportsConstraints(0));
076: assertNotNull("getName() " + nim.getName(), nim.getName());
077: assertNotNull("getCommandName() " + nim.getCommandName(), nim
078: .getCommandName());
079: nim.beginInput(null, "", 0);
080: assertEquals("processKey ", 0, nim.processKey(1, true));
081: assertEquals("getPendingChar ", 0, nim.getPendingChar());
082: assertEquals("getNextMatch ", "", nim.getNextMatch());
083: assertFalse("hasMoreMatches ", nim.hasMoreMatches());
084: String[] ml = nim.getMatchList();
085: assertEquals("getMatchList().length ", 0,
086: nim.getMatchList().length);
087: if (getVerbose()) {
088: System.out.print("getMatchList() ");
089: for (int i = 0; i < nim.getMatchList().length; i++) {
090: System.out.print("'" + ml[i] + "' ");
091: }
092: System.out.println(";");
093: }
094:
095: try {
096: nim.endInput();
097: assertTrue("endInput successful ", true);
098: } catch (Throwable e) {
099: fail("unexpected throwable " + e);
100: e.printStackTrace();
101: }
102:
103: InputMode[] ims = InputModeFactory.createInputModes();
104: if (getVerbose()) {
105: for (int i = 0; i < ims.length; i++) {
106: System.out.print(" " + ims[i] + " ");
107: }
108: System.out.println(";");
109: }
110: }
111:
112: public void runTests() throws Throwable {
113:
114: try {
115:
116: declare("test");
117:
118: testNativeInputMode();
119:
120: assertTrue(true);
121: } finally {
122: // LcduiTestMIDlet.cleanup();
123: }
124: }
125:
126: }
|