sangmingming / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

clickInList(int) doesn't work if clicked item is not displayed in first screen of device. #82

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run an application which contains a ListView, ListView's members cannot 
display in one screen of device.
2. click a list member (with method "solo.clickInList(int)") which is not in 
the first screen.

What is the expected output? What do you see instead?
The correct ListView member is clicked.
Nothing happens.

What version of the product are you using? On what operating system?
Robotium 2.2 newest version.
Android 2.1.

Please provide any additional information below.
I look into the source code. 

    public ArrayList<TextView> clickInList(int line, int index, boolean longClick, int time) {  
        line--;
        if(line < 0)
            line = 0;

        boolean foundList = waiter.waitForView(ListView.class, index);
        if (!foundList) 
            Assert.assertTrue("No ListView with index " + index + " is available!", false);

        ArrayList<View> views = new ArrayList<View>();
        final ListView listView = viewFetcher.getView(ListView.class, null, 0);
        if(listView == null)
            Assert.assertTrue("ListView is null!", false);

        View view = listView.getChildAt(line);
        if(view != null){
            views = viewFetcher.getViews(view, true);
            views = RobotiumUtils.removeInvisibleViews(views);
            clickOnScreen(view, longClick, time);
        }
        return RobotiumUtils.filterViews(TextView.class, views);
    }
---------------------------------------------
There should be some code to handle the views which cannot display in first 
screen.
And after "if(view != null){ ... }" there should be some exception handle for 
view is null.
I try to output the view which is not in the first screen,it outputs 
NullPointerException.

Original issue reported on code.google.com by maguowei...@gmail.com on 9 Mar 2011 at 8:24

GoogleCodeExporter commented 9 years ago
In clickInList() there is not scroll functionality. So if there is no element 
in the first screen then it will not click. If you want to use clickInList() on 
the second page you need to do a scrollDown() first and then use clickInList(1).

Original comment by renasr...@gmail.com on 9 Mar 2011 at 11:12

GoogleCodeExporter commented 9 years ago

Original comment by renasr...@gmail.com on 10 Mar 2011 at 5:10