Created
January 28, 2015 08:38
-
-
Save paddyzab/7ef3d9506d3a5d0b7b73 to your computer and use it in GitHub Desktop.
testing_colors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void assertIsColorClose(TextView label, int textColor) { | |
int currentTextColor = label.getCurrentTextColor(); | |
int currentRed = (currentTextColor >> 16) & 0xFF; | |
int currentGreen = (currentTextColor >> 8) & 0xFF; | |
int currentBlue = (currentTextColor >> 0) & 0xFF; | |
int expectedRed = (textColor >> 16) & 0xFF; | |
int expectedGreen = (textColor >> 8) & 0xFF; | |
int expectedBlue = (textColor >> 0) & 0xFF; | |
assertTrue(((expectedRed - COLOR_TOLERANCE) <= currentRed) && (expectedRed + COLOR_TOLERANCE) >= currentRed); | |
assertTrue(((expectedGreen - COLOR_TOLERANCE) <= currentGreen) && (expectedGreen + COLOR_TOLERANCE) >= currentGreen); | |
assertTrue(((expectedBlue - COLOR_TOLERANCE) <= currentBlue) && (expectedBlue + COLOR_TOLERANCE) >= currentBlue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment