austgl / robotium

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

Solo.searchText onlyVisible does not work correctly #128

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set a LinearLayout visibility = Gone
2. Search with Robotium with searchtext("thetext", true) for a text of a 
TextView within the LinearLayout

What is the expected output? What do you see instead?
expected:
2. Text is not found
instead: 
2. Text is found

What version of the product are you using? On what operating system?
2.4, Android 2.2 HTC Desire

Please provide any additional information below.
See attached project and test project for details

Original issue reported on code.google.com by JoaRe...@gmail.com on 22 Jul 2011 at 11:35

Attachments:

GoogleCodeExporter commented 9 years ago
The method only checks the text view it self if it is set to gone or 
invincible. It will not check the layout it is in. It is designed like this and 
at the moment it is not something that will be changed.

Original comment by renasr...@gmail.com on 22 Jul 2011 at 12:03

GoogleCodeExporter commented 9 years ago
I thought the idea of Robotium is that some independent tester can use the 
provided methods of Robotium in a BlackboxTest. This means that the tester only 
knows what is actually displayed, not wondering which element has its 
visibility property set to VISIBLE. Since the Layout the TextView is in can 
hide the TextView by setting its own property to INVISIBLE or GONE, I think 
Robotium should check this Layout as well. 
This is actually done quite easily as I just found out. Android provides the 
method someView.isShown(). It checks if the view and also all ancestors of the 
view is set to VISIBILE.

My suggestion would be that in the class 

RobotiumUtils 

the method

public static <T extends View> ArrayList<T> removeInvisibleViews(ArrayList<T> 
viewList)

should be changed to the following:

ArrayList<T> tmpViewList = new ArrayList<T>(viewList.size());
        for (T view : viewList) {
            if (view != null && view.isShown()) {
                tmpViewList.add(view);
            }
        }
        return tmpViewList;

Works for me so far :)

Original comment by JoaRe...@gmail.com on 22 Jul 2011 at 4:04

GoogleCodeExporter commented 9 years ago
Sounds good. Will be changed. Thanks. 

Original comment by renasr...@gmail.com on 24 Jul 2011 at 4:07