mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 07:16:04 -04:00
Refactored the remaining UI test cases.
This commit is contained in:
parent
a51615e249
commit
a6eb00f6b9
@ -133,7 +133,7 @@ class NoteFragmentTest : BaseActivityTest() {
|
|||||||
loadZimFileInReader("testzim.zim")
|
loadZimFileInReader("testzim.zim")
|
||||||
StandardActions.closeDrawer() // close the drawer if open before running the test cases.
|
StandardActions.closeDrawer() // close the drawer if open before running the test cases.
|
||||||
note {
|
note {
|
||||||
clickOnNoteMenuItem(context)
|
clickOnNoteMenuItem(composeTestRule)
|
||||||
assertNoteDialogDisplayed(composeTestRule)
|
assertNoteDialogDisplayed(composeTestRule)
|
||||||
writeDemoNote(composeTestRule)
|
writeDemoNote(composeTestRule)
|
||||||
saveNote(composeTestRule)
|
saveNote(composeTestRule)
|
||||||
@ -180,7 +180,7 @@ class NoteFragmentTest : BaseActivityTest() {
|
|||||||
loadZimFileInReader("testzim.zim")
|
loadZimFileInReader("testzim.zim")
|
||||||
note {
|
note {
|
||||||
assertHomePageIsLoadedOfTestZimFile()
|
assertHomePageIsLoadedOfTestZimFile()
|
||||||
clickOnNoteMenuItem(context)
|
clickOnNoteMenuItem(composeTestRule)
|
||||||
assertNoteDialogDisplayed(composeTestRule)
|
assertNoteDialogDisplayed(composeTestRule)
|
||||||
writeDemoNote(composeTestRule)
|
writeDemoNote(composeTestRule)
|
||||||
saveNote(composeTestRule)
|
saveNote(composeTestRule)
|
||||||
@ -203,7 +203,7 @@ class NoteFragmentTest : BaseActivityTest() {
|
|||||||
deletePreviouslySavedNotes()
|
deletePreviouslySavedNotes()
|
||||||
loadZimFileInReader("testzim.zim")
|
loadZimFileInReader("testzim.zim")
|
||||||
note {
|
note {
|
||||||
clickOnNoteMenuItem(context)
|
clickOnNoteMenuItem(composeTestRule)
|
||||||
assertNoteDialogDisplayed(composeTestRule)
|
assertNoteDialogDisplayed(composeTestRule)
|
||||||
writeDemoNote(composeTestRule)
|
writeDemoNote(composeTestRule)
|
||||||
saveNote(composeTestRule)
|
saveNote(composeTestRule)
|
||||||
@ -226,7 +226,7 @@ class NoteFragmentTest : BaseActivityTest() {
|
|||||||
loadZimFileInReader("testzim.zim")
|
loadZimFileInReader("testzim.zim")
|
||||||
// Save a note.
|
// Save a note.
|
||||||
note {
|
note {
|
||||||
clickOnNoteMenuItem(context)
|
clickOnNoteMenuItem(composeTestRule)
|
||||||
assertNoteDialogDisplayed(composeTestRule)
|
assertNoteDialogDisplayed(composeTestRule)
|
||||||
writeDemoNote(composeTestRule)
|
writeDemoNote(composeTestRule)
|
||||||
saveNote(composeTestRule)
|
saveNote(composeTestRule)
|
||||||
@ -236,7 +236,7 @@ class NoteFragmentTest : BaseActivityTest() {
|
|||||||
deletePreviouslySavedNotes()
|
deletePreviouslySavedNotes()
|
||||||
// Test the note file is deleted or not.
|
// Test the note file is deleted or not.
|
||||||
note {
|
note {
|
||||||
clickOnNoteMenuItem(context)
|
clickOnNoteMenuItem(composeTestRule)
|
||||||
assertNoteDialogDisplayed(composeTestRule)
|
assertNoteDialogDisplayed(composeTestRule)
|
||||||
assertNotDoesNotExist(composeTestRule)
|
assertNotDoesNotExist(composeTestRule)
|
||||||
pressBack()
|
pressBack()
|
||||||
|
@ -18,18 +18,19 @@
|
|||||||
|
|
||||||
package org.kiwix.kiwixmobile.note
|
package org.kiwix.kiwixmobile.note
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import androidx.compose.ui.test.assertTextContains
|
import androidx.compose.ui.test.assertTextContains
|
||||||
import androidx.compose.ui.test.assertTextEquals
|
import androidx.compose.ui.test.assertTextEquals
|
||||||
|
import androidx.compose.ui.test.filter
|
||||||
|
import androidx.compose.ui.test.hasText
|
||||||
import androidx.compose.ui.test.isDisplayed
|
import androidx.compose.ui.test.isDisplayed
|
||||||
import androidx.compose.ui.test.junit4.ComposeContentTestRule
|
import androidx.compose.ui.test.junit4.ComposeContentTestRule
|
||||||
import androidx.compose.ui.test.onAllNodesWithTag
|
import androidx.compose.ui.test.onAllNodesWithTag
|
||||||
|
import androidx.compose.ui.test.onFirst
|
||||||
import androidx.compose.ui.test.onNodeWithTag
|
import androidx.compose.ui.test.onNodeWithTag
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performTextReplacement
|
import androidx.compose.ui.test.performTextReplacement
|
||||||
import androidx.test.espresso.Espresso.closeSoftKeyboard
|
import androidx.test.espresso.Espresso.closeSoftKeyboard
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
|
|
||||||
import androidx.test.espresso.action.ViewActions.click
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import androidx.test.espresso.web.sugar.Web.onWebView
|
import androidx.test.espresso.web.sugar.Web.onWebView
|
||||||
@ -37,21 +38,23 @@ import androidx.test.espresso.web.webdriver.DriverAtoms.findElement
|
|||||||
import androidx.test.espresso.web.webdriver.Locator
|
import androidx.test.espresso.web.webdriver.Locator
|
||||||
import com.adevinta.android.barista.interaction.BaristaSleepInteractions
|
import com.adevinta.android.barista.interaction.BaristaSleepInteractions
|
||||||
import org.kiwix.kiwixmobile.BaseRobot
|
import org.kiwix.kiwixmobile.BaseRobot
|
||||||
import org.kiwix.kiwixmobile.Findable.StringId.TextId
|
|
||||||
import org.kiwix.kiwixmobile.core.R
|
import org.kiwix.kiwixmobile.core.R
|
||||||
import org.kiwix.kiwixmobile.core.main.ADD_NOTE_TEXT_FILED_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.main.ADD_NOTE_TEXT_FILED_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.main.DELETE_MENU_BUTTON_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.main.DELETE_MENU_BUTTON_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.main.SAVE_MENU_BUTTON_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.main.SAVE_MENU_BUTTON_TESTING_TAG
|
||||||
|
import org.kiwix.kiwixmobile.core.main.reader.TAKE_NOTE_MENU_ITEM_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.page.DELETE_MENU_ICON_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.page.DELETE_MENU_ICON_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.page.NO_ITEMS_TEXT_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.page.NO_ITEMS_TEXT_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.page.PAGE_ITEM_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.page.PAGE_ITEM_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.page.SWITCH_TEXT_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.page.SWITCH_TEXT_TESTING_TAG
|
||||||
|
import org.kiwix.kiwixmobile.core.ui.components.OVERFLOW_MENU_BUTTON_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.ui.components.TOOLBAR_TITLE_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.ui.components.TOOLBAR_TITLE_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_CONFIRM_BUTTON_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_CONFIRM_BUTTON_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_DISMISS_BUTTON_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_DISMISS_BUTTON_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_TITLE_TEXT_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_TITLE_TEXT_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.testutils.TestUtils
|
import org.kiwix.kiwixmobile.testutils.TestUtils
|
||||||
import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView
|
import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView
|
||||||
|
import org.kiwix.kiwixmobile.testutils.TestUtils.waitUntilTimeout
|
||||||
import org.kiwix.kiwixmobile.utils.StandardActions.openDrawer
|
import org.kiwix.kiwixmobile.utils.StandardActions.openDrawer
|
||||||
|
|
||||||
fun note(func: NoteRobot.() -> Unit) = NoteRobot().apply(func)
|
fun note(func: NoteRobot.() -> Unit) = NoteRobot().apply(func)
|
||||||
@ -75,12 +78,13 @@ class NoteRobot : BaseRobot() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clickOnNoteMenuItem(context: Context) {
|
fun clickOnNoteMenuItem(composeTestRule: ComposeContentTestRule) {
|
||||||
// wait a bit to properly load the readerFragment and setting up the
|
composeTestRule.apply {
|
||||||
// overFlowOptionMenu so that we can easily click on it.
|
waitUntilTimeout()
|
||||||
pauseForBetterTestPerformance()
|
onNodeWithTag(OVERFLOW_MENU_BUTTON_TESTING_TAG).performClick()
|
||||||
openActionBarOverflowOrOptionsMenu(context)
|
waitUntilTimeout()
|
||||||
clickOn(TextId(R.string.take_notes))
|
onNodeWithTag(TAKE_NOTE_MENU_ITEM_TESTING_TAG).performClick()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun assertNoteDialogDisplayed(composeTestRule: ComposeContentTestRule) {
|
fun assertNoteDialogDisplayed(composeTestRule: ComposeContentTestRule) {
|
||||||
@ -88,9 +92,12 @@ class NoteRobot : BaseRobot() {
|
|||||||
composeTestRule.waitForIdle()
|
composeTestRule.waitForIdle()
|
||||||
composeTestRule.waitUntil(
|
composeTestRule.waitUntil(
|
||||||
TestUtils.TEST_PAUSE_MS.toLong()
|
TestUtils.TEST_PAUSE_MS.toLong()
|
||||||
) { composeTestRule.onNodeWithTag(TOOLBAR_TITLE_TESTING_TAG).isDisplayed() }
|
) {
|
||||||
composeTestRule.onNodeWithTag(TOOLBAR_TITLE_TESTING_TAG)
|
composeTestRule.onAllNodesWithTag(TOOLBAR_TITLE_TESTING_TAG)
|
||||||
.assertTextEquals(context.getString(R.string.note))
|
.filter(hasText(context.getString(R.string.note)))
|
||||||
|
.onFirst()
|
||||||
|
.isDisplayed()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,19 +23,19 @@ import androidx.compose.ui.test.hasText
|
|||||||
import androidx.compose.ui.test.isDisplayed
|
import androidx.compose.ui.test.isDisplayed
|
||||||
import androidx.compose.ui.test.junit4.ComposeContentTestRule
|
import androidx.compose.ui.test.junit4.ComposeContentTestRule
|
||||||
import androidx.compose.ui.test.junit4.ComposeTestRule
|
import androidx.compose.ui.test.junit4.ComposeTestRule
|
||||||
|
import androidx.compose.ui.test.longClick
|
||||||
|
import androidx.compose.ui.test.onNodeWithContentDescription
|
||||||
import androidx.compose.ui.test.onNodeWithTag
|
import androidx.compose.ui.test.onNodeWithTag
|
||||||
import androidx.compose.ui.test.onNodeWithText
|
import androidx.compose.ui.test.onNodeWithText
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
import androidx.compose.ui.test.performScrollToNode
|
import androidx.compose.ui.test.performScrollToNode
|
||||||
|
import androidx.compose.ui.test.performTouchInput
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.action.ViewActions.click
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
import androidx.test.espresso.action.ViewActions.longClick
|
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import applyWithViewHierarchyPrinting
|
import applyWithViewHierarchyPrinting
|
||||||
import com.adevinta.android.barista.interaction.BaristaSleepInteractions
|
import com.adevinta.android.barista.interaction.BaristaSleepInteractions
|
||||||
import org.kiwix.kiwixmobile.BaseRobot
|
import org.kiwix.kiwixmobile.BaseRobot
|
||||||
import org.kiwix.kiwixmobile.Findable.ViewId
|
|
||||||
import org.kiwix.kiwixmobile.core.R
|
import org.kiwix.kiwixmobile.core.R
|
||||||
import org.kiwix.kiwixmobile.core.page.DELETE_MENU_ICON_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.page.DELETE_MENU_ICON_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.page.NO_ITEMS_TEXT_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.page.NO_ITEMS_TEXT_TESTING_TAG
|
||||||
@ -45,9 +45,10 @@ import org.kiwix.kiwixmobile.core.page.bookmark.adapter.LibkiwixBookmarkItem
|
|||||||
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_CONFIRM_BUTTON_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_CONFIRM_BUTTON_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_TITLE_TEXT_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_TITLE_TEXT_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.testutils.TestUtils
|
import org.kiwix.kiwixmobile.testutils.TestUtils
|
||||||
|
import org.kiwix.kiwixmobile.testutils.TestUtils.TEST_PAUSE_MS
|
||||||
import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView
|
import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView
|
||||||
|
import org.kiwix.kiwixmobile.testutils.TestUtils.waitUntilTimeout
|
||||||
import org.kiwix.kiwixmobile.utils.StandardActions.openDrawer
|
import org.kiwix.kiwixmobile.utils.StandardActions.openDrawer
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
|
|
||||||
fun bookmarks(func: BookmarksRobot.() -> Unit) =
|
fun bookmarks(func: BookmarksRobot.() -> Unit) =
|
||||||
BookmarksRobot().applyWithViewHierarchyPrinting(func)
|
BookmarksRobot().applyWithViewHierarchyPrinting(func)
|
||||||
@ -100,15 +101,26 @@ class BookmarksRobot : BaseRobot() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clickOnSaveBookmarkImage() {
|
fun clickOnSaveBookmarkImage(composeTestRule: ComposeContentTestRule) {
|
||||||
pauseForBetterTestPerformance()
|
composeTestRule.apply {
|
||||||
clickOn(ViewId(R.id.bottom_toolbar_bookmark))
|
waitUntilTimeout()
|
||||||
|
onNodeWithContentDescription(context.getString(R.string.bookmarks))
|
||||||
|
.performClick()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun longClickOnSaveBookmarkImage() {
|
fun longClickOnSaveBookmarkImage(
|
||||||
// wait for disappearing the snack-bar after removing the bookmark
|
composeTestRule: ComposeContentTestRule,
|
||||||
BaristaSleepInteractions.sleep(5L, TimeUnit.SECONDS)
|
timeout: Long = TEST_PAUSE_MS.toLong()
|
||||||
testFlakyView({ onView(withId(R.id.bottom_toolbar_bookmark)).perform(longClick()) })
|
) {
|
||||||
|
composeTestRule.apply {
|
||||||
|
// wait for disappearing the snack-bar after removing the bookmark
|
||||||
|
waitUntilTimeout(timeout)
|
||||||
|
onNodeWithContentDescription(context.getString(R.string.bookmarks))
|
||||||
|
.performTouchInput {
|
||||||
|
longClick()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun assertBookmarkSaved(composeTestRule: ComposeContentTestRule) {
|
fun assertBookmarkSaved(composeTestRule: ComposeContentTestRule) {
|
||||||
|
@ -52,6 +52,8 @@ import org.kiwix.kiwixmobile.main.topLevel
|
|||||||
import org.kiwix.kiwixmobile.nav.destination.library.local.LocalLibraryFragmentDirections
|
import org.kiwix.kiwixmobile.nav.destination.library.local.LocalLibraryFragmentDirections
|
||||||
import org.kiwix.kiwixmobile.testutils.RetryRule
|
import org.kiwix.kiwixmobile.testutils.RetryRule
|
||||||
import org.kiwix.kiwixmobile.testutils.TestUtils
|
import org.kiwix.kiwixmobile.testutils.TestUtils
|
||||||
|
import org.kiwix.kiwixmobile.testutils.TestUtils.TEST_PAUSE_MS_FOR_DOWNLOAD_TEST
|
||||||
|
import org.kiwix.kiwixmobile.testutils.TestUtils.waitUntilTimeout
|
||||||
import org.kiwix.libkiwix.Book
|
import org.kiwix.libkiwix.Book
|
||||||
import org.kiwix.libkiwix.Bookmark
|
import org.kiwix.libkiwix.Bookmark
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@ -126,24 +128,25 @@ class LibkiwixBookmarkTest : BaseActivityTest() {
|
|||||||
}
|
}
|
||||||
bookmarks {
|
bookmarks {
|
||||||
// delete any bookmark if already saved to properly perform this test case.
|
// delete any bookmark if already saved to properly perform this test case.
|
||||||
longClickOnSaveBookmarkImage()
|
longClickOnSaveBookmarkImage(composeTestRule)
|
||||||
clickOnTrashIcon(composeTestRule)
|
clickOnTrashIcon(composeTestRule)
|
||||||
assertDeleteBookmarksDialogDisplayed(composeTestRule)
|
assertDeleteBookmarksDialogDisplayed(composeTestRule)
|
||||||
clickOnDeleteButton(composeTestRule)
|
clickOnDeleteButton(composeTestRule)
|
||||||
assertNoBookMarkTextDisplayed(composeTestRule)
|
assertNoBookMarkTextDisplayed(composeTestRule)
|
||||||
pressBack()
|
pressBack()
|
||||||
// Test saving bookmark
|
// Test saving bookmark
|
||||||
clickOnSaveBookmarkImage()
|
clickOnSaveBookmarkImage(composeTestRule)
|
||||||
openBookmarkScreen()
|
openBookmarkScreen()
|
||||||
assertBookmarkSaved(composeTestRule)
|
assertBookmarkSaved(composeTestRule)
|
||||||
pressBack()
|
pressBack()
|
||||||
// Test removing bookmark
|
// Test removing bookmark
|
||||||
clickOnSaveBookmarkImage()
|
composeTestRule.waitUntilTimeout()
|
||||||
longClickOnSaveBookmarkImage()
|
clickOnSaveBookmarkImage(composeTestRule)
|
||||||
|
longClickOnSaveBookmarkImage(composeTestRule, TEST_PAUSE_MS_FOR_DOWNLOAD_TEST.toLong())
|
||||||
assertBookmarkRemoved(composeTestRule)
|
assertBookmarkRemoved(composeTestRule)
|
||||||
pressBack()
|
pressBack()
|
||||||
// Save the bookmark to test whether it remains saved after the application restarts or not.
|
// Save the bookmark to test whether it remains saved after the application restarts or not.
|
||||||
clickOnSaveBookmarkImage()
|
clickOnSaveBookmarkImage(composeTestRule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,13 +170,14 @@ class LibkiwixBookmarkTest : BaseActivityTest() {
|
|||||||
}
|
}
|
||||||
bookmarks {
|
bookmarks {
|
||||||
// delete any bookmark if already saved to properly perform this test case.
|
// delete any bookmark if already saved to properly perform this test case.
|
||||||
longClickOnSaveBookmarkImage()
|
longClickOnSaveBookmarkImage(composeTestRule)
|
||||||
clickOnTrashIcon(composeTestRule)
|
clickOnTrashIcon(composeTestRule)
|
||||||
assertDeleteBookmarksDialogDisplayed(composeTestRule)
|
assertDeleteBookmarksDialogDisplayed(composeTestRule)
|
||||||
clickOnDeleteButton(composeTestRule)
|
clickOnDeleteButton(composeTestRule)
|
||||||
assertNoBookMarkTextDisplayed(composeTestRule)
|
assertNoBookMarkTextDisplayed(composeTestRule)
|
||||||
pressBack()
|
pressBack()
|
||||||
}
|
}
|
||||||
|
composeTestRule.waitUntilTimeout()
|
||||||
val navHostFragment: NavHostFragment =
|
val navHostFragment: NavHostFragment =
|
||||||
kiwixMainActivity.supportFragmentManager
|
kiwixMainActivity.supportFragmentManager
|
||||||
.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
|
.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
|
||||||
|
@ -236,7 +236,6 @@ class ReaderMenuState(
|
|||||||
private fun addReaderMenuItems() {
|
private fun addReaderMenuItems() {
|
||||||
if (menuItemVisibility[MenuItemType.AddNote] == true) {
|
if (menuItemVisibility[MenuItemType.AddNote] == true) {
|
||||||
menuItems += ActionMenuItem(
|
menuItems += ActionMenuItem(
|
||||||
icon = IconItem.Drawable(R.drawable.ic_add_note),
|
|
||||||
contentDescription = R.string.take_notes,
|
contentDescription = R.string.take_notes,
|
||||||
onClick = { menuClickListener.onAddNoteMenuClicked() },
|
onClick = { menuClickListener.onAddNoteMenuClicked() },
|
||||||
testingTag = TAKE_NOTE_MENU_ITEM_TESTING_TAG,
|
testingTag = TAKE_NOTE_MENU_ITEM_TESTING_TAG,
|
||||||
|
@ -68,6 +68,7 @@ import org.kiwix.kiwixmobile.core.ui.theme.White
|
|||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SIXTEEN_DP
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SIXTEEN_DP
|
||||||
|
|
||||||
const val TOOLBAR_TITLE_TESTING_TAG = "toolbarTitle"
|
const val TOOLBAR_TITLE_TESTING_TAG = "toolbarTitle"
|
||||||
|
const val OVERFLOW_MENU_BUTTON_TESTING_TAG = "overflowMenuButtonTestingTag"
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
@ -147,7 +148,10 @@ private fun ActionMenu(actionMenuItems: List<ActionMenuItem>) {
|
|||||||
val (mainActions, overflowActions) = actionMenuItems.partition { !it.isInOverflow }
|
val (mainActions, overflowActions) = actionMenuItems.partition { !it.isInOverflow }
|
||||||
MainMenuItems(mainActions)
|
MainMenuItems(mainActions)
|
||||||
if (overflowActions.isNotEmpty()) {
|
if (overflowActions.isNotEmpty()) {
|
||||||
IconButton(onClick = { overflowExpanded = true }) {
|
IconButton(
|
||||||
|
onClick = { overflowExpanded = true },
|
||||||
|
modifier = Modifier.testTag(OVERFLOW_MENU_BUTTON_TESTING_TAG)
|
||||||
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.MoreVert,
|
imageVector = Icons.Default.MoreVert,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
@ -224,7 +228,8 @@ private fun OverflowMenuItems(
|
|||||||
onDismiss()
|
onDismiss()
|
||||||
menuItem.onClick()
|
menuItem.onClick()
|
||||||
},
|
},
|
||||||
enabled = menuItem.isEnabled
|
enabled = menuItem.isEnabled,
|
||||||
|
modifier = Modifier.testTag(menuItem.testingTag)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ import com.adevinta.android.barista.interaction.BaristaDrawerInteractions.openDr
|
|||||||
import com.adevinta.android.barista.interaction.BaristaSleepInteractions
|
import com.adevinta.android.barista.interaction.BaristaSleepInteractions
|
||||||
import org.hamcrest.CoreMatchers.containsString
|
import org.hamcrest.CoreMatchers.containsString
|
||||||
import org.kiwix.kiwixmobile.core.R
|
import org.kiwix.kiwixmobile.core.R
|
||||||
|
import org.kiwix.kiwixmobile.core.page.SEARCH_ICON_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.search.SEARCH_FIELD_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.search.SEARCH_FIELD_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.core.search.SEARCH_ITEM_TESTING_TAG
|
import org.kiwix.kiwixmobile.core.search.SEARCH_ITEM_TESTING_TAG
|
||||||
import org.kiwix.kiwixmobile.custom.R.id
|
import org.kiwix.kiwixmobile.custom.R.id
|
||||||
@ -109,17 +110,18 @@ class SearchRobot {
|
|||||||
composeTestRule.onNodeWithTag(SEARCH_FIELD_TESTING_TAG).performTextClearance()
|
composeTestRule.onNodeWithTag(SEARCH_FIELD_TESTING_TAG).performTextClearance()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun openSearchScreen() {
|
private fun openSearchScreen(composeTestRule: ComposeContentTestRule) {
|
||||||
testFlakyView({
|
testFlakyView(
|
||||||
Espresso.onView(ViewMatchers.withId(R.id.menu_search))
|
{
|
||||||
.perform(ViewActions.click())
|
composeTestRule.onNodeWithTag(SEARCH_ICON_TESTING_TAG).performClick()
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun searchAndClickOnArticle(searchString: String, composeTestRule: ComposeContentTestRule) {
|
fun searchAndClickOnArticle(searchString: String, composeTestRule: ComposeContentTestRule) {
|
||||||
// wait a bit to properly load the ZIM file in the reader
|
// wait a bit to properly load the ZIM file in the reader
|
||||||
composeTestRule.waitUntilTimeout()
|
composeTestRule.waitUntilTimeout()
|
||||||
openSearchScreen()
|
openSearchScreen(composeTestRule)
|
||||||
// Wait a bit to properly visible the search screen.
|
// Wait a bit to properly visible the search screen.
|
||||||
composeTestRule.waitUntilTimeout()
|
composeTestRule.waitUntilTimeout()
|
||||||
searchWithFrequentlyTypedWords(searchString, composeTestRule = composeTestRule)
|
searchWithFrequentlyTypedWords(searchString, composeTestRule = composeTestRule)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user