Hi,
I have the following test case which tests context.sendBoardcast() function:
public void testInstallFavorite() {
Context context = getContext();
IntentFilter filter = new IntentFilter();
filter.addAction("com.android.launcher.action.INSTALL_SHORTCUT");
context.registerReceiver(new DummyBoardcastReceiver(), filter);
Intent installShortcut = new
Intent("com.android.launcher.action.INSTALL_SHORTCUT");
context.sendBroadcast(installShortcut);
// count is a dummy variable which increments by 1
when DummyBoardcastReceiver::onReceive() is called
assertEquals(count, 1);
}
But the DummyBoardcastReceiver::onReceive() is never get called. Can
you please tell me why? or if there is a better way to unit test the
code?
private int count = 0;
class DummyBoardcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent shortCutIntent =
intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
assertNotNull(shortCutIntent);
count++;
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---