-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 249/compose support #307
Changes from 13 commits
438bd46
0db17b6
ed71945
56b727c
c75259d
6df379b
7211a8b
2b90a5f
61a7b45
7a77c87
49f1adb
3d7da93
a2094e1
d08bf45
e3a7a32
0f028fa
068f0b0
67860e2
aeb5e5a
7b626a1
c8aa36b
44f3bbd
1165160
dc905e6
abf3983
2edacd0
795dd5a
387549a
22aaa15
60f586d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,11 @@ android { | |
} | ||
} | ||
|
||
@Suppress("UnstableApiUsage") | ||
onVariants { | ||
androidTest { | ||
enabled = false | ||
} | ||
} | ||
// todo doesn't work on AGP 4.2.2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RuslanMingaliev such api is not available now |
||
// @Suppress("UnstableApiUsage") | ||
// onVariants { | ||
// androidTest { | ||
// enabled = false | ||
// } | ||
// } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
[versions] | ||
kotlin = "1.4.32" | ||
kotlin = "1.5.21" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1.5.31 causes weird problems, postponed |
||
detekt = "1.18.1" | ||
espresso = "3.3.0" | ||
allure = "2.2.6" | ||
espresso = "3.4.0" | ||
allure = "2.2.7" | ||
compose = "1.0.2" | ||
activityCompose = "1.3.1" | ||
|
||
[libraries] | ||
# plugins | ||
kotlinPlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } | ||
androidPlugin = "com.android.tools.build:gradle:4.1.0" | ||
androidPlugin = "com.android.tools.build:gradle:4.2.2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Мб нам его до 7 поднять? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried but I got a lot of errors with our plugins =( |
||
|
||
# libraries | ||
kotlinCli = "org.jetbrains.kotlinx:kotlinx-cli:0.3" | ||
|
@@ -17,28 +19,47 @@ detektFormatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", v | |
kotlinStdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" } | ||
espressoCore = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" } | ||
espressoWeb = { module = "androidx.test.espresso:espresso-web", version.ref = "espresso" } | ||
testCore = "androidx.test:core:1.3.0" | ||
testCore = "androidx.test:core:1.4.0" | ||
uiAutomator = "androidx.test.uiautomator:uiautomator:2.2.0" | ||
fragmentTesting = "androidx.fragment:fragment-testing:1.3.2" | ||
fragmentTesting = "androidx.fragment:fragment-testing:1.3.6" | ||
# upgrading to 4.6.1 is blocked by https://github.com/robolectric/robolectric/issues/6593 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not a bug, there is a solution in the comments There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure that you are right. Ok, can you try to fix it? |
||
robolectric = "org.robolectric:robolectric:4.5.1" | ||
|
||
androidXCore = "androidx.core:core:1.3.0" | ||
androidXRules = "androidx.test:rules:1.3.0" | ||
androidXTest = "androidx.test.ext:junit:1.1.2" | ||
androidXTestKtx = "androidx.test.ext:junit-ktx:1.1.2" | ||
androidXCore = "androidx.core:core:1.7.0" | ||
|
||
androidXRules = "androidx.test:rules:1.4.0" | ||
androidXTest = "androidx.test.ext:junit:1.1.3" | ||
androidXTestKtx = "androidx.test.ext:junit-ktx:1.1.3" | ||
|
||
composeActivity = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" } | ||
composeUiTooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" } | ||
composeMaterial = { module = "androidx.compose.material:material", version.ref = "compose" } | ||
composeTestManifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" } | ||
composeCompiler = { module = "androidx.compose.compiler:compiler", version.ref = "compose" } | ||
|
||
composeUiTest = { module = "androidx.compose.ui:ui-test", version.ref = "compose" } | ||
|
||
composeJunit = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" } | ||
|
||
lifecycleViewModelKtx = "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0" | ||
lifecycleLiveDataKtx = "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0" | ||
composeNavigation = "androidx.navigation:navigation-compose:2.4.0-beta02" | ||
lifecycleViewModelComposeKtx = "androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0" | ||
composeRuntimeLiveData = "androidx.compose.runtime:runtime-livedata:1.0.5" | ||
|
||
appcompat = "androidx.appcompat:appcompat:1.3.0" | ||
material = "com.google.android.material:material:1.2.0" | ||
constraint = "androidx.constraintlayout:constraintlayout:2.0.0" | ||
|
||
kakao = "io.github.kakaocup:kakao:3.0.2" | ||
kakao = "io.github.kakaocup:kakao:3.0.5" | ||
kakaoCompose = "io.github.kakaocup:compose:0.0.2" | ||
gson = "com.google.code.gson:gson:2.8.6" | ||
|
||
junit = "junit:junit:4.13" | ||
junitJupiter = "org.junit.jupiter:junit-jupiter:5.6.2" | ||
truth = "com.google.truth:truth:1.0" | ||
runner = "androidx.test:runner:1.3.0" | ||
orchestrator = "androidx.test:orchestrator:1.3.0" | ||
orchestrator = "androidx.test:orchestrator:1.4.0" | ||
|
||
okhttp = "com.squareup.okhttp3:okhttp:4.9.1" | ||
kotson = "com.github.salomonbrys.kotson:kotson:2.5.0" | ||
|
@@ -51,3 +72,4 @@ allureKotlinAndroid = { module = "io.qameta.allure:allure-kotlin-android", versi | |
[bundles] | ||
espresso = ["espressoCore", "espressoWeb"] | ||
allure = ["allureKotlinModel", "allureKotlinCommons", "allureKotlinJunit4", "allureKotlinAndroid"] | ||
compose = ["composeActivity", "composeUiTooling", "composeMaterial", "composeTestManifest", "composeCompiler"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.kaspersky.kaspresso.interceptors.behaviorcompose | ||
|
||
interface ComposeBehaviorInterceptor<Interaction, Assertion, Action> { | ||
|
||
/** | ||
* Called to do some stuff and actually check an interaction with element. | ||
* | ||
* @param activity a function-wrapper of an action or an assertion to be invoked. | ||
*/ | ||
fun <T> interceptCheck(interaction: Interaction, assertion: Assertion, activity: () -> T): T | ||
|
||
/** | ||
* Called to do some stuff and actually perform an interaction with element. | ||
* | ||
* @param activity a function-wrapper of an action or an assertion to be invoked. | ||
*/ | ||
fun <T> interceptPerform(interaction: Interaction, action: Action, activity: () -> T): T | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.kaspersky.kaspresso.interceptors.behaviorcompose | ||
|
||
import io.github.kakaocup.compose.intercept.interaction.ComposeInteraction | ||
import io.github.kakaocup.compose.intercept.operation.ComposeAction | ||
import io.github.kakaocup.compose.intercept.operation.ComposeAssertion | ||
|
||
/** | ||
* The derived from [ComposeBehaviorInterceptor] interface for intercepting [ComposeInteraction.perform] and | ||
* [ComposeInteraction.check] behavior. | ||
*/ | ||
interface SemanticsBehaviorInterceptor : | ||
ComposeBehaviorInterceptor<ComposeInteraction, ComposeAssertion, ComposeAction> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.kaspersky.kaspresso.interceptors.behaviorcompose.impl.failure | ||
|
||
import com.kaspersky.kaspresso.failure.FailureLoggingProvider | ||
import com.kaspersky.kaspresso.failure.FailureLoggingProviderImpl | ||
import com.kaspersky.kaspresso.interceptors.behaviorcompose.SemanticsBehaviorInterceptor | ||
import com.kaspersky.kaspresso.logger.UiTestLogger | ||
import io.github.kakaocup.compose.intercept.interaction.ComposeInteraction | ||
import io.github.kakaocup.compose.intercept.operation.ComposeAction | ||
import io.github.kakaocup.compose.intercept.operation.ComposeAssertion | ||
|
||
/** | ||
* The implementation of [SemanticsBehaviorInterceptor] and [FailureLoggingProvider] interfaces. | ||
* Provides failure logging functionality for [ComposeInteraction.perform] and [ComposeInteraction.check] calls. | ||
* | ||
* By default, this interceptor is not used in Kaspresso. | ||
* If you desire to change result log (especially in case of an error) we recommend to use [FailureLoggingProvider] directly | ||
*/ | ||
class FailureLoggingSemanticsBehaviorInterceptor( | ||
logger: UiTestLogger | ||
) : SemanticsBehaviorInterceptor, | ||
FailureLoggingProvider by FailureLoggingProviderImpl(logger) { | ||
|
||
/** | ||
* Wraps the given [activity] invocation with the failure logging. | ||
* | ||
* @param interaction the intercepted [ComposeInteraction]. | ||
* @param assertion the intercepted [ComposeAssertion]. | ||
* @param activity the activity to invoke. | ||
*/ | ||
override fun <T> interceptCheck( | ||
interaction: ComposeInteraction, | ||
assertion: ComposeAssertion, | ||
activity: () -> T | ||
): T = withLoggingOnFailure(action = activity) | ||
|
||
/** | ||
* Wraps the given [activity] invocation with the failure logging. | ||
* | ||
* @param interaction the intercepted [ComposeInteraction]. | ||
* @param action the intercepted [ComposeAction]. | ||
* @param activity the activity to invoke. | ||
*/ | ||
override fun <T> interceptPerform( | ||
interaction: ComposeInteraction, | ||
action: ComposeAction, | ||
activity: () -> T | ||
): T = withLoggingOnFailure(action = activity) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.kaspersky.kaspresso.interceptors.behaviorcompose.impl.flakysafety | ||
|
||
import com.kaspersky.kaspresso.flakysafety.FlakySafetyProvider | ||
import com.kaspersky.kaspresso.flakysafety.FlakySafetyProviderSimpleImpl | ||
import com.kaspersky.kaspresso.interceptors.behaviorcompose.SemanticsBehaviorInterceptor | ||
import com.kaspersky.kaspresso.logger.UiTestLogger | ||
import com.kaspersky.kaspresso.params.FlakySafetyParams | ||
import io.github.kakaocup.compose.intercept.interaction.ComposeInteraction | ||
import io.github.kakaocup.compose.intercept.operation.ComposeAction | ||
import io.github.kakaocup.compose.intercept.operation.ComposeAssertion | ||
|
||
/** | ||
* The implementation of [SemanticsBehaviorInterceptor] and [FlakySafetyProvider] interfaces. | ||
* Provides system flaky safety functionality for [ComposeInteraction.perform] and [ComposeInteraction.check] calls. | ||
*/ | ||
class FlakySafeSemanticsBehaviorInterceptor( | ||
params: FlakySafetyParams, | ||
logger: UiTestLogger | ||
) : SemanticsBehaviorInterceptor, | ||
FlakySafetyProvider by FlakySafetyProviderSimpleImpl(params, logger) { | ||
|
||
/** | ||
* Wraps the given [activity] invocation with the flaky safety. | ||
* | ||
* @param interaction the intercepted [ComposeInteraction]. | ||
* @param assertion the intercepted [ComposeAssertion]. | ||
* @param activity the activity to invoke. | ||
*/ | ||
override fun <T> interceptCheck( | ||
interaction: ComposeInteraction, | ||
assertion: ComposeAssertion, | ||
activity: () -> T | ||
): T = flakySafely(action = { | ||
interaction.reFindNode() | ||
activity.invoke() | ||
}) | ||
|
||
/** | ||
* Wraps the given [activity] invocation with the flaky safety. | ||
* | ||
* @param interaction the intercepted [ComposeInteraction]. | ||
* @param action the intercepted [ComposeAction]. | ||
* @param activity the activity to invoke. | ||
*/ | ||
override fun <T> interceptPerform( | ||
interaction: ComposeInteraction, | ||
action: ComposeAction, | ||
activity: () -> T | ||
): T = flakySafely(action = { | ||
interaction.reFindNode() | ||
activity.invoke() | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.kaspersky.kaspresso.interceptors.behaviorcompose.impl.systemsafety | ||
|
||
import com.kaspersky.kaspresso.device.server.AdbServer | ||
import com.kaspersky.kaspresso.instrumental.InstrumentalDependencyProvider | ||
import com.kaspersky.kaspresso.interceptors.behaviorcompose.SemanticsBehaviorInterceptor | ||
import com.kaspersky.kaspresso.logger.UiTestLogger | ||
import com.kaspersky.kaspresso.systemsafety.SystemDialogSafetyProvider | ||
import com.kaspersky.kaspresso.systemsafety.SystemDialogSafetyProviderImpl | ||
import io.github.kakaocup.compose.intercept.interaction.ComposeInteraction | ||
import io.github.kakaocup.compose.intercept.operation.ComposeAction | ||
import io.github.kakaocup.compose.intercept.operation.ComposeAssertion | ||
|
||
/** | ||
* The implementation of [SemanticsBehaviorInterceptor] and [SystemDialogSafetyProvider] interfaces. | ||
* Provides system dialog safety functionality for [ComposeInteraction.perform] and [ComposeInteraction.check] calls. | ||
*/ | ||
class SystemDialogSafetySemanticsBehaviorInterceptor( | ||
logger: UiTestLogger, | ||
instrumentalDependencyProvider: InstrumentalDependencyProvider, | ||
adbServer: AdbServer | ||
) : SemanticsBehaviorInterceptor, | ||
SystemDialogSafetyProvider by SystemDialogSafetyProviderImpl(logger, instrumentalDependencyProvider, adbServer) { | ||
|
||
/** | ||
* Wraps the given [activity] invocation with the system dialog safety. | ||
* | ||
* @param interaction the intercepted [ComposeInteraction]. | ||
* @param assertion the intercepted [ComposeAssertion]. | ||
* @param activity the activity to invoke. | ||
*/ | ||
override fun <T> interceptCheck( | ||
interaction: ComposeInteraction, | ||
assertion: ComposeAssertion, | ||
activity: () -> T | ||
): T = passSystemDialogs(activity) | ||
|
||
/** | ||
* Wraps the given [activity] invocation with the system dialog safety. | ||
* | ||
* @param interaction the intercepted [ComposeInteraction]. | ||
* @param action the intercepted [ComposeAction]. | ||
* @param activity the activity to invoke. | ||
*/ | ||
override fun <T> interceptPerform( | ||
interaction: ComposeInteraction, | ||
action: ComposeAction, | ||
activity: () -> T | ||
): T = passSystemDialogs(activity) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,10 @@ class FlakySafeObjectBehaviorInterceptor( | |
interaction: UiObjectInteraction, | ||
assertion: UiObjectAssertion, | ||
activity: () -> T | ||
): T = flakySafely(action = activity) | ||
): T = flakySafely(action = { | ||
interaction.reFindUiObject() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improvements of Kautomator stability There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you describe the problem? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
activity.invoke() | ||
}) | ||
|
||
/** | ||
* Wraps the given [activity] invocation with the flaky safety. | ||
|
@@ -43,5 +46,8 @@ class FlakySafeObjectBehaviorInterceptor( | |
interaction: UiObjectInteraction, | ||
action: UiObjectAction, | ||
activity: () -> T | ||
): T = flakySafely(action = activity) | ||
): T = flakySafely(action = { | ||
interaction.reFindUiObject() | ||
activity.invoke() | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RuslanMingaliev need your help here