FakeHost

public class FakeHost
extends Object

java.lang.Object
   ↳ androidx.car.app.testing.FakeHost


A fake that simulates the behavior of the host of a car app.

This fake allows sending a PendingIntent as if the user clicked on a notification action.

It will also perform expected host behaviors such as calling Screen.onGetTemplate() after AppManager.invalidate() is called.

Summary

Public methods

void performNotificationActionClick(PendingIntent pendingIntent)

Sends the given pending intent as if the user clicked on a notification action.

Inherited methods

Public methods

performNotificationActionClick

public void performNotificationActionClick (PendingIntent pendingIntent)

Sends the given pending intent as if the user clicked on a notification action.

You can retrieve the sent Intent using:

   Shadows.shadowOf(TestCarContext.getCarContext()).getBroadcastIntents()
 

You can then test your BroadcastReceiver by calling BroadcastReceiver.onReceive(Context, Intent) with the Intent that was fired.

Parameters
pendingIntent PendingIntent

Throws
NullPointerException if pendingIntent is null