-
-
Save coyarzun89/f7ae848392c1ebef56cf0548f0a31b40 to your computer and use it in GitHub Desktop.
HardcodedColorXmlDetectorTest.kt
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
class HardcodedColorXmlDetectorTest { | |
@Test | |
fun `Given a hardcoded color on a custom text view property, When we analyze our custom rule, Then display an error`() { | |
lint() | |
.files( | |
xml( | |
"res/layout/layout.xml", | |
""" | |
<TextView xmlns:app="http://schemas.android.com/apk/res-auto" | |
app:someCustomColor="#fff"/> | |
""" | |
).indented() | |
) | |
.issues(HardcodedColorXmlDetector.ISSUE) | |
.allowMissingSdk() | |
.run() | |
.expectCount(1, Severity.ERROR) | |
} | |
@Test | |
fun `Given a hardcoded color on a text view, When we analyze our custom rule, Then display an error`() { | |
lint() | |
.files( | |
xml( | |
"res/layout/layout.xml", | |
""" | |
<TextView xmlns:android="http://schemas.android.com/apk/res/android" | |
android:textColor="#80000000"/> | |
""" | |
).indented() | |
) | |
.issues(HardcodedColorXmlDetector.ISSUE) | |
.allowMissingSdk() | |
.run() | |
.expectCount(1, Severity.ERROR) | |
} | |
@Test | |
fun `Given a color from our resources on a text view, When we analyze our custom rule, Then expect no errors`() { | |
lint() | |
.files( | |
xml( | |
"res/layout/layout.xml", | |
""" | |
<TextView xmlns:android="http://schemas.android.com/apk/res/android" | |
android:textColor="@color/primaryColor"/> | |
""" | |
).indented() | |
) | |
.issues(HardcodedColorXmlDetector.ISSUE) | |
.allowMissingSdk() | |
.run() | |
.expectClean() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment