Hi,
I'm a newbie. I encountered a wired problem. I want to do function tests
about Contacts application through Android built-in Instrumentation method.
When I test about inserting a contact , and I check the number of the
current contacts before insert and after insert , but I found the result is
0 after the insert. I use the ListView.getCount() method to get the result.
The test code looks like this:
public class TestAdd extends
ActivityInstrumentationTestCase2<ContactsListActivity>{
ContactsListActivity activity = null;
ListView listView = null;
Instrumentation instrumentation = null;
static int addBefore;
static int addAfter;
public TestAdd(){
super("com.android.contacts",ContactsListActivity.class);
}
public void setUp() throws Exception{
super.setUp();
activity = getActivity();
}
public static Test suite(){
return new TestSuite(TestAdd.class);
}
public void testAdd(){
instrumentation = getInstrumentation();
listView = activity.getListView();
addBefore = listView.getCount()-1;
this section is a serials of keyEvent operations which perform
inserting a contact.
......
......
instrumentation.waitForIdleSync();
addAfter = listView.getCount()-1;
assertEquals("Add failed.",addBefore+1,addAfter);
}
public void tearDown() throws Exception{
super.tearDown();
// activity = null;
}
}
addBefore returns the right number while addAfter returns a wrong number .I
try to use the ListView.getListAdapter.getCount() to get the result, but I
have the same wrong result. I don't know why. Is there something wrong with
my code?
I need some help and guide.
Thanks in Advance.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en