Android Robotium- Error testing listview -


hi there have simple listview wish test row of each listview represented in xml file below

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"  >   <linearlayout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical" >     <textview         android:id="@+id/id"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textsize="16sp"         android:textcolor="#f87217"         android:textstyle="bold"     />      <textview         android:id="@+id/cluster"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textsize="12sp"      />     <textview         android:id="@+id/school"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textsize="12sp"      />     <textview         android:id="@+id/level"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textsize="12sp"      />     <textview         android:id="@+id/size"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textsize="12sp"      />     </linearlayout>     </linearlayout> 

so wrote simple test code test textview inside each row of listview
however, have error retrieving textview inside 2nd row of listview

    public class booklocker2test extends        activityinstrumentationtestcase2<tabmainactivity>           { private solo solo; private button allschoolsbutton; private button viewlockerbutton;    public booklocker2test() {        super(tabmainactivity.class);   }    public void setup() throws exception {         solo = new solo(getinstrumentation(), getactivity());         allschoolsbutton = (button) solo.getcurrentactivity().findviewbyid(                 com.example.mobilelog6.r.id.btnsoesoss);         viewlockerbutton = (button) solo.getcurrentactivity().findviewbyid(                 com.example.mobilelog6.r.id.btnview);    }   @override public void teardown() throws exception {      solo.finishopenedactivities(); }  public void test(){      solo.assertcurrentactivity("wrong activity", tabmainactivity.class);   } public void testbuttonclick() {     solo.clickontext("search/book lockers");     solo.clickonbutton("soe/soss");     solo.clickonbutton("view locker selection");        solo.waitforactivity(populatelockerlist.class);      solo.assertcurrentactivity("wrong activity2", populatelockerlist.class);      //solo = new solo(getinstrumentation());     //listview mlistview = (listview)           solo.getcurrentactivity().findviewbyid(r.id.listviewlockers);     listview mlistview = (listview) solo.getview(r.id.listviewlockers);     assertnotnull("listview not allowed null",mlistview);          int expectedcount = 10;         int actualcount = mlistview.getadapter().getcount();         assertequals(expectedcount, actualcount);          listview l = ( listview )solo.getcurrentactivity().findviewbyid(                 com.example.mobilelog6.r.id.listviewlockers);           assertnotnull("no list views!", l);          view v = l.getchildat(1);          textview txt =(textview)v.findviewbyid(r.id.cluster);           string abc = txt.tostring();         assertequals("incorrect label of listview 1", "sis-2-1-102", abc);           }             } 

error message getting:

junit.framework.comparisonfailure: incorrect label of listview 1 expected:<[sis-2-1-102]> was:<[android.widget.textview@4348a808]> 

at line:

assertequals("incorrect label of listview 1", "sis-2-1-102", abc); 

please help
should getting string instead of android.widget.textview@4348a808

probably should change line

assertequals("incorrect label of listview 1", "sis-2-1-102", abc); 

with this:

assertequals("incorrect label of listview 1", "sis-2-1-102", abc.equals("sis-2-1-102")); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -