Merge pull request #5866 from vector-im/feature/bma/fix_sanity_test

Fix sanity test
This commit is contained in:
Benoit Marty 2022-05-03 15:02:04 +02:00 committed by GitHub
commit 8dd87321da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 11 deletions

View File

@ -26,6 +26,7 @@ import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItem
import androidx.test.espresso.matcher.PreferenceMatchers.withKey
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
import androidx.test.espresso.matcher.ViewMatchers.isFocusable
import androidx.test.espresso.matcher.ViewMatchers.withClassName
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
@ -36,8 +37,15 @@ import org.hamcrest.Matchers.`is`
fun clickOnPreference(@StringRes textResId: Int) {
onView(withId(R.id.recycler_view))
.perform(actionOnItem<RecyclerView.ViewHolder>(
hasDescendant(withText(textResId)), click()))
.perform(
actionOnItem<RecyclerView.ViewHolder>(
allOf(
hasDescendant(withText(textResId)),
// Avoid to click on the Preference Category
isFocusable()
), click()
)
)
}
fun clickOnSwitchPreference(preferenceKey: String) {

View File

@ -56,10 +56,8 @@ class RoomDetailRobot {
// Menu
openMenu()
pressBack()
/* TODO something has changed in the menu :/
clickMenu(R.id.voice_call)
pressBack()
*/
clickMenu(R.id.video_call)
pressBack()
}

View File

@ -18,7 +18,6 @@ package im.vector.app.ui.robot.settings
import androidx.test.espresso.Espresso
import im.vector.app.R
import im.vector.app.clickOnAndGoBack
import im.vector.app.espresso.tools.clickOnPreference
class SettingsSecurityRobot {
@ -38,10 +37,7 @@ class SettingsSecurityRobot {
clickOnPreference(R.string.settings_opt_in_of_analytics)
Espresso.pressBack()
ignoredUsers()
}
private fun ignoredUsers(block: () -> Unit = {}) {
clickOnAndGoBack(R.string.settings_ignored_users) { block() }
clickOnPreference(R.string.settings_ignored_users)
Espresso.pressBack()
}
}

View File

@ -87,7 +87,12 @@ data class RoomDetailViewState(
rootThreadEventId = args.threadTimelineArgs?.rootThreadEventId
)
fun isCallOptionAvailable() = asyncRoomSummary.invoke()?.isDirect ?: true
fun isCallOptionAvailable(): Boolean {
return asyncRoomSummary.invoke()?.isDirect ?: true ||
// When there is only one member, a warning will be displayed when the user
// clicks on the menu item to start a call
asyncRoomSummary.invoke()?.joinedMembersCount == 1
}
fun isSearchAvailable() = asyncRoomSummary()?.isEncrypted == false