Skip to content

Commit

Permalink
Merge pull request #562 from willowtreeapps/chore/561-remove-dead-bas…
Browse files Browse the repository at this point in the history
…etest-code

Remove dead basetest code
  • Loading branch information
PaulKlauser authored Jun 6, 2024
2 parents 6b11ff4 + d1ec70a commit 5d9d99d
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions app/src/androidTest/java/com/willowtree/vocable/tests/BaseTest.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
package com.willowtree.vocable.tests

import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import androidx.test.rule.GrantPermissionRule
import androidx.test.uiautomator.UiDevice
import com.willowtree.vocable.splash.SplashActivity
import com.willowtree.vocable.utility.IdlingResourceTestRule
import com.willowtree.vocable.utility.VocableKoinTestRule
import org.junit.Before
import org.junit.Rule
import org.junit.rules.TestName
import java.io.File

open class BaseTest {

private var firstLaunch = true
private val name = TestName()

@get:Rule(order = 0)
val vocableKoinTestRule = VocableKoinTestRule()

Expand All @@ -29,29 +21,4 @@ open class BaseTest {
@get:Rule
var mRuntimePermissionRule = GrantPermissionRule.grant(android.Manifest.permission.CAMERA)

@Rule
fun getTestName(): TestName = name

@Before
open fun setup() {
// Since the build machine gets wiped after every run we can check the file storage
// of the emulator to determine if this is a first time launch
// and dismiss the full screen immersive popup on android if it is
firstLaunch = getInstrumentation().targetContext.filesDir.listFiles()?.isEmpty() ?: true
if (firstLaunch) {
takeScreenshot("InitialSetup")
}
}

/* This function will take a screenshot of the application and copy it to the sd card path
on the emulator so that it can be pulled out with an adb command on the build machine.
The copy shell command is necessary because the app and its contents are deleted
once the tests finish running on CircleCI. */
fun takeScreenshot(fileName: String) {
val file = File(getInstrumentation().targetContext.filesDir.path, "$fileName.png")
UiDevice.getInstance(getInstrumentation()).takeScreenshot(file)
getInstrumentation().uiAutomation.executeShellCommand(
"run-as com.willowtree.vocable cp $file /sdcard/Pictures/$fileName.png"
)
}
}

0 comments on commit 5d9d99d

Please sign in to comment.