-
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 all 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.5" | ||
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,55 @@ | ||
package com.kaspersky.kaspresso.autoscroll | ||
|
||
import androidx.compose.ui.test.performScrollTo | ||
import com.kaspersky.kaspresso.internal.extensions.other.isAllowed | ||
import com.kaspersky.kaspresso.logger.UiTestLogger | ||
import com.kaspersky.kaspresso.params.AutoScrollParams | ||
import io.github.kakaocup.compose.intercept.interaction.ComposeInteraction | ||
|
||
class SemanticsAutoScrollProviderImpl( | ||
private val logger: UiTestLogger, | ||
private val autoScrollParams: AutoScrollParams | ||
) : AutoScrollProvider<ComposeInteraction> { | ||
|
||
/** | ||
* Invokes the given [action] and calls [scroll] if it fails. Helps in cases when test fails because of the | ||
* need to scroll to interacted view. | ||
* | ||
* @param interaction the instance of [ComposeInteraction] interface to perform actions and assertions. | ||
* @param action the actual action on the interacted view. | ||
* | ||
* @throws Throwable if the exception caught while invoking [action] is not allowed via [ALLOWED_EXCEPTIONS]. | ||
* @return the result of [action] invocation. | ||
*/ | ||
override fun <T> withAutoScroll(interaction: ComposeInteraction, action: () -> T): T { | ||
return try { | ||
action.invoke() | ||
} catch (error: Throwable) { | ||
if (error.isAllowed(autoScrollParams.allowedExceptions)) { | ||
return scroll(interaction, action, error) | ||
} | ||
throw error | ||
} | ||
} | ||
|
||
/** | ||
* Performs the autoscrolling functionality. Performs scroll and re-invokes the given [action]. | ||
* | ||
* @param interaction the instance of [ComposeInteraction] interface to perform actions and assertions. | ||
* @param action the actual action on the interacted view. | ||
* @param cachedError the error to be thrown if autoscroll would not help. | ||
* | ||
* @throws cachedError if autoscroll action did not help. | ||
* @return the result of [action] invocation. | ||
*/ | ||
override fun <T> scroll(interaction: ComposeInteraction, action: () -> T, cachedError: Throwable): T { | ||
return try { | ||
interaction.semanticsNodeInteraction.performScrollTo() | ||
logger.i("SemanticsNodeInteraction autoscroll successfully performed.") | ||
action.invoke() | ||
} catch (error: Throwable) { | ||
logger.i("SemanticsNodeInteraction autoscroll did not help. Throwing exception.") | ||
throw cachedError | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.kaspersky.kaspresso.elementloader | ||
|
||
/** | ||
* The interface to provide element loader functionality. | ||
*/ | ||
interface ElementLoaderProvider { | ||
|
||
/** | ||
* Invokes the given [action] and calls [elementLoader] if it fails. Helps in cases when test fails because | ||
* the element is outdated and must be reloaded using its selectors/matchers. | ||
* | ||
* @param elementLoader the lambda to reload the element. | ||
* @param action the actual action on the interacted view. | ||
* | ||
* @return the result of [action] invocation. | ||
*/ | ||
fun <ActionType> passAction( | ||
elementLoader: () -> Unit, | ||
action: () -> ActionType | ||
): ActionType | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.kaspersky.kaspresso.elementloader | ||
|
||
import com.kaspersky.kaspresso.internal.extensions.other.isAllowed | ||
import com.kaspersky.kaspresso.logger.UiTestLogger | ||
import com.kaspersky.kaspresso.params.ElementLoaderParams | ||
|
||
/** | ||
* The implementation of the [ElementLoaderProvider] interface | ||
*/ | ||
class ElementLoaderProviderImpl( | ||
private val logger: UiTestLogger, | ||
private val params: ElementLoaderParams, | ||
) : ElementLoaderProvider { | ||
|
||
/** | ||
* Invokes the given [action] and calls [elementLoader] if it fails. Helps in cases when test fails because | ||
* the element is outdated and must be reloaded using its selectors/matchers. | ||
* | ||
* @param elementLoader the lambda to reload the element. | ||
* @param action the actual action on the interacted view. | ||
* | ||
* @return the result of [action] invocation. | ||
*/ | ||
override fun <ActionType> passAction( | ||
elementLoader: () -> Unit, | ||
action: () -> ActionType | ||
): ActionType { | ||
return try { | ||
action.invoke() | ||
} catch (error: Throwable) { | ||
matzuk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (error.isAllowed(params.allowedExceptions)) { | ||
logger.i("Reloading of the element is started") | ||
elementLoader.invoke() | ||
logger.i("Reloading of the element is finished") | ||
logger.i("Repeat action again with the reloaded element") | ||
action.invoke() | ||
} else { | ||
throw error | ||
} | ||
} | ||
} | ||
} |
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