|
| 1 | +/* |
| 2 | + * © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com |
| 3 | + * Contributors: denbond7 |
| 4 | + */ |
| 5 | + |
| 6 | +package com.flowcrypt.email.ui.fragment |
| 7 | + |
| 8 | +import androidx.test.espresso.Espresso.onView |
| 9 | +import androidx.test.espresso.assertion.ViewAssertions.doesNotExist |
| 10 | +import androidx.test.espresso.assertion.ViewAssertions.matches |
| 11 | +import androidx.test.espresso.matcher.ViewMatchers.isDisplayed |
| 12 | +import androidx.test.espresso.matcher.ViewMatchers.withText |
| 13 | +import androidx.test.ext.junit.rules.activityScenarioRule |
| 14 | +import androidx.test.ext.junit.runners.AndroidJUnit4 |
| 15 | +import androidx.test.filters.MediumTest |
| 16 | +import com.flowcrypt.email.R |
| 17 | +import com.flowcrypt.email.TestConstants |
| 18 | +import com.flowcrypt.email.junit.annotations.FlowCryptTestSettings |
| 19 | +import com.flowcrypt.email.rules.ClearAppSettingsRule |
| 20 | +import com.flowcrypt.email.rules.FlowCryptMockWebServerRule |
| 21 | +import com.flowcrypt.email.rules.GrantPermissionRuleChooser |
| 22 | +import com.flowcrypt.email.rules.RetryRule |
| 23 | +import com.flowcrypt.email.rules.ScreenshotTestRule |
| 24 | +import com.flowcrypt.email.ui.activity.MainActivity |
| 25 | +import com.flowcrypt.email.ui.base.BaseGmailApiTest |
| 26 | +import com.flowcrypt.email.util.TestGeneralUtil |
| 27 | +import okhttp3.mockwebserver.Dispatcher |
| 28 | +import okhttp3.mockwebserver.MockResponse |
| 29 | +import okhttp3.mockwebserver.RecordedRequest |
| 30 | +import org.junit.Rule |
| 31 | +import org.junit.Test |
| 32 | +import org.junit.rules.RuleChain |
| 33 | +import org.junit.rules.TestRule |
| 34 | +import org.junit.runner.RunWith |
| 35 | + |
| 36 | +/** |
| 37 | + * @author Denys Bondarenko |
| 38 | + */ |
| 39 | +@MediumTest |
| 40 | +@RunWith(AndroidJUnit4::class) |
| 41 | +@FlowCryptTestSettings(useCommonIdling = false) |
| 42 | +class MainSettingsFragmentEnterpriseFlowTest : |
| 43 | + BaseGmailApiTest(BASE_ACCOUNT_ENTITY.copy(useConversationMode = true)) { |
| 44 | + override val activityScenarioRule = activityScenarioRule<MainActivity>( |
| 45 | + TestGeneralUtil.genIntentForNavigationComponent( |
| 46 | + destinationId = R.id.mainSettingsFragment |
| 47 | + ) |
| 48 | + ) |
| 49 | + |
| 50 | + override val mockWebServerRule = |
| 51 | + FlowCryptMockWebServerRule(TestConstants.MOCK_WEB_SERVER_PORT, object : Dispatcher() { |
| 52 | + override fun dispatch(request: RecordedRequest): MockResponse { |
| 53 | + return when { |
| 54 | + else -> handleCommonAPICalls(request) |
| 55 | + } |
| 56 | + } |
| 57 | + }) |
| 58 | + |
| 59 | + @get:Rule |
| 60 | + var ruleChain: TestRule = RuleChain |
| 61 | + .outerRule(RetryRule.DEFAULT) |
| 62 | + .around(ClearAppSettingsRule()) |
| 63 | + .around(GrantPermissionRuleChooser.grant(android.Manifest.permission.POST_NOTIFICATIONS)) |
| 64 | + .around(addAccountToDatabaseRule) |
| 65 | + .around(addPrivateKeyToDatabaseRule) |
| 66 | + .around(activityScenarioRule) |
| 67 | + .around(ScreenshotTestRule()) |
| 68 | + |
| 69 | + @Test |
| 70 | + fun testHiddenOrVisibleItems() { |
| 71 | + //should be hidden as we have NO_PRV_BACKUP |
| 72 | + onView(withText(getResString(R.string.backups))) |
| 73 | + .check(doesNotExist()) |
| 74 | + //should be hidden as we have RESTRICT_ANDROID_ATTACHMENT_HANDLING |
| 75 | + onView(withText(getResString(R.string.general))) |
| 76 | + .check(doesNotExist()) |
| 77 | + |
| 78 | + //should be visible |
| 79 | + onView(withText(getResString(R.string.security_and_privacy))) |
| 80 | + .check(matches(isDisplayed())) |
| 81 | + onView(withText(getResString(R.string.contacts))) |
| 82 | + .check(matches(isDisplayed())) |
| 83 | + onView(withText(getResString(R.string.keys))) |
| 84 | + .check(matches(isDisplayed())) |
| 85 | + onView(withText(getResString(R.string.attester))) |
| 86 | + .check(matches(isDisplayed())) |
| 87 | + onView(withText(getResString(R.string.experimental))) |
| 88 | + .check(matches(isDisplayed())) |
| 89 | + } |
| 90 | +} |
0 commit comments