brarcher / loyalty-card-locker

Stores your barcode-based store/loyalty cards on your phone
GNU General Public License v3.0
171 stars 29 forks source link

Added option to keep the screen on #316

Open franga2000 opened 4 years ago

franga2000 commented 4 years ago

Implements a setting that keeps the screen on and the app above the keyguard when displaying a barcode (as discussed in #287).

(I noticed my previous PR was on an old version so this is the same but rebased to master)

Signed-off-by: Miha Frangež<miha.frangez@gmail.com>

brarcher commented 4 years ago

Thanks for the change.

Do you think it would be possible to test this change in Robolectric? There are tests for this activity in LoyaltyCardViewActivityTest. There are a few tests which set settings. I've not tested window flags before to see if they are set, but I'm expecting it is possible. Could you look into adding a simple test?

franga2000 commented 4 years ago

I doubt the kind of testing that Robolectric does would be of much use here. From what I've read about it, the best we could do is test whether the flags were actually set, but that would effectively just test whether the Window.addFlags method works.

A more interesting test would be whether the actual functionality of "screen doesn't time out" and "window stays above lock screen" works, but that would require something that runs on a full system. UIAutomator might be able to do it, but I'm not 100%.

brarcher commented 4 years ago

I doubt the kind of testing that Robolectric does would be of much use here. From what I've read about it, the best we could do is test whether the flags were actually set, but that would effectively just test whether the Window.addFlags method works.

I think that a Robolectric test would ensure that the behavior of setting/clearing the setting has the expected behavior on the Window's flag. I'd count that as a success! The UI Automator would be more interesting, however the test setup I have for the project does not easily support running an emulator, so I'd like to avoid that path if possible.

Is it OK to add a Robolectric test for the setting, showing that the Window flags are set as expected?

franga2000 commented 4 years ago

Ok. I'll add in the following week when I get back to by workstation.