views:

33

answers:

0

Hi folks!

I have a question regarding the creation of an IntentFilter. I'm currently writing JUnit-tests for an Android application and want to make use of ActivityMonitors. To be more specific: I want to create an ActivityMonitor which listens for calls to the address book as our Application requests the user to choose a contact from the address book. So I want to mock this by using an ActivityMonitor. This is what I have done so far:

ActivityMonitor addressBookMonitor = null;
try {
        addressBookMonitor = getInstrumentation().addMonitor(new IntentFilter(Intent.ACTION_PICK,"content://contacts/people/"), null, false);
    } catch (MalformedMimeTypeException e) {
        e.printStackTrace();
    }
//code to open the address book
Activity addressBook = getInstrumentation().waitForMonitorWithTimeout(addressBookMonitor, 250);
assertNotNull(addressBook);

The problem is, that the assertion always fails although I can see the address book opening in front of our application. Even increasing the timeout value doesn't help. This leads me to the assumption, that my ActivityMonitor/IntentFilter is set up with wrong values.

Maybe someone can help?

Thanks in advance! Sven