Skip to content

Commit

Permalink
Converted AddNewRepeatDialog to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Jan 12, 2025
1 parent e58d42b commit c91e839
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 39 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.odk.collect.android.support.pages

import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.RootMatchers.isDialog
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withText
import org.odk.collect.strings.R

class AddNewRepeatDialog(private val repeatName: String?) : Page<AddNewRepeatDialog>() {
override fun assertOnPage(): AddNewRepeatDialog {
val dialogMessage = if (repeatName.isNullOrBlank()) {
getTranslatedString(R.string.add_another_question)
} else {
getTranslatedString(R.string.add_repeat_question, repeatName)
}
onView(withText(dialogMessage))
.inRoot(isDialog())
.check(matches(isDisplayed()))
return this
}

fun <D : Page<D>> clickOnAdd(destination: D): D {
return clickOnTextInDialog(R.string.add_repeat, destination)
}

fun <D : Page<D>> clickOnDoNotAdd(destination: D): D {
return clickOnTextInDialog(R.string.cancel, destination)
}
}

0 comments on commit c91e839

Please sign in to comment.