austgl / robotium

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

Text search in multiple list fragments fails #233

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a view pager with a couple of list fragments
2. Make sure that first list fragment is scrolled out of the screen
3. search for a text view which occurs in the second fragment
4. ViewFetcher.getView will return the first list view instead of the second 
one although first one has negative absolute coordinates. Scroller will then 
try to scroll the wrong list.

What is the expected output? What do you see instead?
I would like to see the second list view scroll. I see that the current visible 
one does not scroll at all. Adding debug output showed that the list that is 
currently off-screen was scrolled instead.

What version of the product are you using? On what operating system?
3.1, OS is 2.2

Please provide any additional information below.

I can imagine a fix for like this:
    public final <T extends View> T getView(Class<T> classToFilterBy, ArrayList<T> views){
        T viewToReturn = null;
        long drawingTime = 0;
        if(views == null){
            views = RobotiumUtils.removeInvisibleViews(getCurrentViews(classToFilterBy));
        }
        for(T view : views){
            int[] locationOnScreen =  new int[2];
            view.getLocationOnScreen(locationOnScreen);
            if (locationOnScreen[0] < 0) {
                continue;

However, it probably needs to be extended so that it also covers lists that are 
to right side of the current visible one. Visible means visible to the user.

Original issue reported on code.google.com by josefaic...@gmail.com on 12 Mar 2012 at 4:24

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. Would it be possible for you to supply a sample 
project which exhibits this behavior? 

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

GoogleCodeExporter commented 9 years ago
Hello, sample is attached. Note that it would be possible to condense it a bit 
more (i.e. remove the tab bar). However, keeping it makes it obvious what the 
whole thing is about. The test basically searches for an item in the first tab, 
then switches to the second tab and searches for an item in that tab which 
eventually fails. As written in my initial comment: it seems that the view 
fetcher returns the first list view instead of the current one and search then 
happens in the wrong view. I patched the code (so that ignores views which are 
completely off-screen) which is fine for now.

Original comment by josefaic...@gmail.com on 14 Mar 2012 at 7:36

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the sample project. This will be fixed in the next release. 

Original comment by renasr...@gmail.com on 14 Mar 2012 at 3:37

GoogleCodeExporter commented 9 years ago
This has been fixed in Robotium 3.2. 

Original comment by renasr...@gmail.com on 10 Apr 2012 at 6:46