How to use isNotChecked method of android.support.test.espresso.matcher.ViewMatchers class

Best Appium-espresso-driver code snippet using android.support.test.espresso.matcher.ViewMatchers.isNotChecked

FileDetailSharingFragmentIT.kt

Source:FileDetailSharingFragmentIT.kt Github

copy

Full Screen

...30import androidx.test.espresso.intent.rule.IntentsTestRule31import androidx.test.espresso.matcher.ViewMatchers32import androidx.test.espresso.matcher.ViewMatchers.isChecked33import androidx.test.espresso.matcher.ViewMatchers.isDisplayed34import androidx.test.espresso.matcher.ViewMatchers.isNotChecked35import androidx.test.espresso.matcher.ViewMatchers.withText36import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultBaseUtils.matchesCheckNames37import com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckResultUtils.matchesViews38import com.google.android.material.floatingactionbutton.FloatingActionButton39import com.nextcloud.client.RetryTestRule40import com.nextcloud.client.TestActivity41import com.owncloud.android.AbstractIT42import com.owncloud.android.R43import com.owncloud.android.datamodel.OCFile44import com.owncloud.android.lib.resources.shares.OCShare45import com.owncloud.android.lib.resources.shares.OCShare.CREATE_PERMISSION_FLAG46import com.owncloud.android.lib.resources.shares.OCShare.DELETE_PERMISSION_FLAG47import com.owncloud.android.lib.resources.shares.OCShare.MAXIMUM_PERMISSIONS_FOR_FILE48import com.owncloud.android.lib.resources.shares.OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER49import com.owncloud.android.lib.resources.shares.OCShare.NO_PERMISSION50import com.owncloud.android.lib.resources.shares.OCShare.READ_PERMISSION_FLAG51import com.owncloud.android.lib.resources.shares.OCShare.SHARE_PERMISSION_FLAG52import com.owncloud.android.lib.resources.shares.ShareType53import com.owncloud.android.ui.activity.FileDisplayActivity54import com.owncloud.android.ui.fragment.util.SharingMenuHelper55import com.owncloud.android.utils.ScreenshotTest56import org.hamcrest.CoreMatchers.`is`57import org.hamcrest.CoreMatchers.allOf58import org.hamcrest.CoreMatchers.anyOf59import org.hamcrest.CoreMatchers.not60import org.junit.After61import org.junit.Assert.assertFalse62import org.junit.Assert.assertTrue63import org.junit.Before64import org.junit.Rule65import org.junit.Test66@Suppress("TooManyFunctions")67class FileDetailSharingFragmentIT : AbstractIT() {68 @get:Rule69 val testActivityRule = IntentsTestRule(TestActivity::class.java, true, false)70 @get:Rule71 val retryRule = RetryTestRule()72 lateinit var file: OCFile73 lateinit var folder: OCFile74 lateinit var activity: TestActivity75 @Before76 fun before() {77 activity = testActivityRule.launchActivity(null)78 file = OCFile("/test.md").apply {79 remoteId = "00000001"80 parentId = activity.storageManager.getFileByEncryptedRemotePath("/").fileId81 permissions = OCFile.PERMISSION_CAN_RESHARE82 }83 folder = OCFile("/test").apply {84 setFolder()85 parentId = activity.storageManager.getFileByEncryptedRemotePath("/").fileId86 permissions = OCFile.PERMISSION_CAN_RESHARE87 }88 }89 @Test90 @ScreenshotTest91 fun listSharesFileNone() {92 show(file)93 }94 @Test95 @ScreenshotTest96 fun listSharesFileResharingNotAllowed() {97 file.permissions = ""98 show(file)99 }100 @Test101 @ScreenshotTest102 @Suppress("MagicNumber")103 /**104 * Use same values as {@link OCFileListFragmentStaticServerIT showSharedFiles }105 */106 fun listSharesFileAllShareTypes() {107 OCShare(file.decryptedRemotePath).apply {108 remoteId = 1109 shareType = ShareType.USER110 sharedWithDisplayName = "Admin"111 permissions = MAXIMUM_PERMISSIONS_FOR_FILE112 userId = getUserId(user)113 activity.storageManager.saveShare(this)114 }115 OCShare(file.decryptedRemotePath).apply {116 remoteId = 2117 shareType = ShareType.GROUP118 sharedWithDisplayName = "Group"119 permissions = MAXIMUM_PERMISSIONS_FOR_FILE120 userId = getUserId(user)121 activity.storageManager.saveShare(this)122 }123 OCShare(file.decryptedRemotePath).apply {124 remoteId = 3125 shareType = ShareType.EMAIL126 sharedWithDisplayName = "admin@nextcloud.localhost"127 userId = getUserId(user)128 activity.storageManager.saveShare(this)129 }130 OCShare(file.decryptedRemotePath).apply {131 remoteId = 4132 shareType = ShareType.PUBLIC_LINK133 label = "Customer"134 activity.storageManager.saveShare(this)135 }136 OCShare(file.decryptedRemotePath).apply {137 remoteId = 5138 shareType = ShareType.PUBLIC_LINK139 label = "Colleagues"140 activity.storageManager.saveShare(this)141 }142 OCShare(file.decryptedRemotePath).apply {143 remoteId = 6144 shareType = ShareType.FEDERATED145 sharedWithDisplayName = "admin@nextcloud.localhost"146 permissions = OCShare.FEDERATED_PERMISSIONS_FOR_FILE147 userId = getUserId(user)148 activity.storageManager.saveShare(this)149 }150 OCShare(file.decryptedRemotePath).apply {151 remoteId = 7152 shareType = ShareType.CIRCLE153 sharedWithDisplayName = "Personal circle"154 permissions = SHARE_PERMISSION_FLAG155 userId = getUserId(user)156 activity.storageManager.saveShare(this)157 }158 OCShare(file.decryptedRemotePath).apply {159 remoteId = 8160 shareType = ShareType.CIRCLE161 sharedWithDisplayName = "Public circle"162 permissions = SHARE_PERMISSION_FLAG163 userId = getUserId(user)164 activity.storageManager.saveShare(this)165 }166 OCShare(file.decryptedRemotePath).apply {167 remoteId = 9168 shareType = ShareType.CIRCLE169 sharedWithDisplayName = "Closed circle"170 permissions = SHARE_PERMISSION_FLAG171 userId = getUserId(user)172 activity.storageManager.saveShare(this)173 }174 OCShare(file.decryptedRemotePath).apply {175 remoteId = 10176 shareType = ShareType.CIRCLE177 sharedWithDisplayName = "Secret circle"178 permissions = SHARE_PERMISSION_FLAG179 userId = getUserId(user)180 activity.storageManager.saveShare(this)181 }182 OCShare(file.decryptedRemotePath).apply {183 remoteId = 11184 shareType = ShareType.ROOM185 sharedWithDisplayName = "Admin"186 permissions = SHARE_PERMISSION_FLAG187 userId = getUserId(user)188 activity.storageManager.saveShare(this)189 }190 OCShare(file.decryptedRemotePath).apply {191 remoteId = 12192 shareType = ShareType.ROOM193 sharedWithDisplayName = "Meeting"194 permissions = SHARE_PERMISSION_FLAG195 userId = getUserId(user)196 activity.storageManager.saveShare(this)197 }198 show(file)199 }200 private fun show(file: OCFile) {201 val fragment = FileDetailSharingFragment.newInstance(file, user)202 activity.addFragment(fragment)203 waitForIdleSync()204 screenshot(activity)205 }206 @Test207 @Suppress("MagicNumber")208 // public link and email are handled the same way209 // for advanced permissions210 fun publicLinkOptionMenuFolderAdvancePermission() {211 val sut = FileDetailSharingFragment.newInstance(file, user)212 activity.addFragment(sut)213 setupSecondaryFragment()214 shortSleep()215 sut.refreshCapabilitiesFromDB()216 val publicShare = OCShare().apply {217 isFolder = true218 shareType = ShareType.PUBLIC_LINK219 permissions = 17220 }221 activity.runOnUiThread { sut.showSharingMenuActionSheet(publicShare) }222 shortSleep()223 waitForIdleSync()224 // check if items are visible225 onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).check(matches(isDisplayed()))226 onView(ViewMatchers.withId(R.id.menu_share_send_new_email)).check(matches(isDisplayed()))227 onView(ViewMatchers.withId(R.id.menu_share_send_link)).check(matches(isDisplayed()))228 onView(ViewMatchers.withId(R.id.menu_share_unshare)).check(matches(isDisplayed()))229 onView(ViewMatchers.withId(R.id.menu_share_add_another_link)).check(matches(isDisplayed()))230 // click event231 onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).perform(ViewActions.click())232 // validate view shown on screen233 onView(ViewMatchers.withId(R.id.share_process_permission_read_only)).check(matches(isDisplayed()))234 onView(ViewMatchers.withId(R.id.share_process_permission_upload_editing)).check(matches(isDisplayed()))235 onView(ViewMatchers.withId(R.id.share_process_permission_file_drop)).check(matches(isDisplayed()))236 onView(ViewMatchers.withId(R.id.share_process_hide_download_checkbox)).check(matches(isDisplayed()))237 onView(ViewMatchers.withId(R.id.share_process_set_password_switch)).check(matches(isDisplayed()))238 onView(ViewMatchers.withId(R.id.share_process_change_name_switch)).check(matches(isDisplayed()))239 onView(ViewMatchers.withId(R.id.share_process_allow_resharing_checkbox)).check(matches(not(isDisplayed())))240 // read-only241 onView(ViewMatchers.withId(R.id.share_process_permission_read_only)).check(matches(isChecked()))242 onView(ViewMatchers.withId(R.id.share_process_permission_upload_editing)).check(matches(isNotChecked()))243 onView(ViewMatchers.withId(R.id.share_process_permission_file_drop)).check(matches(isNotChecked()))244 goBack()245 // upload and editing246 publicShare.permissions = MAXIMUM_PERMISSIONS_FOR_FOLDER247 openAdvancedPermissions(sut, publicShare)248 onView(ViewMatchers.withId(R.id.share_process_permission_read_only)).check(matches(isNotChecked()))249 onView(ViewMatchers.withId(R.id.share_process_permission_upload_editing)).check(matches(isChecked()))250 onView(ViewMatchers.withId(R.id.share_process_permission_file_drop)).check(matches(isNotChecked()))251 goBack()252 // file drop253 publicShare.permissions = 4254 openAdvancedPermissions(sut, publicShare)255 onView(ViewMatchers.withId(R.id.share_process_permission_read_only)).check(matches(isNotChecked()))256 onView(ViewMatchers.withId(R.id.share_process_permission_upload_editing)).check(matches(isNotChecked()))257 onView(ViewMatchers.withId(R.id.share_process_permission_file_drop)).check(matches(isChecked()))258 goBack()259 // password protection260 publicShare.shareWith = "someValue"261 openAdvancedPermissions(sut, publicShare)262 onView(ViewMatchers.withId(R.id.share_process_set_password_switch)).check(matches(isChecked()))263 goBack()264 publicShare.shareWith = ""265 openAdvancedPermissions(sut, publicShare)266 onView(ViewMatchers.withId(R.id.share_process_set_password_switch)).check(matches(isNotChecked()))267 goBack()268 // hide download269 publicShare.isHideFileDownload = true270 publicShare.permissions = MAXIMUM_PERMISSIONS_FOR_FOLDER271 openAdvancedPermissions(sut, publicShare)272 onView(ViewMatchers.withId(R.id.share_process_hide_download_checkbox)).check(matches(isChecked()))273 goBack()274 publicShare.isHideFileDownload = false275 openAdvancedPermissions(sut, publicShare)276 onView(ViewMatchers.withId(R.id.share_process_hide_download_checkbox)).check(matches(isNotChecked()))277 goBack()278 publicShare.expirationDate = 1582019340000279 openAdvancedPermissions(sut, publicShare)280 onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isChecked()))281 onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(not(withText(""))))282 goBack()283 publicShare.expirationDate = 0284 openAdvancedPermissions(sut, publicShare)285 onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isNotChecked()))286 onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(withText("")))287 }288 @Test289 @Suppress("MagicNumber")290 // public link and email are handled the same way291 // for send new email292 fun publicLinkOptionMenuFolderSendNewEmail() {293 val sut = FileDetailSharingFragment.newInstance(file, user)294 activity.addFragment(sut)295 setupSecondaryFragment()296 shortSleep()297 sut.refreshCapabilitiesFromDB()298 val publicShare = OCShare().apply {299 isFolder = true300 shareType = ShareType.PUBLIC_LINK301 permissions = 17302 }303 verifySendNewEmail(sut, publicShare)304 }305 private fun setupSecondaryFragment() {306 val secondary = FileDetailFragment.newInstance(file, user)307 activity.addSecondaryFragment(secondary, FileDisplayActivity.TAG_LIST_OF_FILES)308 activity.addView(309 FloatingActionButton(activity).apply { // needed for some reason310 visibility = View.GONE311 id = R.id.fab_main312 }313 )314 }315 @Test316 @Suppress("MagicNumber")317 // public link and email are handled the same way318 // for advanced permissions319 fun publicLinkOptionMenuFileAdvancePermission() {320 val sut = FileDetailSharingFragment.newInstance(file, user)321 activity.addFragment(sut)322 setupSecondaryFragment()323 shortSleep()324 sut.refreshCapabilitiesFromDB()325 val publicShare = OCShare().apply {326 isFolder = false327 shareType = ShareType.PUBLIC_LINK328 permissions = 17329 }330 activity.handler.post { sut.showSharingMenuActionSheet(publicShare) }331 waitForIdleSync()332 // check if items are visible333 onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).check(matches(isDisplayed()))334 onView(ViewMatchers.withId(R.id.menu_share_send_new_email)).check(matches(isDisplayed()))335 onView(ViewMatchers.withId(R.id.menu_share_send_link)).check(matches(isDisplayed()))336 onView(ViewMatchers.withId(R.id.menu_share_unshare)).check(matches(isDisplayed()))337 onView(ViewMatchers.withId(R.id.menu_share_add_another_link)).check(matches(isDisplayed()))338 // click event339 onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).perform(ViewActions.click())340 // validate view shown on screen341 onView(ViewMatchers.withId(R.id.share_process_permission_read_only)).check(matches(isDisplayed()))342 onView(ViewMatchers.withId(R.id.share_process_permission_upload_editing)).check(matches(isDisplayed()))343 onView(ViewMatchers.withId(R.id.share_process_permission_file_drop)).check(matches(not(isDisplayed())))344 onView(ViewMatchers.withId(R.id.share_process_hide_download_checkbox)).check(matches(isDisplayed()))345 onView(ViewMatchers.withId(R.id.share_process_set_password_switch)).check(matches(isDisplayed()))346 onView(ViewMatchers.withId(R.id.share_process_change_name_switch)).check(matches(isDisplayed()))347 onView(ViewMatchers.withId(R.id.share_process_allow_resharing_checkbox)).check(matches(not(isDisplayed())))348 // read-only349 publicShare.permissions = 17 // from server350 onView(ViewMatchers.withId(R.id.share_process_permission_read_only)).check(matches(isChecked()))351 onView(ViewMatchers.withId(R.id.share_process_permission_upload_editing)).check(matches(isNotChecked()))352 goBack()353 // editing354 publicShare.permissions = MAXIMUM_PERMISSIONS_FOR_FILE // from server355 openAdvancedPermissions(sut, publicShare)356 onView(ViewMatchers.withId(R.id.share_process_permission_read_only)).check(matches(isNotChecked()))357 onView(ViewMatchers.withId(R.id.share_process_permission_upload_editing)).check(matches(isChecked()))358 goBack()359 // hide download360 publicShare.isHideFileDownload = true361 openAdvancedPermissions(sut, publicShare)362 onView(ViewMatchers.withId(R.id.share_process_hide_download_checkbox)).check(matches(isChecked()))363 goBack()364 publicShare.isHideFileDownload = false365 openAdvancedPermissions(sut, publicShare)366 onView(ViewMatchers.withId(R.id.share_process_hide_download_checkbox)).check(matches(isNotChecked()))367 goBack()368 // password protection369 publicShare.isPasswordProtected = true370 publicShare.shareWith = "someValue"371 openAdvancedPermissions(sut, publicShare)372 onView(ViewMatchers.withId(R.id.share_process_set_password_switch)).check(matches(isChecked()))373 goBack()374 publicShare.isPasswordProtected = false375 publicShare.shareWith = ""376 openAdvancedPermissions(sut, publicShare)377 onView(ViewMatchers.withId(R.id.share_process_set_password_switch)).check(matches(isNotChecked()))378 goBack()379 // expires380 publicShare.expirationDate = 1582019340381 openAdvancedPermissions(sut, publicShare)382 onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isChecked()))383 onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(not(withText(""))))384 goBack()385 publicShare.expirationDate = 0386 openAdvancedPermissions(sut, publicShare)387 onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isNotChecked()))388 onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(withText("")))389 }390 @Test391 @Suppress("MagicNumber")392 // public link and email are handled the same way393 // for send new email394 fun publicLinkOptionMenuFileSendNewEmail() {395 val sut = FileDetailSharingFragment.newInstance(file, user)396 activity.addFragment(sut)397 setupSecondaryFragment()398 shortSleep()399 sut.refreshCapabilitiesFromDB()400 val publicShare = OCShare().apply {401 isFolder = false402 shareType = ShareType.PUBLIC_LINK403 permissions = 17404 }405 verifySendNewEmail(sut, publicShare)406 }407 @Test408 @Suppress("MagicNumber")409 // also applies for410 // group411 // conversation412 // circle413 // federated share414 // for advanced permissions415 fun userOptionMenuFileAdvancePermission() {416 val sut = FileDetailSharingFragment.newInstance(file, user)417 suppressFDFAccessibilityChecks()418 activity.addFragment(sut)419 setupSecondaryFragment()420 shortSleep()421 sut.refreshCapabilitiesFromDB()422 val userShare = OCShare().apply {423 isFolder = false424 shareType = ShareType.USER425 permissions = 17426 }427 activity.runOnUiThread { sut.showSharingMenuActionSheet(userShare) }428 shortSleep()429 waitForIdleSync()430 // check if items are visible431 onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).check(matches(isDisplayed()))432 onView(ViewMatchers.withId(R.id.menu_share_send_new_email)).check(matches(isDisplayed()))433 onView(ViewMatchers.withId(R.id.menu_share_send_link)).check(matches(not(isDisplayed())))434 onView(ViewMatchers.withId(R.id.menu_share_unshare)).check(matches(isDisplayed()))435 onView(ViewMatchers.withId(R.id.menu_share_add_another_link)).check(matches(not(isDisplayed())))436 // click event437 onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).perform(ViewActions.click())438 shortSleep()439 waitForIdleSync()440 // validate view shown on screen441 onView(ViewMatchers.withId(R.id.share_process_permission_read_only)).check(matches(isDisplayed()))442 onView(ViewMatchers.withId(R.id.share_process_permission_upload_editing)).check(matches(isDisplayed()))443 onView(ViewMatchers.withId(R.id.share_process_permission_file_drop)).check(matches(not(isDisplayed())))444 onView(ViewMatchers.withId(R.id.share_process_hide_download_checkbox)).check(matches(not(isDisplayed())))445 onView(ViewMatchers.withId(R.id.share_process_set_password_switch)).check(matches(not(isDisplayed())))446 onView(ViewMatchers.withId(R.id.share_process_change_name_switch)).check(matches(not(isDisplayed())))447 onView(ViewMatchers.withId(R.id.share_process_allow_resharing_checkbox)).check(matches(isDisplayed()))448 // read-only449 userShare.permissions = 17 // from server450 onView(ViewMatchers.withId(R.id.share_process_permission_read_only)).check(matches(isChecked()))451 onView(ViewMatchers.withId(R.id.share_process_permission_upload_editing)).check(matches(isNotChecked()))452 goBack()453 // editing454 userShare.permissions = MAXIMUM_PERMISSIONS_FOR_FILE // from server455 openAdvancedPermissions(sut, userShare)456 onView(ViewMatchers.withId(R.id.share_process_permission_read_only)).check(matches(isNotChecked()))457 onView(ViewMatchers.withId(R.id.share_process_permission_upload_editing)).check(matches(isChecked()))458 goBack()459 // allow reshare460 userShare.permissions = 1 // from server461 openAdvancedPermissions(sut, userShare)462 onView(ViewMatchers.withId(R.id.share_process_allow_resharing_checkbox)).check(matches(isNotChecked()))463 goBack()464 userShare.permissions = 17 // from server465 openAdvancedPermissions(sut, userShare)466 onView(ViewMatchers.withId(R.id.share_process_allow_resharing_checkbox)).check(matches(isChecked()))467 goBack()468 // set expiration date469 userShare.expirationDate = 1582019340000470 openAdvancedPermissions(sut, userShare)471 onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isChecked()))472 onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(not(withText(""))))473 goBack()474 userShare.expirationDate = 0475 openAdvancedPermissions(sut, userShare)476 onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isNotChecked()))477 onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(withText("")))478 }479 private fun suppressFDFAccessibilityChecks() {480 AccessibilityChecks.enable().apply {481 setSuppressingResultMatcher(482 allOf(483 anyOf(484 matchesCheckNames(`is`("TouchTargetSizeCheck")),485 matchesCheckNames(`is`("SpeakableTextPresentCheck")),486 ),487 anyOf(488 matchesViews(ViewMatchers.withId(R.id.favorite)),489 matchesViews(ViewMatchers.withId(R.id.last_modification_timestamp))490 )491 )492 )493 }494 }495 @Test496 @Suppress("MagicNumber")497 // also applies for498 // group499 // conversation500 // circle501 // federated share502 // for send new email503 fun userOptionMenuFileSendNewEmail() {504 val sut = FileDetailSharingFragment.newInstance(file, user)505 activity.addFragment(sut)506 setupSecondaryFragment()507 shortSleep()508 sut.refreshCapabilitiesFromDB()509 val userShare = OCShare().apply {510 isFolder = false511 shareType = ShareType.USER512 permissions = 17513 }514 verifySendNewEmail(sut, userShare)515 }516 @Test517 @Suppress("MagicNumber")518 // also applies for519 // group520 // conversation521 // circle522 // federated share523 // for advanced permissions524 fun userOptionMenuFolderAdvancePermission() {525 val sut = FileDetailSharingFragment.newInstance(file, user)526 activity.addFragment(sut)527 setupSecondaryFragment()528 suppressFDFAccessibilityChecks()529 shortSleep()530 sut.refreshCapabilitiesFromDB()531 val userShare = OCShare().apply {532 isFolder = true533 shareType = ShareType.USER534 permissions = 17535 }536 activity.runOnUiThread { sut.showSharingMenuActionSheet(userShare) }537 shortSleep()538 waitForIdleSync()539 // check if items are visible540 onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).check(matches(isDisplayed()))541 onView(ViewMatchers.withId(R.id.menu_share_send_new_email)).check(matches(isDisplayed()))542 onView(ViewMatchers.withId(R.id.menu_share_send_link)).check(matches(not(isDisplayed())))543 onView(ViewMatchers.withId(R.id.menu_share_unshare)).check(matches(isDisplayed()))544 onView(ViewMatchers.withId(R.id.menu_share_add_another_link)).check(matches(not(isDisplayed())))545 // click event546 onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).perform(ViewActions.click())547 // validate view shown on screen548 onView(ViewMatchers.withId(R.id.share_process_permission_read_only)).check(matches(isDisplayed()))549 onView(ViewMatchers.withId(R.id.share_process_permission_upload_editing)).check(matches(isDisplayed()))550 onView(ViewMatchers.withId(R.id.share_process_permission_file_drop)).check(matches(isDisplayed()))551 onView(ViewMatchers.withId(R.id.share_process_hide_download_checkbox)).check(matches(not(isDisplayed())))552 onView(ViewMatchers.withId(R.id.share_process_set_password_switch)).check(matches(not(isDisplayed())))553 onView(ViewMatchers.withId(R.id.share_process_change_name_switch)).check(matches(not(isDisplayed())))554 onView(ViewMatchers.withId(R.id.share_process_allow_resharing_checkbox)).check(matches(isDisplayed()))555 // read-only556 userShare.permissions = 17 // from server557 onView(ViewMatchers.withId(R.id.share_process_permission_read_only)).check(matches(isChecked()))558 onView(ViewMatchers.withId(R.id.share_process_permission_upload_editing)).check(matches(isNotChecked()))559 onView(ViewMatchers.withId(R.id.share_process_permission_file_drop)).check(matches(isNotChecked()))560 goBack()561 // allow upload & editing562 userShare.permissions = MAXIMUM_PERMISSIONS_FOR_FOLDER // from server563 openAdvancedPermissions(sut, userShare)564 onView(ViewMatchers.withId(R.id.share_process_permission_read_only)).check(matches(isNotChecked()))565 onView(ViewMatchers.withId(R.id.share_process_permission_upload_editing)).check(matches(isChecked()))566 onView(ViewMatchers.withId(R.id.share_process_permission_file_drop)).check(matches(isNotChecked()))567 goBack()568 // file drop569 userShare.permissions = 4570 openAdvancedPermissions(sut, userShare)571 onView(ViewMatchers.withId(R.id.share_process_permission_read_only)).check(matches(isNotChecked()))572 onView(ViewMatchers.withId(R.id.share_process_permission_upload_editing)).check(matches(isNotChecked()))573 onView(ViewMatchers.withId(R.id.share_process_permission_file_drop)).check(matches(isChecked()))574 goBack()575 // allow reshare576 userShare.permissions = 1 // from server577 openAdvancedPermissions(sut, userShare)578 onView(ViewMatchers.withId(R.id.share_process_allow_resharing_checkbox)).check(matches(isNotChecked()))579 goBack()580 userShare.permissions = 17 // from server581 openAdvancedPermissions(sut, userShare)582 onView(ViewMatchers.withId(R.id.share_process_allow_resharing_checkbox)).check(matches(isChecked()))583 goBack()584 // set expiration date585 userShare.expirationDate = 1582019340000586 openAdvancedPermissions(sut, userShare)587 onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isChecked()))588 onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(not(withText(""))))589 goBack()590 userShare.expirationDate = 0591 openAdvancedPermissions(sut, userShare)592 onView(ViewMatchers.withId(R.id.share_process_set_exp_date_switch)).check(matches(isNotChecked()))593 onView(ViewMatchers.withId(R.id.share_process_select_exp_date)).check(matches(withText("")))594 }595 // open bottom sheet with actions596 private fun openAdvancedPermissions(597 sut: FileDetailSharingFragment,598 userShare: OCShare599 ) {600 activity.handler.post {601 sut.showSharingMenuActionSheet(userShare)602 }603 shortSleep()604 waitForIdleSync()605 onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).perform(ViewActions.click())606 }...

Full Screen

Full Screen

DialogFragmentWithThreeButtonsTest.kt

Source:DialogFragmentWithThreeButtonsTest.kt Github

copy

Full Screen

...32 Intents.init()33 // Perform view actions.34 Espresso.onView(Matchers.allOf(35 ViewMatchers.withId(R.id.switchCompat),36 ViewMatchers.isNotChecked(),37 ViewMatchers.withParent(ViewMatchers.withId(R.id.layout_item_negative))38 )).perform(ViewActions.click())39 Espresso.onView(Matchers.allOf(40 ViewMatchers.withId(R.id.switchCompat),41 ViewMatchers.isNotChecked(),42 ViewMatchers.withParent(ViewMatchers.withId(R.id.layout_item_neutral))43 )).perform(ViewActions.click())44 Espresso.onView(Matchers.allOf(45 ViewMatchers.withId(R.id.switchCompat),46 ViewMatchers.isNotChecked(),47 ViewMatchers.withParent(ViewMatchers.withId(R.id.layout_item_cancelable))48 )).perform(ViewActions.click())49 Espresso.onView(Matchers.allOf(50 ViewMatchers.withId(R.id.switchCompat),51 ViewMatchers.isNotChecked(),52 ViewMatchers.withParent(ViewMatchers.withId(R.id.layout_item_callback))53 )).perform(ViewActions.click())54 Espresso.onView(Matchers.allOf(55 ViewMatchers.withId(R.id.editText),56 ViewMatchers.withParent(ViewMatchers.withId(R.id.layout_item_title))57 )).perform(ViewActions.typeText("Submit forms."), ViewActions.closeSoftKeyboard())58 Espresso.onView(Matchers.allOf(59 ViewMatchers.withId(R.id.editText),60 ViewMatchers.withParent(ViewMatchers.withId(R.id.layout_item_message))61 )).perform(ViewActions.typeText("Are you sure to submit this forms?"), ViewActions.closeSoftKeyboard())62 Espresso.onView(Matchers.allOf(63 ViewMatchers.withId(R.id.editText),64 ViewMatchers.withParent(ViewMatchers.withId(R.id.layout_item_positive))65 )).perform(ViewActions.typeText("Submit"), ViewActions.closeSoftKeyboard())...

Full Screen

Full Screen

Autobot.kt

Source:Autobot.kt Github

copy

Full Screen

...78 fun isChecked(): SettingRobot {79 interaction.check(ViewAssertions.matches(ViewMatchers.isChecked()))80 return this81 }82 fun isNotChecked(): SettingRobot {83 interaction.check(ViewAssertions.matches(ViewMatchers.isNotChecked()))84 return this85 }86 fun click(): SettingRobot {87 interaction.perform(ViewActions.click())88 return this89 }90 fun prefSendUsageData(): SettingRobot {91 // Click on the switch multiple times...92 interaction = Espresso.onData(93 Is.`is`(CoreMatchers.instanceOf(TelemetrySwitchPreference::class.java))).onChildView(ViewMatchers.withClassName(Is.`is`(Switch::class.java.name)))94 return this95 }96 fun prefTurboMode(): SettingRobot {97 // Click on the switch multiple times......

Full Screen

Full Screen

DialogFragmentWithTwoButtonsTest.kt

Source:DialogFragmentWithTwoButtonsTest.kt Github

copy

Full Screen

...32 Intents.init()33 // Perform view actions.34 Espresso.onView(Matchers.allOf(35 ViewMatchers.withId(R.id.switchCompat),36 ViewMatchers.isNotChecked(),37 ViewMatchers.withParent(ViewMatchers.withId(R.id.layout_item_negative))38 )).perform(ViewActions.click())39 Espresso.onView(Matchers.allOf(40 ViewMatchers.withId(R.id.switchCompat),41 ViewMatchers.isNotChecked(),42 ViewMatchers.withParent(ViewMatchers.withId(R.id.layout_item_cancelable))43 )).perform(ViewActions.click())44 Espresso.onView(Matchers.allOf(45 ViewMatchers.withId(R.id.switchCompat),46 ViewMatchers.isNotChecked(),47 ViewMatchers.withParent(ViewMatchers.withId(R.id.layout_item_callback))48 )).perform(ViewActions.click())49 Espresso.onView(ViewMatchers.withId(R.id.button_dialog))50 .perform(ViewActions.click())51 }52 @After53 fun after() {54 Intents.release()55 }56 /**57 * Check views onto the dialog fragment.58 */59 @Test60 fun twoButtons_checkViews() {...

Full Screen

Full Screen

ConfigureWidgetActivityTest.kt

Source:ConfigureWidgetActivityTest.kt Github

copy

Full Screen

...9import android.support.test.espresso.contrib.ActivityResultMatchers.hasResultCode10import android.support.test.espresso.matcher.ViewMatchers.assertThat11import android.support.test.espresso.matcher.ViewMatchers.isChecked12import android.support.test.espresso.matcher.ViewMatchers.isDisplayed13import android.support.test.espresso.matcher.ViewMatchers.isNotChecked14import android.support.test.espresso.matcher.ViewMatchers.withId15import android.support.test.filters.LargeTest16import android.support.test.rule.ActivityTestRule17import android.support.test.rule.GrantPermissionRule18import android.support.test.runner.AndroidJUnit419import me.thanel.linecalendar.R20import me.thanel.linecalendar.preference.IndicatorStyle21import me.thanel.linecalendar.preference.WidgetPreferences22import org.hamcrest.CoreMatchers.not23import org.hamcrest.Matchers.equalTo24import org.junit.Before25import org.junit.Rule26import org.junit.Test27import org.junit.runner.RunWith28@LargeTest29@RunWith(AndroidJUnit4::class)30class ConfigureWidgetActivityTest {31 @Suppress("MemberVisibilityCanBePrivate")32 @get:Rule33 val activityTestRule =34 object : ActivityTestRule<ConfigureWidgetActivity>(ConfigureWidgetActivity::class.java) {35 override fun getActivityIntent(): Intent {36 val targetContext = InstrumentationRegistry.getInstrumentation().targetContext37 return Intent(targetContext, ConfigureWidgetActivity::class.java)38 .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 1)39 }40 }41 @Suppress("unused")42 @get:Rule43 val grantPermissionRule: GrantPermissionRule =44 GrantPermissionRule.grant(android.Manifest.permission.READ_CALENDAR)45 private lateinit var preferences: WidgetPreferences46 private lateinit var tempPreferences: WidgetPreferences47 @Before48 fun initPreferences() {49 val targetContext = InstrumentationRegistry.getInstrumentation().targetContext50 preferences = WidgetPreferences(targetContext, 1)51 preferences.clear()52 tempPreferences = WidgetPreferences(targetContext, AppWidgetManager.INVALID_APPWIDGET_ID)53 tempPreferences.clear()54 }55 @Test56 fun uncheckHeaderSwitch_hidesHeaderAndUpdatesPreference() {57 // By default should enable header58 onView(withId(R.id.headerEnabledSwitch)).check(matches(isChecked()))59 onView(withId(R.id.eventsHeader)).check(matches(isDisplayed()))60 // Uncheck header switch61 onView(withId(R.id.headerEnabledSwitch)).perform(click())62 // Verify that the header has been hidden63 onView(withId(R.id.headerEnabledSwitch)).check(matches(isNotChecked()))64 onView(withId(R.id.eventsHeader)).check(matches(not(isDisplayed())))65 // ...and preference updated66 assertThat(tempPreferences.isHeaderEnabled, equalTo(false))67 }68 @Test69 fun clickFinishFab_closesActivityWithOkResult() {70 onView(withId(R.id.finishFab)).perform(click())71 assertThat(activityTestRule.activity.isFinishing, equalTo(true))72 assertThat(activityTestRule.activityResult, hasResultCode(Activity.RESULT_OK))73 }74 @Test75 fun indicatorStyle_updatesViewsAndPreference() {76 // By default should check circle style77 onView(withId(R.id.indicatorStyleNone)).check(matches(not(isChecked())))...

Full Screen

Full Screen

EspressoAssertion.kt

Source:EspressoAssertion.kt Github

copy

Full Screen

...13 var text: String by Delegator(::withText)14 var textResId: Int by Delegator(::withText)15 var spinnerText: String by Delegator(::withSpinnerText)16 var enabled: Boolean by Delegator(::withEnabled)17 var checked: Boolean by Delegator { if (it) isChecked() else isNotChecked() }18 var color: Int by Delegator(::withTextColor)19 var displayed: Boolean by Delegator { if(it) isDisplayed() else not(isDisplayed())}20 var backgroundResId: Int by Delegator(::withBackground)21 inner class Delegator<K, T>(val block: (T) -> Matcher<View>) : ReadWriteProperty<K, T> {22 override fun getValue(thisRef: K, property: KProperty<*>): T {23 throw UnsupportedOperationException("not implemented")24 }25 override fun setValue(thisRef: K, property: KProperty<*>, value: T) {26 checkNotNull(viewInteraction, { "Missing 'on { }' block before 'assert { }'" })27 viewInteraction?.check(ViewAssertions.matches(block(value)))28 }29 }30 init {31 init()...

Full Screen

Full Screen

TheRequestActivity.kt

Source:TheRequestActivity.kt Github

copy

Full Screen

...16 var rule = TruleskActivityRule(RequestActivity::class.java)17 @Test18 fun requestIsThereAndHasQRCodeAndNoValue() {19 onView(withId(R.id.receive_qrcode)).check(matches(isDisplayed()))20 onView(withId(R.id.add_value_checkbox)).check(matches(isNotChecked()))21 onView(withId(R.id.value_input_layout)).check(matches(withEffectiveVisibility(GONE)))22 rule.screenShot("transaction_no_value")23 }24 @Test25 fun thereIsNoValueEditShownWhenCheckboxUnchecked() {26 onView(withId(R.id.add_value_checkbox)).perform(click())27 onView(withId(R.id.add_value_checkbox)).check(matches(isChecked()))28 onView(withId(R.id.value_input_layout)).check(matches(isDisplayed()))29 onView(withId(R.id.value_input_edittext)).perform(typeText("0.42"))30 Espresso.closeSoftKeyboard()31 rule.screenShot("transaction_with_value")32 }33}...

Full Screen

Full Screen

ViewAssertions.kt

Source:ViewAssertions.kt Github

copy

Full Screen

...13fun ViewInteraction.hasText(text: String) = check(matches(withText(text)))14fun ViewInteraction.isEnabled() = check(matches(ViewMatchers.isEnabled()))15fun ViewInteraction.isDisabled() = check(matches(not(ViewMatchers.isEnabled())))16fun ViewInteraction.isChecked() = check(matches(ViewMatchers.isChecked()))17fun ViewInteraction.isNotChecked() = check(matches(not(ViewMatchers.isChecked())))...

Full Screen

Full Screen

isNotChecked

Using AI Code Generation

copy

Full Screen

1Espresso.onView(ViewMatchers.withId(R.id.checkbox)).check(ViewAssertions.matches(ViewMatchers.isNotChecked()));2Espresso.onView(ViewMatchers.withId(R.id.textview)).check(ViewAssertions.matches(ViewMatchers.withText("Hello World!")));3Espresso.onView(ViewMatchers.withId(R.id.textview)).check(ViewAssertions.matches(ViewMatchers.withText(R.string.hello_world)));4Espresso.onView(ViewMatchers.withId(R.id.textview)).check(ViewAssertions.matches(ViewMatchers.withText(R.string.hello_world)));5Espresso.onView(ViewMatchers.withId(R.id.textview)).check(ViewAssertions.matches(ViewMatchers.withText(R.string.hello_world)));6Espresso.onView(ViewMatchers.withId(R.id.textview)).check(ViewAssertions.matches(ViewMatchers.withText(R.string.hello_world)));7Espresso.onView(ViewMatchers.withId(R.id.textview)).check(ViewAssertions.matches(ViewMatchers.withText(R.string.hello_world)));8Espresso.onView(ViewMatchers.withId(R.id.textview)).check(ViewAssertions.matches(ViewMatchers.withText(R.string.hello_world)));9Espresso.onView(ViewMatchers.withId(R.id.textview)).check(ViewAssertions.matches(ViewMatchers.withText(R.string.hello_world)));10Espresso.onView(ViewMatchers.withId(R.id.textview)).check(ViewAssertions.matches(ViewMatchers.withText(R.string.hello_world)));11Espresso.onView(ViewMatchers.withId(R.id.textview)).check(ViewAssertions.matches(ViewMatchers.withText(R.string.hello_world)));12Espresso.onView(ViewMatchers.withId(R.id.textview)).check(ViewAssertions.matches(ViewMatchers.withText(R.string.hello_world)));

Full Screen

Full Screen

isNotChecked

Using AI Code Generation

copy

Full Screen

1onView(withId(R.id.checkbox)).check(matches(not(isChecked())));2onView(withId(R.id.checkbox)).check(matches(not(isChecked())));3onView(withId(R.id.checkbox)).check(matches(isNotChecked()));4onView(withId(R.id.checkbox)).check(matches(isNotChecked()));5onView(withId(R.id.checkbox)).check(matches(not(isChecked())));6onView(withId(R.id.checkbox)).check(matches(not(isChecked())));7onView(withId(R.id.checkbox)).check(matches(isNotChecked()));8onView(withId(R.id.checkbox)).check(matches(isNotChecked()));9onView(withId(R.id.checkbox)).check(matches(not(isChecked())));10onView(withId(R.id.checkbox)).check(matches(not(isChecked())));11onView(withId(R.id.checkbox)).check(matches(isNotChecked()));12onView(withId(R.id.checkbox)).check(matches(isNotChecked()));13onView(withId(R.id.checkbox)).check(matches(not(isChecked())));14onView(withId(R.id.checkbox)).check(matches(not(isChecked())));15onView(withId(R.id.checkbox)).check(matches(isNotChecked()));16onView(withId(R.id.checkbox)).check(matches(isNotChecked()));17onView(withId(R.id.checkbox)).check(matches(not(isChecked())));18onView(withId(R.id.checkbox)).check(matches(not(isChecked())));19onView(withId(R.id.checkbox)).check(matches(isNotChecked()));20onView(withId(R.id.checkbox)).check(matches(isNotChecked()));21onView(withId(R.id.checkbox)).check(matches(not(isChecked())));22onView(withId(R.id.checkbox)).check(matches(not(isChecked())));23onView(withId(R.id.checkbox)).check(matches(isNotChecked()));24onView(withId(R.id.checkbox)).check(matches(isNotChecked()));25onView(withId(R.id.checkbox)).check(matches(not(isChecked())));26onView(withId(R.id.checkbox)).check(matches(not(isChecked())));27onView(withId(R.id.checkbox)).check(matches(isNotChecked()));28onView(withId(R.id.checkbox)).check(matches(isNotChecked()));29onView(withId(R.id.checkbox)).check(matches(not(isChecked())));30onView(withId(R.id.checkbox)).check(matches(not(isChecked())));31onView(withId(R.id.checkbox)).check(matches(isNotChecked()));32onView(withId(R.id.checkbox)).check(matches(isNotChecked()));33onView(withId(R.id.checkbox)).check(matches(not(isChecked())));34onView(withId(R.id.checkbox)).check(matches(not(isChecked())));35onView(withId(R.id.checkbox)).check(matches(isNotChecked()));

Full Screen

Full Screen

isNotChecked

Using AI Code Generation

copy

Full Screen

1onView(withId(R.id.checkbox)).perform(click());2onView(withId(R.id.checkbox)).check(matches(isNotChecked()));3onView(withId(R.id.layout)).check(matches(isDescendantOfA(withId(R.id.parent_layout))));4onView(withId(R.id.button)).check(matches(isRoot()));5onView(withId(R.id.button)).check(matches(isAssignableFrom(Button.class)));6onView(withId(R.id.button)).check(matches(isClickable()));7onView(withId(R.id.button)).check(matches(isEnabled()));8onView(withId(R.id.button)).check(matches(isDisplayed()));

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful