Sample Instrumented Test for Retained Text After Screen Rotation // Android Kotlin Dev Diary

First I added the following UI Automator to my app:

So now my build.gradle (Module) file has the following dependecies:

Then under the package app/src/androidTest/java/net/catzie/samplecalculatorapp I added the following instrumented test class:

What it does is press the buttons 1, period, and 5 on the calculator’s UI to show “1.5” which should show up the display panel, rotate the screen of the emulator/device, and then check if the display panel is still showing the value “1.5”.

I use a ViewModel and LiveData to let the value survive configuration changes such as screen rotation.

Related Posts:

Posts that may be related to "Sample Instrumented Test for Retained Text After Screen Rotation // Android Kotlin Dev Diary":

Catzie

An odd human being who happens to have a variety of ever-changing interests, but right now they are programming, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert/drink flavors, obsessing about finding out how some things works, automation, anime, video games... Ran online dessert shops Cookies PH and Catzie's Cakery in her past life.

Leave a Reply

Your email address will not be published. Required fields are marked *