mirror of
https://github.com/revanced/smali.git
synced 2025-05-09 10:54:29 +02:00
Added the junit-tests directory, which contains a junit "Suite" class, and a couple of initial tests
git-svn-id: https://smali.googlecode.com/svn/trunk@78 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
2c5bb6ddf8
commit
20f261138f
114
src/test/smali/junit-tests/FieldTest/FieldTest.smali
Normal file
114
src/test/smali/junit-tests/FieldTest/FieldTest.smali
Normal file
@ -0,0 +1,114 @@
|
||||
.class public LFieldTest;
|
||||
.super Ljava/lang/Object;
|
||||
.source "FieldTest.smali"
|
||||
|
||||
;this class tests that fields of various types are working
|
||||
|
||||
.method public constructor <init>()V
|
||||
.registers 4
|
||||
invoke-direct {v3}, Ljava/lang/Object;-><init>()V
|
||||
|
||||
const-string v0, "publicStringFieldValue"
|
||||
iput-object v0, v3, LFieldTest;->publicStringField:Ljava/lang/String;
|
||||
|
||||
const v0, 23
|
||||
iput v0, v3, LFieldTest;->publicIntegerField:I
|
||||
|
||||
const-string v0, "publicObjectFieldValue"
|
||||
iput-object v0, v3, LFieldTest;->publicObjectField:Ljava/lang/Object;
|
||||
|
||||
const/4 v0, 3
|
||||
new-array v0, v0, [Ljava/lang/String;
|
||||
|
||||
const-string v1, "publicStringArrayFieldValue1"
|
||||
const/4 v2, 0
|
||||
aput-object v1, v0, v2
|
||||
|
||||
const-string v1, "publicStringArrayFieldValue2"
|
||||
const/4 v2, 1
|
||||
aput-object v1, v0, v2
|
||||
|
||||
const-string v1, "pubicStringArrayFieldValue3"
|
||||
const/4 v2, 2
|
||||
aput-object v1, v0, v2
|
||||
|
||||
iput-object v0, v3, LFieldTest;->publicStringArrayField:[Ljava/lang/String;
|
||||
|
||||
const-string v0, "privateStringFieldValue"
|
||||
iput-object v0, v3, LFieldTest;->privateStringField:Ljava/lang/String;
|
||||
|
||||
const-string v0, "publicStaticStringFieldValue";
|
||||
sput-object v0, LFieldTest;->publicStaticStringField:Ljava/lang/String;
|
||||
|
||||
const-string v0, "privateStaticStringFieldValue";
|
||||
sput-object v0, LFieldTest;->privateStaticStringField:Ljava/lang/String;
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.field public publicStringField:Ljava/lang/String;
|
||||
.field public publicIntegerField:I
|
||||
.field public publicObjectField:Ljava/lang/Object;
|
||||
.field public publicStringArrayField:[Ljava/lang/String;
|
||||
.field private privateStringField:Ljava/lang/String;
|
||||
.field public static publicStaticStringField:Ljava/lang/String;
|
||||
.field private static privateStaticStringField:Ljava/lang/String;
|
||||
|
||||
|
||||
.method public test()V
|
||||
.registers 5
|
||||
.annotation runtime Lorg/junit/Test;
|
||||
.end annotation
|
||||
|
||||
.line 1
|
||||
iget-object v0, v4, LFieldTest;->publicStringField:Ljava/lang/String;
|
||||
const-string v1, "publicStringFieldValue"
|
||||
invoke-static {v0, v1}, Lorg/junit/Assert;->assertEquals(Ljava/lang/Object;Ljava/lang/Object;)V
|
||||
|
||||
.line 2
|
||||
iget v0, v4, LFieldTest;->publicIntegerField:I
|
||||
int-to-long v0, v0
|
||||
const-wide/16 v2, 23
|
||||
invoke-static {v0, v1, v2, v3}, Lorg/junit/Assert;->assertEquals(JJ)V
|
||||
|
||||
.line 3
|
||||
iget-object v0, v4, LFieldTest;->publicObjectField:Ljava/lang/Object;
|
||||
const-string v1, "publicObjectFieldValue"
|
||||
invoke-static {v0, v1}, Lorg/junit/Assert;->assertEquals(Ljava/lang/Object;Ljava/lang/Object;)V
|
||||
|
||||
.line 4
|
||||
const/4 v0, 3
|
||||
new-array v0, v0, [Ljava/lang/String;
|
||||
|
||||
const-string v1, "publicStringArrayFieldValue1"
|
||||
const/4 v2, 0
|
||||
aput-object v1, v0, v2
|
||||
|
||||
const-string v1, "publicStringArrayFieldValue2"
|
||||
const/4 v2, 1
|
||||
aput-object v1, v0, v2
|
||||
|
||||
const-string v1, "pubicStringArrayFieldValue3"
|
||||
const/4 v2, 2
|
||||
aput-object v1, v0, v2
|
||||
|
||||
iget-object v1, v4, LFieldTest;->publicStringArrayField:[Ljava/lang/String;
|
||||
invoke-static {v0, v1}, Lorg/junit/Assert;->assertEquals([Ljava/lang/Object;[Ljava/lang/Object;)V
|
||||
|
||||
.line 5
|
||||
iget-object v0, v4, LFieldTest;->privateStringField:Ljava/lang/String;
|
||||
const-string v1, "privateStringFieldValue"
|
||||
invoke-static {v0, v1}, Lorg/junit/Assert;->assertEquals(Ljava/lang/Object;Ljava/lang/Object;)V
|
||||
|
||||
.line 6
|
||||
sget-object v0, LFieldTest;->publicStaticStringField:Ljava/lang/String;
|
||||
const-string v1, "publicStaticStringFieldValue"
|
||||
invoke-static {v0, v1}, Lorg/junit/Assert;->assertEquals(Ljava/lang/Object;Ljava/lang/Object;)V
|
||||
|
||||
.line 7
|
||||
sget-object v0, LFieldTest;->privateStaticStringField:Ljava/lang/String;
|
||||
const-string v1, "privateStaticStringFieldValue"
|
||||
invoke-static {v0, v1}, Lorg/junit/Assert;->assertEquals(Ljava/lang/Object;Ljava/lang/Object;)V
|
||||
|
||||
return-void
|
||||
.end method
|
@ -0,0 +1,66 @@
|
||||
.class public LSpecialInstructionPaddingTest;
|
||||
.super Ljava/lang/Object;
|
||||
.source "InstructionPaddingTest.smali"
|
||||
|
||||
.method public constructor <init>()V
|
||||
.registers 1
|
||||
invoke-direct {v0}, Ljava/lang/Object;-><init>()V
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public test()V
|
||||
.registers 4
|
||||
.annotation runtime Lorg/junit/Test;
|
||||
.end annotation
|
||||
|
||||
const v0, 0
|
||||
invoke-static {}, LSpecialInstructionPaddingTest;->paddingTest()I
|
||||
move-result v0
|
||||
int-to-long v0, v0
|
||||
|
||||
|
||||
const-wide/16 v2, 12
|
||||
|
||||
invoke-static {v0, v1, v2, v3}, Lorg/junit/Assert;->assertEquals(JJ)V
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public static paddingTest()I
|
||||
.registers 2
|
||||
|
||||
const v0, 12
|
||||
|
||||
switch:
|
||||
packed-switch v0, PackedSwitch:
|
||||
|
||||
Label10:
|
||||
const v1, 10
|
||||
return v1
|
||||
|
||||
Label11:
|
||||
const v1, 11
|
||||
return v1
|
||||
|
||||
Label12:
|
||||
const v1, 12
|
||||
return v1
|
||||
|
||||
Label13:
|
||||
const v1, 13
|
||||
return v1
|
||||
|
||||
;this nop de-aligns the following packed-switch data
|
||||
;smali should generate another nop before the packed-switch
|
||||
;data to force alignment
|
||||
nop
|
||||
|
||||
PackedSwitch:
|
||||
.packed-switch switch: 10
|
||||
Label10:
|
||||
Label11:
|
||||
Label12:
|
||||
Label13:
|
||||
.end packed-switch
|
||||
|
||||
.end method
|
26
src/test/smali/junit-tests/TestSuite.smali
Normal file
26
src/test/smali/junit-tests/TestSuite.smali
Normal file
@ -0,0 +1,26 @@
|
||||
.class public LAllTests;
|
||||
.super Ljava/lang/Object;
|
||||
|
||||
;This class is a wrapper for all the classes in the junit-tests directory
|
||||
;
|
||||
;To run the tests, you need to use dx on the junit jar and push that to the
|
||||
;device/emulator, and then zip up the classes.dex containing this class
|
||||
;and all of the tests and push that to the device/emulator.
|
||||
;
|
||||
;dx --dex --output=classes.dex junit-4.6.jar
|
||||
;zip junit-4.6.zip classes.dex
|
||||
;adb push junit-4.6.zip /data/local
|
||||
;java -jar smali.jar --dex --output=classes.dex .
|
||||
;zip smali-junit-tests.zip classes.dex
|
||||
;adb push smali-junit-tests.zip /data/local
|
||||
;adb shell dalvikvm -cp /data/local/junit-4.6.zip:/data/local/smali-junit-tests.zip org.junit.runner.JUnitCore AllTests
|
||||
|
||||
.annotation runtime Lorg/junit/runner/RunWith;
|
||||
value = Lorg/junit/runners/Suite;
|
||||
.end annotation
|
||||
|
||||
.annotation runtime Lorg/junit/runners/Suite$SuiteClasses;
|
||||
value = { LFieldTest;,
|
||||
LSpecialInstructionPaddingTest;
|
||||
}
|
||||
.end annotation
|
Loading…
x
Reference in New Issue
Block a user