From 4b2d981cc6ae3692315df35fcfcc5d745e7fb337 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Sun, 24 Sep 2023 15:37:51 +0200 Subject: [PATCH 1/3] Add test to ensure colours have white foreground --- .../java/protect/card_locker/UtilsTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/src/test/java/protect/card_locker/UtilsTest.java diff --git a/app/src/test/java/protect/card_locker/UtilsTest.java b/app/src/test/java/protect/card_locker/UtilsTest.java new file mode 100644 index 000000000..1d0013e6f --- /dev/null +++ b/app/src/test/java/protect/card_locker/UtilsTest.java @@ -0,0 +1,34 @@ +package protect.card_locker; + +import static org.junit.Assert.assertFalse; + +import android.content.res.TypedArray; +import android.graphics.Color; + +import androidx.test.core.app.ActivityScenario; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; + + +@RunWith(RobolectricTestRunner.class) +public class UtilsTest { + /** + * Ensure all the default card colours (used when an user has not chosen a card colour) use white foreground text + */ + @Test + public void allDefaultCardColoursHaveWhiteForegroundTest() { + try(ActivityScenario scenario = ActivityScenario.launch(MainActivity.class)) { + scenario.onActivity(activity -> { + TypedArray colors = activity.getApplicationContext().getResources().obtainTypedArray(R.array.letter_tile_colors); + + for (int i = 0; i < colors.length(); i++) { + // Grab white as fallback so that if the retrieval somehow fails the test is guaranteed to fail because a white background will have black foreground + int color = colors.getColor(i, Color.WHITE); + assertFalse(Utils.needsDarkForeground(color)); + } + }); + } + } +} From 926f3adb186cbee87d1d70686f8b014b13e24ff0 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Sun, 24 Sep 2023 15:40:00 +0200 Subject: [PATCH 2/3] Remove default card colour which uses wrong foreground colour --- app/src/main/res/values/settings.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml index e187197a7..223ec20ff 100644 --- a/app/src/main/res/values/settings.xml +++ b/app/src/main/res/values/settings.xml @@ -129,7 +129,6 @@ #f16364 #f58559 #f9a43e - #e4c62e #67bf74 #59a2be #2093cd From 1f70446bce9761be2df0254ad2029d64395a8533 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Mon, 25 Sep 2023 22:22:40 +0200 Subject: [PATCH 3/3] Fix typo Co-authored-by: FC (Fay) Stegerman --- app/src/test/java/protect/card_locker/UtilsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/test/java/protect/card_locker/UtilsTest.java b/app/src/test/java/protect/card_locker/UtilsTest.java index 1d0013e6f..8dad15e9a 100644 --- a/app/src/test/java/protect/card_locker/UtilsTest.java +++ b/app/src/test/java/protect/card_locker/UtilsTest.java @@ -15,7 +15,7 @@ import org.robolectric.RobolectricTestRunner; @RunWith(RobolectricTestRunner.class) public class UtilsTest { /** - * Ensure all the default card colours (used when an user has not chosen a card colour) use white foreground text + * Ensure all the default card colours (used when a user has not chosen a card colour) use white foreground text */ @Test public void allDefaultCardColoursHaveWhiteForegroundTest() {