首页 > 使用robotium测试scrollview界面如何自动滚动底部和顶部

使用robotium测试scrollview界面如何自动滚动底部和顶部

       ScrollView  scrollView_city =(ScrollView)solo.getView("id/listView_city");
        int[] location=new int[2];
        scrollView_city.getLocationOnScreen(location);
        location[1]=location[1]+scrollView_city.getBottom();
        //输出日志
        Log.d("Tag","[Location x]:  "+Integer.toString(location[0]));
        Log.d("Tag","[Location y]:  "+Integer.toString(location[1]));

        if(solo.waitForView(scrollView_city)){
            //从上往下滑动
            int newlistcount, listcount = scrollView_city.getCount();
            while(true){
                solo.scrollListToLine(scrollView_city, listcount);
                solo.sleep(500);
                solo.drag(location[0]+10f, location[0]+10f,location[1]-10f, location[0]-100f,50);
                solo.sleep(2000);
                newlistcount=listView_city.getCount();
                if(newlistcount==listcount){
                    break;
                }else{
                    listcount=newlistcount;
                    Log.d("Tag","[Location]:  "+Integer.toString(listcount));
                }
            }
        }




}
【热门文章】
【热门文章】