-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #452 from KasperskyLab/TECH-sanity-tests
Tech sanity tests
- Loading branch information
Showing
50 changed files
with
1,890 additions
and
13 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
kaspresso/src/main/kotlin/com/kaspersky/kaspresso/systemsafety/SystemDialogSafetyPattern.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.kaspersky.kaspresso.systemsafety | ||
|
||
import java.util.regex.Pattern | ||
|
||
enum class SystemDialogSafetyPattern(val pattern: Pattern) { | ||
PERMISSION_API23(Pattern.compile("\\S*android.packageinstaller\\S*")), | ||
PERMISSION_API30(Pattern.compile("\\S*android.permissioncontroller\\S*")), | ||
OTHER(Pattern.compile("\\S*google.android\\S*")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...resso/composesupport/kaspresso/sanity/autoscroll/AutoScrollSemanticsDisabledSanityTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.kaspersky.kaspresso.composesupport.kaspresso.sanity.autoscroll | ||
|
||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.kaspersky.components.composesupport.config.withComposeSupport | ||
import com.kaspersky.kaspresso.composesupport.sample.MainActivity | ||
import com.kaspersky.kaspresso.composesupport.sample.screen.ComposeMainScreen | ||
import com.kaspersky.kaspresso.composesupport.sample.screen.ComposeScrollScreen | ||
import com.kaspersky.kaspresso.kaspresso.Kaspresso | ||
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase | ||
import io.github.kakaocup.compose.node.element.ComposeScreen | ||
import org.junit.Assert | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import java.lang.AssertionError | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class AutoScrollSemanticsDisabledSanityTest : TestCase( | ||
kaspressoBuilder = Kaspresso.Builder.withComposeSupport( | ||
lateComposeCustomize = { composeBuilder -> | ||
composeBuilder.semanticsBehaviorInterceptors = mutableListOf() | ||
} | ||
) | ||
) { | ||
|
||
@get:Rule | ||
val composeTestRule = createAndroidComposeRule<MainActivity>() | ||
|
||
@Test | ||
fun test() = run { | ||
step("Open Flaky screen") { | ||
ComposeScreen.onComposeScreen<ComposeMainScreen>(composeTestRule) { | ||
scrollButton { | ||
performClick() | ||
} | ||
} | ||
} | ||
|
||
step("Click on the First button") { | ||
ComposeScreen.onComposeScreen<ComposeScrollScreen>(composeTestRule) { | ||
firstButton { | ||
assertIsDisplayed() | ||
performClick() | ||
} | ||
} | ||
} | ||
|
||
step("Click on the Last button") { | ||
ComposeScreen.onComposeScreen<ComposeScrollScreen>(composeTestRule) { | ||
Assert.assertThrows(null, AssertionError::class.java) { | ||
lastButton { | ||
assertIsDisplayed() | ||
performClick() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...presso/composesupport/kaspresso/sanity/autoscroll/AutoScrollSemanticsEnabledSanityTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.kaspersky.kaspresso.composesupport.kaspresso.sanity.autoscroll | ||
|
||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.kaspersky.components.composesupport.config.withComposeSupport | ||
import com.kaspersky.components.composesupport.interceptors.behavior.impl.autoscroll.AutoScrollSemanticsBehaviorInterceptor | ||
import com.kaspersky.kaspresso.composesupport.sample.MainActivity | ||
import com.kaspersky.kaspresso.composesupport.sample.screen.ComposeMainScreen | ||
import com.kaspersky.kaspresso.composesupport.sample.screen.ComposeScrollScreen | ||
import com.kaspersky.kaspresso.kaspresso.Kaspresso | ||
import com.kaspersky.kaspresso.logger.UiTestLoggerImpl | ||
import com.kaspersky.kaspresso.params.AutoScrollParams | ||
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase | ||
import io.github.kakaocup.compose.node.element.ComposeScreen | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class AutoScrollSemanticsEnabledSanityTest : TestCase( | ||
kaspressoBuilder = Kaspresso.Builder.withComposeSupport( | ||
lateComposeCustomize = { composeBuilder -> | ||
composeBuilder.semanticsBehaviorInterceptors = mutableListOf(AutoScrollSemanticsBehaviorInterceptor(UiTestLoggerImpl(Kaspresso.DEFAULT_TEST_LOGGER_TAG), AutoScrollParams.default())) | ||
} | ||
) | ||
) { | ||
|
||
@get:Rule | ||
val composeTestRule = createAndroidComposeRule<MainActivity>() | ||
|
||
@Test | ||
fun test() = run { | ||
step("Open Flaky screen") { | ||
ComposeScreen.onComposeScreen<ComposeMainScreen>(composeTestRule) { | ||
scrollButton { | ||
performClick() | ||
} | ||
} | ||
} | ||
|
||
step("Click on the First button") { | ||
ComposeScreen.onComposeScreen<ComposeScrollScreen>(composeTestRule) { | ||
firstButton { | ||
assertIsDisplayed() | ||
performClick() | ||
} | ||
} | ||
} | ||
|
||
step("Click on the Last button") { | ||
ComposeScreen.onComposeScreen<ComposeScrollScreen>(composeTestRule) { | ||
lastButton { | ||
assertIsDisplayed() | ||
performClick() | ||
} | ||
} | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...spersky/kaspresso/composesupport/kaspresso/sanity/flaky/FlakyComposeDisabledSanityTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.kaspersky.kaspresso.composesupport.kaspresso.sanity.flaky | ||
|
||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.kaspersky.components.composesupport.config.withComposeSupport | ||
import com.kaspersky.kaspresso.composesupport.sample.MainActivity | ||
import com.kaspersky.kaspresso.composesupport.sample.screen.ComposeMainScreen | ||
import com.kaspersky.kaspresso.composesupport.sample.screen.ComposeSanityFlakyScreen | ||
import com.kaspersky.kaspresso.kaspresso.Kaspresso | ||
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase | ||
import io.github.kakaocup.compose.node.element.ComposeScreen | ||
import org.junit.Assert | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class FlakyComposeDisabledSanityTest : TestCase( | ||
kaspressoBuilder = Kaspresso.Builder.withComposeSupport( | ||
lateComposeCustomize = { composeBuilder -> | ||
composeBuilder.semanticsBehaviorInterceptors = mutableListOf() | ||
} | ||
) | ||
) { | ||
|
||
@get:Rule | ||
val composeTestRule = createAndroidComposeRule<MainActivity>() | ||
|
||
@Test | ||
fun test() = run { | ||
step("Open Flaky screen") { | ||
ComposeScreen.onComposeScreen<ComposeMainScreen>(composeTestRule) { | ||
sanityFlakyButton { | ||
performClick() | ||
} | ||
} | ||
} | ||
|
||
step("Click on the First button") { | ||
ComposeScreen.onComposeScreen<ComposeSanityFlakyScreen>(composeTestRule) { | ||
firstButton { | ||
assertIsDisplayed() | ||
performClick() | ||
} | ||
} | ||
} | ||
|
||
step("Click on the Second button") { | ||
ComposeScreen.onComposeScreen<ComposeSanityFlakyScreen>(composeTestRule) { | ||
secondButton { | ||
Assert.assertThrows(null, AssertionError::class.java) { | ||
assertIsDisplayed() | ||
performClick() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...aspersky/kaspresso/composesupport/kaspresso/sanity/flaky/FlakyComposeEnabledSanityTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.kaspersky.kaspresso.composesupport.kaspresso.sanity.flaky | ||
|
||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.kaspersky.components.composesupport.config.withComposeSupport | ||
import com.kaspersky.components.composesupport.interceptors.behavior.impl.flakysafety.FlakySafeSemanticsBehaviorInterceptor | ||
import com.kaspersky.kaspresso.composesupport.sample.MainActivity | ||
import com.kaspersky.kaspresso.composesupport.sample.screen.ComposeMainScreen | ||
import com.kaspersky.kaspresso.composesupport.sample.screen.ComposeSanityFlakyScreen | ||
import com.kaspersky.kaspresso.kaspresso.Kaspresso | ||
import com.kaspersky.kaspresso.logger.UiTestLoggerImpl | ||
import com.kaspersky.kaspresso.params.FlakySafetyParams | ||
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase | ||
import io.github.kakaocup.compose.node.element.ComposeScreen | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class FlakyComposeEnabledSanityTest : TestCase( | ||
kaspressoBuilder = Kaspresso.Builder.withComposeSupport( | ||
lateComposeCustomize = { composeBuilder -> | ||
composeBuilder.semanticsBehaviorInterceptors = mutableListOf(FlakySafeSemanticsBehaviorInterceptor(FlakySafetyParams.default(), UiTestLoggerImpl(Kaspresso.DEFAULT_TEST_LOGGER_TAG))) | ||
} | ||
) | ||
) { | ||
|
||
@get:Rule | ||
val composeTestRule = createAndroidComposeRule<MainActivity>() | ||
|
||
@Test | ||
fun test() = run { | ||
step("Open Flaky screen") { | ||
ComposeScreen.onComposeScreen<ComposeMainScreen>(composeTestRule) { | ||
sanityFlakyButton { | ||
performClick() | ||
} | ||
} | ||
} | ||
|
||
step("Click on the First button") { | ||
ComposeScreen.onComposeScreen<ComposeSanityFlakyScreen>(composeTestRule) { | ||
firstButton { | ||
assertIsDisplayed() | ||
performClick() | ||
} | ||
} | ||
} | ||
|
||
step("Click on the Second button") { | ||
ComposeScreen.onComposeScreen<ComposeSanityFlakyScreen>(composeTestRule) { | ||
secondButton { | ||
assertIsDisplayed() | ||
performClick() | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...t/kotlin/com/kaspersky/kaspresso/composesupport/sample/screen/ComposeSanityFlakyScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.kaspersky.kaspresso.composesupport.sample.screen | ||
|
||
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider | ||
import com.kaspersky.kaspresso.composesupport.sample.resources.C | ||
import io.github.kakaocup.compose.node.element.ComposeScreen | ||
import io.github.kakaocup.compose.node.element.KNode | ||
|
||
class ComposeSanityFlakyScreen(semanticsProvider: SemanticsNodeInteractionsProvider) : | ||
ComposeScreen<ComposeSanityFlakyScreen>( | ||
semanticsProvider = semanticsProvider, | ||
viewBuilderAction = { hasTestTag(C.Tag.sanity_flaky_screen_container) } | ||
) { | ||
|
||
val firstButton: KNode = child { | ||
hasTestTag(C.Tag.sanity_flaky_screen_simple_first_button) | ||
} | ||
|
||
val secondButton: KNode = child { | ||
hasTestTag(C.Tag.sanity_flaky_screen_simple_second_button) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...idTest/kotlin/com/kaspersky/kaspresso/composesupport/sample/screen/ComposeScrollScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.kaspersky.kaspresso.composesupport.sample.screen | ||
|
||
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider | ||
import com.kaspersky.kaspresso.composesupport.sample.resources.C | ||
import io.github.kakaocup.compose.node.element.ComposeScreen | ||
import io.github.kakaocup.compose.node.element.KNode | ||
|
||
class ComposeScrollScreen(semanticsProvider: SemanticsNodeInteractionsProvider) : | ||
ComposeScreen<ComposeScrollScreen>( | ||
semanticsProvider = semanticsProvider, | ||
viewBuilderAction = { hasTestTag(C.Tag.scroll_screen_container) } | ||
) { | ||
|
||
val firstButton: KNode = child { | ||
hasTestTag(C.Tag.scroll_screen_buttons[0]) | ||
} | ||
|
||
val lastButton: KNode = child { | ||
hasTestTag(C.Tag.scroll_screen_buttons.last()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.