Skip to content

Commit

Permalink
Refactored the test cases according to our this change.
Browse files Browse the repository at this point in the history
  • Loading branch information
MohitMaliDeveloper authored and kelson42 committed Oct 15, 2024
1 parent 02d732f commit 9f7af51
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import org.kiwix.kiwixmobile.Findable.StringId.TextId
import org.kiwix.kiwixmobile.Findable.Text
import org.kiwix.kiwixmobile.Findable.ViewId
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.R.id
import org.kiwix.kiwixmobile.core.utils.files.Log
import org.kiwix.kiwixmobile.testutils.TestUtils
import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView
Expand Down Expand Up @@ -74,7 +75,7 @@ class ZimHostRobot : BaseRobot() {
fun startServer() {
// stop the server if it is already running.
stopServerIfAlreadyStarted()
clickOn(ViewId(R.id.startServerButton))
clickOn(ViewId(id.startServerButton))
assetWifiDialogDisplayed()
testFlakyView({ onView(withText("PROCEED")).perform(click()) })
}
Expand Down Expand Up @@ -115,7 +116,7 @@ class ZimHostRobot : BaseRobot() {
} catch (assertionFailedError: AssertionFailedError) {
try {
val recyclerViewItemsCount =
RecyclerViewItemCount(R.id.recyclerViewZimHost).checkRecyclerViewCount()
RecyclerViewItemCount(id.recyclerViewZimHost).checkRecyclerViewCount()
(0 until recyclerViewItemsCount)
.asSequence()
.filter { it != 0 }
Expand All @@ -129,14 +130,14 @@ class ZimHostRobot : BaseRobot() {
private fun selectZimFile(position: Int) {
try {
onView(
RecyclerViewMatcher(R.id.recyclerViewZimHost).atPositionOnView(
RecyclerViewMatcher(id.recyclerViewZimHost).atPositionOnView(
position,
R.id.itemBookCheckbox
)
).check(matches(ViewMatchers.isChecked()))
} catch (assertionError: AssertionFailedError) {
onView(
RecyclerViewMatcher(R.id.recyclerViewZimHost).atPositionOnView(
RecyclerViewMatcher(id.recyclerViewZimHost).atPositionOnView(
position,
R.id.itemBookCheckbox
)
Expand All @@ -147,14 +148,14 @@ class ZimHostRobot : BaseRobot() {
fun assertItemHostedOnServer(itemCount: Int) {
val checkedCheckboxCount =
RecyclerViewSelectedCheckBoxCountAssertion(
R.id.recyclerViewZimHost,
id.recyclerViewZimHost,
R.id.itemBookCheckbox
).countCheckedCheckboxes()
assertThat(checkedCheckboxCount, CoreMatchers.`is`(itemCount))
}

fun stopServer() {
testFlakyView({ onView(withId(R.id.startServerButton)).perform(click()) })
testFlakyView({ onView(withId(id.startServerButton)).perform(click()) })
}

fun assertServerStopped() {
Expand All @@ -163,11 +164,11 @@ class ZimHostRobot : BaseRobot() {
}

fun assertQrShown() {
isVisible(ViewId(R.id.serverQrCode))
isVisible(ViewId(id.serverQrCode))
}

fun assertQrNotShown() {
isNotVisible(ViewId(R.id.serverQrCode))
isNotVisible(ViewId(id.serverQrCode))
}

private fun pauseForBetterTestPerformance() {
Expand Down

0 comments on commit 9f7af51

Please sign in to comment.