I am writing unit tests for my app and i want to test, if the alarm is properly cancelled, but i can't find the right solution to do that. I am familiar with the method of checking if the alarm is active by using the PendingIntent.getBroadcast() with FLAG_NO_CREATE flag.
I managed to successfully use the getBroadcast() function repeatedly in same test by first checking if the alarm is not set at the launch of the app and then later to check if the alarm is set, both times returning the expected boolean values. But when i try to do that in reverse order (first checking if the alarm is set and then later - if it is no longer set), my test failed, because after the second check (when the alarm should be cancelled) the getBroadcast() returned true (i expected to get false). I also tried to use the getBroadcast only once after the app cancelled the alarm, but i still got true.
Meanwhile i am assured, that the cancellation of the alarm works as expected, because app stops alarming after being "turned off".
No comments:
Post a Comment