Merge pull request #1524 from CatimaLoyalty/betterDefaultCardColours

Better default card colours
This commit is contained in:
Sylvia van Os
2023-09-26 19:30:59 +02:00
committed by GitHub
2 changed files with 34 additions and 1 deletions

View File

@@ -129,7 +129,6 @@
<item>#f16364</item>
<item>#f58559</item>
<item>#f9a43e</item>
<item>#e4c62e</item>
<item>#67bf74</item>
<item>#59a2be</item>
<item>#2093cd</item>

View File

@@ -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 a user has not chosen a card colour) use white foreground text
*/
@Test
public void allDefaultCardColoursHaveWhiteForegroundTest() {
try(ActivityScenario<MainActivity> 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));
}
});
}
}
}