Instrumentation.ActivityMonitor does not track Intent.ACTION_CALL

I have a simple test case to check if an outgoing call is initiated by pressing a button or not.

public void testCalling(){
    IntentFilter callFilter = new IntentFilter();
    callFilter.addAction(Intent.ACTION_CALL);
    callFilter.addCategory(Intent.CATEGORY_DEFAULT);
    callFilter.addDataScheme("tel:");
    ActivityMonitor mMonitor = new ActivityMonitor(callFilter, null, false);
    getInstrumentation().addMonitor(mMonitor);

    mSolo.clickOnText("CALL");

    assertTrue(0 < mMonitor.getHits());
    sendKeys(KeyEvent.KEYCODE_ENDCALL); 
}

Although the call is Intent (an outgoing call is being made), my ActivityMonitor cannot register it. Stack trace

05-28 17:11:09.183: I/ActivityManager(71): Starting activity: Intent { act=android.intent.action.CALL dat=tel:+xxxxxxx cmp=com.android.phone/.OutgoingCallBroadcaster }

Please, help

The only other resource I could find was this discussion, which ended without any solution in the Android development team.

+5
source share
2 answers

, . , , robotium , , , .

+3

, , .

"tel". .

    public void testMakeCall(){
        IntentFilter filter = new IntentFilter(Intent.ACTION_CALL);
        filter.addCategory(Intent.CATEGORY_DEFAULT);
        filter.addDataScheme("tel");

        ActivityMonitor activityMonitor = getInstrumentation().addMonitor(filter, null, false);

        makeCall();

        assertTrue(activityMonitor.getHits() == 1);
    }
+1

All Articles