-1

In an Android instrumented test I want to check that when selecting a checkbox, the checkbox applies the Paint.STRIKE_THRU_TEXT_FLAG paint flag to the text. Is there any way to check the paint flag of the text?

The code being tested is:

checkBox.setOnClickListener{
    checkPaintFlags(checkBox)
}

...  

private fun checkPaintFlags(checkBox: CheckBox) {
    if(checkBox.isChecked) {
        checkBox.paintFlags = Paint.STRIKE_THRU_TEXT_FLAG
    } else {
        checkBox.paintFlags = 0
    }
}
T. Green
  • 323
  • 10
  • 20
  • The paint flags are regular bit flags, so it'd be something like `val isStrikeThrough = (checkBox.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG) == Paint.STRIKE_THRU_TEXT_FLAG` (if I'm correctly understanding what you're asking). – Mike M. Jul 05 '21 at 20:19

1 Answers1

0

On an android phone go to settings -> about phone-> click build number 7 times to unlock developer mode -> enable USB debugging.

Then connect your phone with USB to your laptop/computer and click "Run App" (Green triangle) on the android studio interface. Now you can make adjustments and check them right away!

You can also use the emulator on Android Studio.

For instrumented tests: this link should help.

https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests

Shagufta
  • 40
  • 5