mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
using robot pattern to navigate the settings
- will allow reuse of navigating around the app (eg enabling develop options and go back to previous locations)
This commit is contained in:
parent
ed4f26de81
commit
2f3716d9b9
3 changed files with 124 additions and 39 deletions
|
@ -37,7 +37,6 @@ import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn
|
|||
import com.adevinta.android.barista.interaction.BaristaClickInteractions.longClickOn
|
||||
import com.adevinta.android.barista.interaction.BaristaDialogInteractions.clickDialogNegativeButton
|
||||
import com.adevinta.android.barista.interaction.BaristaDialogInteractions.clickDialogPositiveButton
|
||||
import com.adevinta.android.barista.interaction.BaristaDrawerInteractions.openDrawer
|
||||
import com.adevinta.android.barista.interaction.BaristaEditTextInteractions.writeTo
|
||||
import com.adevinta.android.barista.interaction.BaristaListInteractions.clickListItem
|
||||
import com.adevinta.android.barista.interaction.BaristaListInteractions.clickListItemChild
|
||||
|
@ -57,6 +56,7 @@ import im.vector.app.features.home.room.detail.RoomDetailActivity
|
|||
import im.vector.app.features.login.LoginActivity
|
||||
import im.vector.app.features.roomdirectory.RoomDirectoryActivity
|
||||
import im.vector.app.initialSyncIdlingResource
|
||||
import im.vector.app.ui.robot.ElementRobot
|
||||
import im.vector.app.waitForView
|
||||
import im.vector.app.withIdlingResource
|
||||
import org.junit.Rule
|
||||
|
@ -76,6 +76,7 @@ class UiAllScreensSanityTest {
|
|||
val activityRule = ActivityScenarioRule(MainActivity::class.java)
|
||||
|
||||
private val uiTestBase = UiTestBase()
|
||||
private val appRobot = ElementRobot()
|
||||
|
||||
// Last passing:
|
||||
// 2020-11-09
|
||||
|
@ -368,44 +369,17 @@ class UiAllScreensSanityTest {
|
|||
}
|
||||
|
||||
private fun navigateToSettings() {
|
||||
// clickOn(R.id.groupToolbarAvatarImageView)
|
||||
openDrawer()
|
||||
clickOn(R.id.homeDrawerHeaderSettingsView)
|
||||
|
||||
clickOn(R.string.settings_general_title)
|
||||
navigateToSettingsGeneral()
|
||||
pressBack()
|
||||
|
||||
clickOn(R.string.settings_notifications)
|
||||
navigateToSettingsNotifications()
|
||||
pressBack()
|
||||
|
||||
clickOn(R.string.settings_preferences)
|
||||
navigateToSettingsPreferences()
|
||||
pressBack()
|
||||
|
||||
clickOn(R.string.preference_voice_and_video)
|
||||
pressBack()
|
||||
|
||||
clickOn(R.string.settings_ignored_users)
|
||||
pressBack()
|
||||
|
||||
clickOn(R.string.settings_security_and_privacy)
|
||||
navigateToSettingsSecurity()
|
||||
pressBack()
|
||||
|
||||
clickOn(R.string.room_settings_labs_pref_title)
|
||||
pressBack()
|
||||
|
||||
clickOn(R.string.settings_advanced_settings)
|
||||
navigateToSettingsAdvanced()
|
||||
pressBack()
|
||||
|
||||
clickOn(R.string.preference_root_help_about)
|
||||
navigateToSettingsHelp()
|
||||
pressBack()
|
||||
|
||||
pressBack()
|
||||
appRobot.openSettings {
|
||||
openGeneral { navigateToSettingsGeneral() }
|
||||
openNotifications { navigateToSettingsNotifications() }
|
||||
openPreferences { navigateToSettingsPreferences() }
|
||||
openVoiceAndVideo {}
|
||||
openIgnoredUsers {}
|
||||
openSecurityAndPrivacy { navigateToSettingsSecurity() }
|
||||
openLabs { }
|
||||
openAdvancedSettings { navigateToSettingsAdvanced() }
|
||||
openHelpAbout { navigateToSettingsHelp() }
|
||||
}
|
||||
}
|
||||
|
||||
private fun navigateToSettingsHelp() {
|
||||
|
@ -521,3 +495,4 @@ class UiAllScreensSanityTest {
|
|||
pressBack()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2021 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.ui.robot
|
||||
|
||||
import androidx.test.espresso.Espresso
|
||||
import com.adevinta.android.barista.interaction.BaristaClickInteractions
|
||||
import com.adevinta.android.barista.interaction.BaristaDrawerInteractions
|
||||
import im.vector.app.R
|
||||
|
||||
class ElementRobot {
|
||||
|
||||
fun openSettings(block: SettingsRobot.() -> Unit) {
|
||||
BaristaDrawerInteractions.openDrawer()
|
||||
BaristaClickInteractions.clickOn(R.id.homeDrawerHeaderSettingsView)
|
||||
block(SettingsRobot())
|
||||
Espresso.pressBack()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (c) 2021 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.ui.robot
|
||||
|
||||
import androidx.test.espresso.Espresso
|
||||
import com.adevinta.android.barista.interaction.BaristaClickInteractions
|
||||
import im.vector.app.R
|
||||
|
||||
class SettingsRobot {
|
||||
|
||||
fun openGeneral(block: () -> Unit) {
|
||||
BaristaClickInteractions.clickOn(R.string.settings_general_title)
|
||||
block()
|
||||
Espresso.pressBack()
|
||||
}
|
||||
|
||||
fun openNotifications(block: () -> Unit) {
|
||||
BaristaClickInteractions.clickOn(R.string.settings_notifications)
|
||||
block()
|
||||
Espresso.pressBack()
|
||||
}
|
||||
|
||||
fun openPreferences(block: () -> Unit) {
|
||||
BaristaClickInteractions.clickOn(R.string.settings_preferences)
|
||||
block()
|
||||
Espresso.pressBack()
|
||||
}
|
||||
|
||||
fun openVoiceAndVideo(block: () -> Unit) {
|
||||
BaristaClickInteractions.clickOn(R.string.preference_voice_and_video)
|
||||
block()
|
||||
Espresso.pressBack()
|
||||
}
|
||||
|
||||
fun openIgnoredUsers(block: () -> Unit) {
|
||||
BaristaClickInteractions.clickOn(R.string.settings_ignored_users)
|
||||
block()
|
||||
Espresso.pressBack()
|
||||
}
|
||||
|
||||
fun openSecurityAndPrivacy(block: () -> Unit) {
|
||||
BaristaClickInteractions.clickOn(R.string.settings_security_and_privacy)
|
||||
block()
|
||||
Espresso.pressBack()
|
||||
}
|
||||
|
||||
fun openLabs(block: () -> Unit) {
|
||||
BaristaClickInteractions.clickOn(R.string.room_settings_labs_pref_title)
|
||||
block()
|
||||
Espresso.pressBack()
|
||||
}
|
||||
|
||||
fun openAdvancedSettings(block: () -> Unit) {
|
||||
BaristaClickInteractions.clickOn(R.string.settings_advanced_settings)
|
||||
block()
|
||||
Espresso.pressBack()
|
||||
}
|
||||
|
||||
fun openHelpAbout(block: () -> Unit) {
|
||||
BaristaClickInteractions.clickOn(R.string.preference_root_help_about)
|
||||
block()
|
||||
Espresso.pressBack()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue