Created
July 12, 2020 06:52
-
-
Save BramYeh/8720463800116e770287a1c3d1b9b604 to your computer and use it in GitHub Desktop.
Basic Page Class
This file contains hidden or 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
import android.os.SystemClock | |
import androidx.test.espresso.Espresso | |
open class Page { | |
inline fun <reified T : Page> on(): T { | |
// reference: https://blog.kotlin-academy.com/creating-a-random-instance-of-any-class-in-kotlin-b6168655b64a | |
val page = T::class.constructors.first().call() | |
page.verify() | |
return page | |
} | |
open fun verify(): Page { | |
assert(false) | |
return this | |
} | |
fun back(): Page { | |
Espresso.pressBack() | |
return this | |
} | |
fun wait(milliseconds: Long): Page { | |
SystemClock.sleep(milliseconds) | |
return this | |
} | |
companion object { | |
inline fun <reified T : Page> on(): T { | |
return Page().on() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment