Emberveil sourcetests/MobileUiCheck.java
public final class MobileUiCheck {
static int checks;
static void check(boolean value,String message){checks++;if(!value)throw new AssertionError(message);}
static RSInterface widget(int width,int height,int max){RSInterface w=new RSInterface();w.type=0;w.width=width;w.height=height;w.scrollMax=max;return w;}
public static void main(String[] args)throws Exception{
RSInterface.interfaceCache=new RSInterface[3];
RSInterface root=widget(500,330,0),bank=widget(460,200,600);RSInterface.interfaceCache[1]=bank;
root.children=new int[]{1};root.childX=new int[]{10};root.childY=new int[]{20};
check(MobileUi.scroll(root,4,4,40,60,45,0)&&bank.scrollPosition==45,"bank drag scrolls child");
check(MobileUi.scroll(root,4,4,40,60,1000,0)&&bank.scrollPosition==400,"lower bound");
check(MobileUi.scroll(root,4,4,40,60,50,0)&&bank.scrollPosition==400,"boundary still consumes gesture");
check(MobileUi.scroll(root,4,4,40,60,-1000,0)&&bank.scrollPosition==0,"upper bound");
check(!MobileUi.scroll(root,4,4,600,60,45,0)&&bank.scrollPosition==0,"outside ignored");
bank.aBoolean266=true;check(!MobileUi.scroll(root,4,4,40,60,45,0),"hidden child ignored");bank.aBoolean266=false;
root.childX=new int[0];check(!MobileUi.scroll(root,4,4,40,60,45,0),"incomplete child arrays safe");
check(!MobileUi.scroll(null,0,0,1,1,1,0),"null widget safe");
check(!MobileUi.scroll(bank,0,0,1,1,1,13),"recursive depth bounded");
root.childX=new int[]{10};
MobileMain.MobileGame game=new MobileMain.MobileGame();game.openInterfaceID=0;game.minimapInt1=200;
RSInterface.interfaceCache[0]=root;
java.lang.reflect.Field current=MobileMain.class.getDeclaredField("game");current.setAccessible(true);current.set(null,game);
java.lang.reflect.Method gesture=MobileMain.class.getDeclaredMethod("applyGesture",int[].class);gesture.setAccessible(true);
gesture.invoke(null,(Object)new int[]{40,60,0,-80});
check(bank.scrollPosition==80&&game.minimapInt1==200,"bank drag scrolls without rotating camera");
gesture.invoke(null,(Object)new int[]{40,60,30,0});
check(game.minimapInt1==200,"horizontal bank drag does not rotate camera");
game.openInterfaceID=-1;gesture.invoke(null,(Object)new int[]{40,60,30,0});
check(game.minimapInt1==290,"scene drag rotates camera");
gesture.invoke(null,(Object)new int[]{-5,60,30,0});check(game.minimapInt1==290,"off-screen gesture ignored");
current.set(null,null);
System.out.println("PASS "+checks+" mobile interface scrolling checks");
}
}