How to test Android asynchronous HTTP request and response

I have a user registration form with a submit button. Basically, when the submit button is clicked, AsyncTask appears. This AsysncTask sends an HTTP request (using Apache HttpClient) consisting of inputs in the form, for example. The IC number is sent to the server. Some reaction expected.

RegistrationActivity has the following:

public void onCreate(Bundle savedInstanceState) {
...
submitBtn.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                sendActivation(v);
            }
        });
...
}
public void sendActivation(View v) {
        EditText text = (EditText) findViewById(R.id.InputIcNo);
        if (text.getText().length() == 0) {
            showErrorMessage("IC No. cannot be blank!");
            return;
        }

        mProcess = new AsyncProcess(this, this.getApplicationContext());
        mProcess.initActivation(text.getText().toString(), null);
        mProcess.execute();
    }  

RegistrationActivityUnitTest:

ImageButton submitBtn = (ImageButton) this.activity.findViewById(R.id.BtnSubmit);
        assertNotNull(submitBtn);
        submitBtn.performClick();
// I don't know what to do from here!

How to check sending an HTTP request and receiving a response using AsyncTask?

1

-, AsyncTask ?
-, AsyncTask HTTP-?
HTTP-?
.

+3
1

, , . , thispost. , , , Observer, . "" coud .

0

All Articles