If you like to test functionality of your broadcast receiver , you can
use mock frameworks
( I personally find jmockit most powerfull, but not easy to
understand)



On Oct 15, 10:10 am, viktor <[email protected]> wrote:
> Any proposition how to test async calls?
>
> On 14 öÏ×, 15:23, viktor <[email protected]> wrote:
>
> > Hi everyone,
>
> > Is it possible to receive notification from activities in a test case?
>
> > I want to test async precesses with broadcast messages. If process
> > done I šsend broadcast and catch it in a test case, but anything
> > doesn't happen.
>
> > I declared receiver in manifest.
>
> > This is my example: MainApp
> > šIntent intent = new Intent();
> > šintent.putExtra("test_message", "main data received");
> > šintent.setAction("test_message");
> > šsendBroadcast(intent);
>
> > TestReceiver:
>
> > public class TestBroadcastReceiver extends šBroadcastReceiver{
>
> > š š š š @Override
> > š š š š public void onReceive(Context arg0, Intent intent) {
> > š š š š š š š š Log.d("TestBroadcastReceiver", "broadcast received");
> > š š š š š š š š if(intent.getStringExtra("test_message") != null){
> > š š š š š š š š š š š š String testMessage = 
> > intent.getStringExtra("test_message");
> > š š š š š š š š š š š š Log.d("TestBroadcastReceiver", "test message: 
> > "+testMessage);
> > š š š š š š š š }
>
> > š š š š }
>
> > }

-- 
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

Reply via email to