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