Hi Group
I'm trying to build a test suite for my Android appliction.
I wanted to test the GUI parts by using
ActivityInstrumentationTestCase2 and then clicking buttons etc.
If the activity I'm testing has a button onclick event that uses a
separate thread to do some networking and then update the UI, how can
I in the test method wait for the thread to update the UI, so that I
can assert that the right updates to the UI was made.
The sample onclick event:
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Thread thread = new Thread(){
public void run(){
//DO THE NETWORK THING
}
}
thread.start();
}
}
The testcase:
@UiThreadTest
public void testButton(){
Button button = (Button) getActivity().findViewById(R.id.button);
button.performClick();
//WAIT FOR THREAD TO FINISH AND THE UI IS UPDATED
ListView view = (ListView) getActivity().getListView();
assertTrue(view.getCount() > 0);
}
Now is it possible to do the waiting? If so, how?
Regards
Jesper
--
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