| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package com.netscape.javascript.qa.liveconnect.slot; |
| 6 |
|
| 7 |
import netscape.javascript.*; |
| 8 |
import com.netscape.javascript.qa.liveconnect.*; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public class Slot_006 extends LiveConnectTest { |
| 32 |
public Slot_006() { |
| 33 |
super(); |
| 34 |
} |
| 35 |
public static void main( String[] args ) { |
| 36 |
Slot_006 test = new Slot_006(); |
| 37 |
test.start(); |
| 38 |
} |
| 39 |
|
| 40 |
public void executeTest() { |
| 41 |
Object testMatrix[] = getDataArray(); |
| 42 |
|
| 43 |
for ( int i = 0; i < testMatrix.length; i++ ) { |
| 44 |
JSObject jsObject = getJSString( (Object[]) testMatrix[i] ); |
| 45 |
|
| 46 |
for ( int j = 0; |
| 47 |
j < ((String) ((Object[]) testMatrix[i])[1]).length(); |
| 48 |
j++ ) |
| 49 |
{ |
| 50 |
getSlot( jsObject, j, (Object[]) testMatrix[i] ); |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
public JSObject getJSString ( Object[] data ) { |
| 56 |
return (JSObject) data[0]; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
public Object[] getDataArray() { |
| 67 |
Object item0[] = { |
| 68 |
global.eval("new String(\"passed!\")"), |
| 69 |
new String("passed!") |
| 70 |
}; |
| 71 |
|
| 72 |
Object dataArray[] = { item0 }; |
| 73 |
return dataArray; |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
public void getSlot( JSObject jsString, int slot, Object[] data ) { |
| 90 |
String exception = ""; |
| 91 |
JSObject constructor = null; |
| 92 |
Class eClass = null; |
| 93 |
Class aClass = null; |
| 94 |
String result = null; |
| 95 |
String eResult = null; |
| 96 |
|
| 97 |
try { |
| 98 |
eResult = new Character( ((String)data[1]).charAt(slot) ).toString(); |
| 99 |
result = (String) jsString.getSlot( slot ); |
| 100 |
if ( result != null ) { |
| 101 |
eClass = Class.forName( "java.lang.String" ); |
| 102 |
aClass = result.getClass(); |
| 103 |
} |
| 104 |
} catch ( Exception e ) { |
| 105 |
exception = "jsString.getSlot( " + slot + " ) "+ |
| 106 |
"threw " + e.toString(); |
| 107 |
file.exception += exception; |
| 108 |
e.printStackTrace(); |
| 109 |
} finally { |
| 110 |
if ( result == null ) { |
| 111 |
addTestCase( |
| 112 |
"[jsString.getSlot(" + slot +").toString(). returned " + result +"] "+ |
| 113 |
"( " + eResult +".equals( " + result +" )", |
| 114 |
"true", |
| 115 |
eResult.equals( result +"") +"", |
| 116 |
exception ); |
| 117 |
|
| 118 |
} else { |
| 119 |
|
| 120 |
addTestCase( |
| 121 |
"[jsString.getSlot(" + slot +") returned " + result +"] "+ |
| 122 |
eResult +".toString().equals( " + result +" ) ", |
| 123 |
"true", |
| 124 |
eResult.equals( result.toString() ) +"", |
| 125 |
exception ); |
| 126 |
|
| 127 |
|
| 128 |
addTestCase( |
| 129 |
"( " + eClass +".equals( " + aClass +" ) )", |
| 130 |
"true", |
| 131 |
eClass.equals( aClass ) +"", |
| 132 |
exception ); |
| 133 |
} |
| 134 |
} |
| 135 |
} |
| 136 |
} |