Skip to content

Commit

Permalink
Fixed: The Delete icon is showing wrong content description on the no…
Browse files Browse the repository at this point in the history
…tes and history screen.

* Added correct description to delete button on HistoryFragment, and NotesFragment.
* Refactored the test case according to this new change.
* Sometimes actionOnItemAtPosition method gives an internal error, and does not perform the desired operation and fails the NoteFragmentTest. So we have moved it inside the testFlakyView method so that if there is any internal error occurs it retries this action.
  • Loading branch information
MohitMaliDeveloper committed May 8, 2024
1 parent c663059 commit 4a5033f
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 7 deletions.
14 changes: 8 additions & 6 deletions app/src/androidTest/java/org/kiwix/kiwixmobile/note/NoteRobot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ class NoteRobot : BaseRobot() {
}

fun clickOnSavedNote() {
onView(withId(R.id.recycler_view)).perform(
actionOnItemAtPosition<RecyclerView.ViewHolder>(
0,
click()
testFlakyView({
onView(withId(R.id.recycler_view)).perform(
actionOnItemAtPosition<RecyclerView.ViewHolder>(
0,
click()
)
)
)
})
}

fun clickOnOpenNote() {
Expand All @@ -114,7 +116,7 @@ class NoteRobot : BaseRobot() {
}

fun clickOnTrashIcon() {
clickOn(ContentDesc(R.string.pref_clear_all_bookmarks_title))
clickOn(ContentDesc(R.string.pref_clear_notes))
}

fun assertDeleteNoteDialogDisplayed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class HistoryRobot : BaseRobot() {
}

fun clickOnTrashIcon() {
clickOn(ContentDesc(R.string.pref_clear_all_bookmarks_title))
clickOn(ContentDesc(R.string.pref_clear_all_history_title))
}

fun assertDeleteHistoryDialogDisplayed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ abstract class PageFragment : OnItemClickListener, BaseFragment(), FragmentActiv
abstract val searchQueryHint: String
abstract val pageAdapter: PageAdapter
abstract val switchIsChecked: Boolean
abstract val deleteIconTitle: String
private var fragmentPageBinding: FragmentPageBinding? = null
override val fragmentToolbar: Toolbar? by lazy {
fragmentPageBinding?.root?.findViewById(R.id.toolbar)
Expand Down Expand Up @@ -116,6 +117,7 @@ abstract class PageFragment : OnItemClickListener, BaseFragment(), FragmentActiv
}
)
}
menu.findItem(R.id.menu_pages_clear).title = deleteIconTitle // Bug fix #3825
}

@Suppress("ReturnCount")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class BookmarksFragment : PageFragment() {
override val screenTitle: String by lazy { getString(R.string.bookmarks) }
override val noItemsString: String by lazy { getString(R.string.no_bookmarks) }
override val switchString: String by lazy { getString(R.string.bookmarks_from_current_book) }
override val deleteIconTitle: String by lazy {
getString(R.string.pref_clear_all_bookmarks_title)
}
override val switchIsChecked: Boolean by lazy { sharedPreferenceUtil.showBookmarksAllBooks }

override fun inject(baseActivity: BaseActivity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class HistoryFragment : PageFragment() {
override val noItemsString: String by lazy { getString(R.string.no_history) }
override val switchString: String by lazy { getString(R.string.history_from_current_book) }
override val screenTitle: String by lazy { getString(R.string.history) }
override val deleteIconTitle: String by lazy {
getString(R.string.pref_clear_all_history_title)
}
override val switchIsChecked: Boolean by lazy { sharedPreferenceUtil.showHistoryAllBooks }

override fun inject(baseActivity: BaseActivity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class NotesFragment : PageFragment() {

override val noItemsString: String by lazy { getString(R.string.no_notes) }
override val switchString: String by lazy { getString(R.string.notes_from_all_books) }
override val deleteIconTitle: String by lazy {
getString(R.string.pref_clear_notes)
}
override val switchIsChecked: Boolean by lazy { sharedPreferenceUtil.showNotesAllBooks }

override fun inject(baseActivity: BaseActivity) {
Expand Down
1 change: 1 addition & 0 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@
<string name="status" tools:keep="@string/status">Status</string>
<string name="pref_clear_all_notes_summary">Clears all notes on all articles</string>
<string name="pref_clear_all_notes_title">Clear all notes</string>
<string name="pref_clear_notes">Clear notes</string>
<string name="pref_allow_to_read_or_write_zim_files_on_sd_card">Allow to read and write ZIM files on SD card</string>
<string name="pref_text_zoom_summary">Change text size with 25\% increments.</string>
<string name="tag_pic">Pic</string>
Expand Down

0 comments on commit 4a5033f

Please sign in to comment.