2

I'm trying to test a method with Robolectric (first contact with Robolectric).
I would like to set the system clock forward in order to fire an alarm, which was previously set with:

alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, alarmDelay, pendingIntent);

I tried to use SystemClock.setCurrentTimeMillis(time + alarmDelay) but it doesn't fire anything. Should I create a MockedSystemClock, but I don't know which method to use.
Please give me an idea.

Hélène
  • 377
  • 1
  • 5
  • 13

1 Answers1

0

Simply use a ShadowAlarmManager see Creating a mock AlarmManager for testing?

Community
  • 1
  • 1
rds
  • 26,253
  • 19
  • 107
  • 134