How do I assert for Title for a ProcessDialog?

11 views
Skip to first unread message

Rohit Ghatol

unread,
Sep 7, 2009, 10:54:12 AM9/7/09
to Auto-android
Hi all,
Here is code snippet I have been using.

I am reading from server in a thread. The first thing I do in the
thread is to show a process dialog (loading dialog). Once I get the
response from the server, I do a dimissDialog.

I am not sure, how do I check this condition with autoandroid. What I
want to do is
1. Launch Activity
2. Check if the Loading Dialog is shown (assertTrue)
3. Wait for say 5 seconds
4. Again check if the Loading Dialog is shown (assertNull)



// Sample code

public class MyList extends ListActivity{

private final static int DIALOG_INITIALIZE = 1;

@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_INITIALIZE: {
processDialog = new ProgressDialog(this);
processDialog.setTitle("Loading...");
processDialog.setMessage("Loading from Server");
processDialog.setIndeterminate(true);
processDialog.setCancelable(true);
return processDialog;
}
}
return null;

}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

....// inside a handler
Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
//Get info from server
........
........
dismissDialog(DIALOG_INITIALIZE);
}
}

Thread thread = new Thread(new Runnable(){
public void run(){
showDialog(DIALOG_INITIALIZE);
//Do a server call
handler.sendEmptyMessage();
}
).start();
}

}

Cheers,
Rohit



Reply all
Reply to author
Forward
0 new messages