Skip to content

Commit

Permalink
Enable UI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
acosta434 committed Jan 25, 2024
1 parent 9a7f4e9 commit 5e1873d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 16 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ dependencies {
androidTestImplementation 'androidx.test:core:1.4.0'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
androidTestImplementation 'androidx.test:rules:1.4.0'

// Testing Navigation
androidTestImplementation "androidx.navigation:navigation-testing:2.3.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.hamcrest.CoreMatchers.instanceOf

class MainScreen {

val defaultCategories = arrayOf("General", "Basic Needs", "Personal Care", "Conversation", "Environment", "123", "My Sayings")
val defaultCategories = arrayOf("General", "Basic Needs", "Personal Care", "Conversation", "Environment", "123", "Recents")
val defaultPhraseGeneral = arrayOf("Please", "Yes", "Maybe", "I don't know", "Thank you", "No", "Please wait", "I didn't mean to say that")
val defaultPhraseBasicNeeds = arrayOf("I need to go to the restroom", "I am hungry", "I am hot", "I am fine", "I am thirsty", "I am cold", "I am tired", "I am good")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.willowtree.vocable.tests

import android.content.Intent
import android.Manifest
import androidx.test.espresso.IdlingPolicies
import androidx.test.espresso.IdlingRegistry
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import androidx.test.rule.ActivityTestRule
import androidx.test.rule.GrantPermissionRule
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until
Expand All @@ -19,7 +19,6 @@ import org.junit.Rule
import org.junit.rules.TestName
import timber.log.Timber
import java.io.File
import java.lang.NullPointerException
import java.util.concurrent.TimeUnit

open class BaseTest {
Expand All @@ -35,6 +34,9 @@ open class BaseTest {
@get:Rule
val activityRule = ActivityScenarioRule(SplashActivity::class.java)

@get:Rule
var mRuntimePermissionRule = GrantPermissionRule.grant(android.Manifest.permission.CAMERA)

@Rule
fun getTestName(): TestName = name

Expand Down Expand Up @@ -76,7 +78,8 @@ open class BaseTest {

// Catch the exception if the popup doesn't appear so we don't fail the tests
try {
device.wait(Until.findObject(By.text("CONTINUE")), 10000).click()
device.wait(Until.findObject(By.text("CONTINUE")), 10000)
device.pressBack()
}
catch (e: NullPointerException) {
Timber.d("Test", "Popup not found, continuing with test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class KeyboardScreenTest : BaseTest() {
private val keyboardScreen = KeyboardScreen()
private val mainScreen = MainScreen()

@Ignore
@Test
@Test
fun verifyKeyboardButtonBringsUpKeyboard() {
navigateToKeyboard()

Expand All @@ -27,7 +26,6 @@ class KeyboardScreenTest : BaseTest() {
}
}

@Ignore
@Test
fun verifyPhraseAppearsWhenTyped() {
navigateToKeyboard()
Expand All @@ -38,7 +36,6 @@ class KeyboardScreenTest : BaseTest() {
}
}

@Ignore
@Test
fun verifyBackspaceRemovesLetters() {
navigateToKeyboard()
Expand All @@ -50,7 +47,6 @@ class KeyboardScreenTest : BaseTest() {
}
}

@Ignore
@Test
fun verifyClearResetsInput() {
navigateToKeyboard()
Expand All @@ -62,7 +58,6 @@ class KeyboardScreenTest : BaseTest() {
}
}

@Ignore
@Test
fun verifyPresetsButtonReturnsToHome() {
navigateToKeyboard()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.willowtree.vocable.tests

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.GrantPermissionRule
import com.willowtree.vocable.screens.MainScreen
import com.willowtree.vocable.utility.assertTextMatches
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

Expand All @@ -12,7 +14,6 @@ class MainScreenTest : BaseTest() {

private val mainScreen = MainScreen()

@Ignore
@Test
fun verifyDefaultTextAppears() {
mainScreen.apply {
Expand All @@ -21,7 +22,6 @@ class MainScreenTest : BaseTest() {
}
}

@Ignore
@Test
fun verifyClickingPhraseUpdatesCurrentText() {
mainScreen.apply {
Expand All @@ -30,15 +30,13 @@ class MainScreenTest : BaseTest() {
}
}

@Ignore
@Test
fun verifyDefaultCategoriesExist() {
mainScreen.apply {
verifyDefaultCategoriesExist()
}
}

@Ignore
@Test
fun verifyDefaultSayingsInCategoriesExist() {
mainScreen.apply {
Expand All @@ -47,7 +45,6 @@ class MainScreenTest : BaseTest() {
}
}

@Ignore
@Test
fun verifySelectingCategoryChangesPhrases() {
mainScreen.apply {
Expand Down

0 comments on commit 5e1873d

Please sign in to comment.