[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[jx8-android] 071 - Import tests

SwikiCodeRobot @> #testJx8AndroidImportTests
"Test code"
(Smalltalk includesKey: #Test) ifTrue: [
	^self cancelFileIn
].

JavaObject 
	buildSubclasses: #(
		Test
	) in: 'org.aleReimondo.test'!

Test buildConstructors:  #(
	#(with: #(i))
	#(i #(i))
	#(i #(i other))
)!
Test buildStaticGetters:  #(
	staticFieldInt
	staticFieldDouble
	staticArrayObjects
)!
Test buildStaticFunctions: #(
	staticMethod
	#(staticMethod #(i))
	#(staticMethodOverload #(_what))
	#(staticMethodThrows #(ex))
	staticMethodThrowsNewException
	#(staticMethodCharArrayToString #(_a))
	#(staticMethodLongToString #(l))
	staticMethodReturnLong
	#(static2Objects #(_o1 _o2))
	#(staticByte #(_b))
	#(staticShort #(_s))
	#(staticLong #(_l))
	#(staticDouble #(_s))
	#(staticString #(_s))
	#(staticMethodAmbiguous #(_what))
	#(staticBigDecimalToString #(_bigDecimal))
	#(staticChar #(_c))
	#(staticShortArray #(_array))
	#(staticBooleanArray #(_array))
	#(staticDoubleArray #(_array))
	#(staticIntArray #(_array))
)!
Test buildFunctions: #(
	getInt
	#(methodOverload #(_what))
	#(methodThrows #(ex))
	methodThrowsNewException
	#(methodAmbiguous #(_what))
	getArrayOfInts
	getArrayOfBytes
	getArrayOfBools
	getArrayOfDoubles
	getArrayOfLongs
	getUnicodeBMP
	getUnicodeSMP
	getUnicodeNULL

)!



"staticFieldInt"
Test staticFieldInt = 42 ifFalse: [
	self error: 'Wrong static field value'
].

"basic access to staticFieldInt"
| native |
native := Test nativeClass handle.
(native basicAt: #staticFieldInt) = 42 ifFalse: [
	self error: 'Wrong static field value'
].
(native basicAt: #staticFieldInt put: 123) = 123 ifFalse: [
	self error: 'Error setting static'
].
(native basicAt: #staticFieldInt) = 123 ifFalse: [
	self error: 'Wrong static value (Must be 123)'
].
Test staticFieldInt = 123 ifFalse: [
	self error: 'Wrong static access (Must be 123)'
].


"staticFieldDouble"
Test staticFieldDouble = 42.5 ifFalse: [
	self error: 'Wrong static field value'
].


"staticArrayObjects"
Test staticArrayObjects isNil ifTrue: [
	self print: 'Ok - staticArrayObjects is nil'
].


"staticMethod"
(Test staticMethod: 99) = 100 ifFalse: [
	self print: 'Wrong result'
].


"getInt"
(Test with: 5) int = 5 ifFalse: [
	self print: 'Wrong getInt'
].