I have the following sample robotium test case,
public class MyActivityTest extends ActivityInstrumentationTestCase2<MyActivity> {
private static Class launcherActivityClass ;
private Solo solo;
public MyActivityTest() {
super(launcherActivityClass);
}
public void setUp() throws Exception {
super.setUp();
solo=new Solo(getInstrumentation(),getActivity());
}
public void test() throws InterruptedException {
solo.enterText(0,"Hel");
solo.goBack();
solo.sendKey(solo.DOWN);
solo.enterText(0,"Hello, Android - Ed Burnette");
Thread.sleep(5000);
}
}
This is the sample Subject Under Test,
public class MyActivity extends Activity {
AutoCompleteTextView acTextView;
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
new AsyncTask(this,acTextView).execute("");
acTextView = (AutoCompleteTextView)findViewById(R.id.androidbooks);
acTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Log.i("Auto Test", adapterView.getAdapter().getItem(i).toString());
}
});
private class AsyncTask extends android.os.AsyncTask<String, String, String[]> {
public AsyncTask(Context ctxt, AutoCompleteTextView fdtv) {
}
@Override
protected String[] doInBackground(String... strings) {
return new String[0];
}
@Override
protected void onPostExecute(String[] strings) {
String[] androidBooks =
{
"Hello, Android - Ed Burnette",
"Professional Android 2 App Dev - Reto Meier",
"Unlocking Android - Frank Ableson",
"Android App Development - Blake Meike",
"Pro Android 2 - Dave MacLean",
"Beginning Android 2 - Mark Murphy",
"Android Programming Tutorials - Mark Murphy",
"Android Wireless App Development - Lauren Darcey",
"Pro Android Games - Vladimir Silva",
"Hello, Android - Ed Burnette",
"Professional Android 2 App Dev - Reto Meier",
"Unlocking Android - Frank Ableson",
"Android App Development - Blake Meike",
"Pro Android 2 - Dave MacLean",
"Beginning Android 2 - Mark Murphy",
"Android Programming Tutorials - Mark Murphy",
"Android Wireless App Development - Lauren Darcey",
"Pro Android Games - Vladimir Silva",
};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(MyActivity.this,android.R.layout.simple_dropdown_item_1line,androidBooks);
acTextView = (AutoCompleteTextView)findViewById(R.id.androidbooks);
acTextView.setThreshold(3);
acTextView.setAdapter(adapter);
}
}
}
When I run the test, AutoCompleteTextView shows up the list and the text is filled with the data, but I am not able to capture the onItemClick event of the textview.
How can i do this in robotium?
Thanks...