xiaofans / robotium

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

checking array with view index #360

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. call clearEditText() with the EditText id

What is the expected output? What do you see instead?
There is an IndexOutOfBoundsException thrown in Waiter->waitForAndGetView() 
function

What version of the product are you using? On what operating system?
Robotium 3.6 on Android 2.3.6

Please provide any additional information below.
In waitForAndGetView() function, the line view = views.get(index); is not 
correct. It should iterate through all the views in the array, and check it's 
corresponding id against index

Original issue reported on code.google.com by rsdso...@gmail.com on 27 Nov 2012 at 8:13

GoogleCodeExporter commented 9 years ago
Index and ID is not the same thing. Index is used for blackbox reasons. What 
you want to do is:

EditText myEditText = solo.getView(R.id);
solo.clearEditText(myEditText)

Original comment by renasr...@gmail.com on 27 Nov 2012 at 4:16

GoogleCodeExporter commented 9 years ago
In any case, the code:
    view = views.get(index);
is not correct.

It should be:
    for (T v : views) {
        if (v.getId() == index) {
            view = (T) v;
            break;
        }
    }

Original comment by rsdso...@gmail.com on 29 Nov 2012 at 6:21

GoogleCodeExporter commented 9 years ago
Index and ID is not the same thing. 

Original comment by renasr...@gmail.com on 29 Nov 2012 at 6:23

GoogleCodeExporter commented 9 years ago
OK. Finally understood. Sorry about that.

Original comment by rsdso...@gmail.com on 29 Nov 2012 at 6:28