Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit de40eb94 authored by Ben Reich's avatar Ben Reich
Browse files

Mark bots in ActivityTestJunit4 as lateinit var

When tests attempt to use bots, as it's current a nullable property
they have to use the non-null assertion everywhere. Given the @Before
in ActivityTestJunit4 will run prior to the test cases, it's safe to
use lateinit var for bots and remove all the non-null assertions in
tests.

Bug: 407646510
Test: atest DocumentsUIGoogleTests
Flag: EXEMPT test change
Change-Id: Iae229c78a354b0ebc732cc8cadb0126379dbd906
parent d5a416b4
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -45,8 +45,7 @@ import org.junit.Before
 * - Cleans up the test environment
 */
abstract class ActivityTestJunit4<T : Activity?> {
    @JvmField
    var bots: Bots? = null
    lateinit var bots: Bots

    @JvmField
    var device: UiDevice? = null
@@ -133,7 +132,7 @@ abstract class ActivityTestJunit4<T : Activity?> {
        // automatically open for phone devices. Espresso register click() as (x, y) MotionEvents,
        // so if a drawer is on top of a file we want to select, it will actually click the drawer.
        // Thus to start a clean state, we always try to close first.
        bots!!.roots!!.closeDrawer()
        bots.roots!!.closeDrawer()
    }

    @After
+13 −13
Original line number Diff line number Diff line
@@ -67,13 +67,13 @@ class PeekUiTest : ActivityTestJunit4<FilesActivity?>() {
    @Throws(Exception::class)
    fun testSequentialFilePreview() {
        peekBot.assertPeekHidden()
        bots!!.directory.selectDocument("image.png")
        bots!!.main.clickActionItem("Get info")
        bots.directory.selectDocument("image.png")
        bots.main.clickActionItem("Get info")
        validatePeekContents("image.png")
        peekBot.hide()

        bots!!.directory.selectDocument("file0.log")
        bots!!.main.clickActionItem("Get info")
        bots.directory.selectDocument("file0.log")
        bots.main.clickActionItem("Get info")
        validatePeekContents("file0.log")
        peekBot.hide()
    }
@@ -83,11 +83,11 @@ class PeekUiTest : ActivityTestJunit4<FilesActivity?>() {
    fun testFileCantBeSelectedDuringFilePreview() {
        peekBot.assertPeekHidden()
        // Selecting a document should show the "1 selected" label.
        bots!!.directory.selectDocument("image.png", 1)
        bots!!.main.clickActionItem("Get info")
        bots.directory.selectDocument("image.png", 1)
        bots.main.clickActionItem("Get info")
        validatePeekContents("image.png")
        // The selection should not be possible, the "1 selected" label shouldn't show.
        bots!!.directory.selectDocument("image.png")
        bots.directory.selectDocument("image.png")
        val assertSelectionText = "1 selected"
        val timeout: Long = 1000
        val selectionText: UiObject2? =
@@ -98,8 +98,8 @@ class PeekUiTest : ActivityTestJunit4<FilesActivity?>() {
    @Test
    @Throws(Exception::class)
    fun testRestorePeekActiveState() {
        bots!!.directory.selectDocument("image.png")
        bots!!.main.clickActionItem("Get info")
        bots.directory.selectDocument("image.png")
        bots.main.clickActionItem("Get info")
        validatePeekContents("image.png")

        // Recreate the activity (happens on window resize, for example), and ensure that the
@@ -111,8 +111,8 @@ class PeekUiTest : ActivityTestJunit4<FilesActivity?>() {
        mActivityScenario!!.recreate()
        peekBot.assertPeekHidden()

        bots!!.directory.selectDocument("file0.log")
        bots!!.main.clickActionItem("Get info")
        bots.directory.selectDocument("file0.log")
        bots.main.clickActionItem("Get info")
        validatePeekContents("file0.log")
        mActivityScenario!!.recreate()
        validatePeekContents("file0.log")
@@ -121,8 +121,8 @@ class PeekUiTest : ActivityTestJunit4<FilesActivity?>() {
    @Test
    @Throws(Exception::class)
    fun testNoPreview() {
        bots!!.directory.selectDocument("file0.log")
        bots!!.main.clickActionItem("Get info")
        bots.directory.selectDocument("file0.log")
        bots.main.clickActionItem("Get info")
        validatePeekContents("file0.log")

        // Use the "No preview available" content description to ensure that the "No preview" shape