From c91e8394ae51e27281948bd8bd7f8694b9e447da Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Mon, 6 Jan 2025 00:13:35 +0100 Subject: [PATCH] Converted AddNewRepeatDialog to kotlin --- .../support/pages/AddNewRepeatDialog.java | 39 ------------------- .../support/pages/AddNewRepeatDialog.kt | 30 ++++++++++++++ 2 files changed, 30 insertions(+), 39 deletions(-) delete mode 100644 collect_app/src/androidTest/java/org/odk/collect/android/support/pages/AddNewRepeatDialog.java create mode 100644 collect_app/src/androidTest/java/org/odk/collect/android/support/pages/AddNewRepeatDialog.kt diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/AddNewRepeatDialog.java b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/AddNewRepeatDialog.java deleted file mode 100644 index 144e42a7a91..00000000000 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/AddNewRepeatDialog.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.odk.collect.android.support.pages; - -import static androidx.test.espresso.Espresso.onView; -import static androidx.test.espresso.assertion.ViewAssertions.matches; -import static androidx.test.espresso.matcher.RootMatchers.isDialog; -import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; -import static androidx.test.espresso.matcher.ViewMatchers.withText; - -public class AddNewRepeatDialog extends Page { - - private final String repeatName; - - public AddNewRepeatDialog(String repeatName) { - this.repeatName = repeatName; - } - - @Override - public AddNewRepeatDialog assertOnPage() { - String dialogMessage; - if (repeatName.isBlank()) { - dialogMessage = getTranslatedString(org.odk.collect.strings.R.string.add_another_question); - } else { - dialogMessage = getTranslatedString(org.odk.collect.strings.R.string.add_repeat_question, repeatName); - } - onView(withText(dialogMessage)) - .inRoot(isDialog()) - .check(matches(isDisplayed())); - return this; - } - - public > D clickOnAdd(D destination) { - return clickOnTextInDialog(org.odk.collect.strings.R.string.add_repeat, destination); - } - - public > D clickOnDoNotAdd(D destination) { - return clickOnTextInDialog(org.odk.collect.strings.R.string.cancel, destination); - } - -} diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/AddNewRepeatDialog.kt b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/AddNewRepeatDialog.kt new file mode 100644 index 00000000000..cab8d877031 --- /dev/null +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/AddNewRepeatDialog.kt @@ -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() { + 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 > clickOnAdd(destination: D): D { + return clickOnTextInDialog(R.string.add_repeat, destination) + } + + fun > clickOnDoNotAdd(destination: D): D { + return clickOnTextInDialog(R.string.cancel, destination) + } +}