Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dead basetest code #562

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
)
}
}
Loading