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

A Filipino programmer with a variety of interests such as baking, singing, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert flavors, obsessing about finding out how some things works, board games, anime, video games, and forgetting things that usually go in her long list of interests. Running small-time online dessert shops Cookies PH and Catzie's Cakery.

Leave a Reply

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