Skip to content
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

Small improvements #334

Merged
merged 10 commits into from
Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Kaspresso is a great framework for UI testing. Based on [Espresso](https://developer.android.com/training/testing/espresso) and [UI Automator](https://developer.android.com/training/testing/ui-automator), Kaspresso provides a wide range of additional amazing features, such as:
* 100% stability, no flakiness.
* *[WIP] Jetpack Compose support.*
* Jetpack Compose support [since version 1.4].
* Significantly faster execution of UI Automator commands.
With Kaspresso, some UI Automator commands run **10 times faster**!
* Excellent readability due to human DSL.
Expand Down Expand Up @@ -252,7 +252,7 @@ dependencies {
androidTestImplementation 'com.kaspersky.android-components:kaspresso:<latest_version>'
# Allure support
androidTestImplementation "com.kaspersky.android-components:kaspresso-allure-support:<latest_version>"
# Jetpack Compose support
# Jetpack Compose support (since version 1.4)
androidTestImplementation "com.kaspersky.android-components:kaspresso-compose-support:<latest_version>"
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ plugins {
android {
testBuildType = "debug"

defaultConfig {
multiDexEnabled = true
}

variantFilter {
if (name != testBuildType) {
ignore = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ configure<BaseExtension> {
}

defaultConfig {
minSdk = 21
minSdk = 18
targetSdk = 30
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.kaspersky.components.composesupport.config
import com.kaspersky.components.composesupport.interceptors.behavior.SemanticsBehaviorInterceptor
import com.kaspersky.components.composesupport.interceptors.behavior.impl.autoscroll.AutoScrollSemanticsBehaviorInterceptor
import com.kaspersky.components.composesupport.interceptors.behavior.impl.elementloader.ElementLoaderSemanticsBehaviorInterceptor
import com.kaspersky.components.composesupport.interceptors.behavior.impl.failure.FailureLoggingSemanticsBehaviorInterceptor
import com.kaspersky.components.composesupport.interceptors.behavior.impl.flakysafety.FlakySafeSemanticsBehaviorInterceptor
import com.kaspersky.components.composesupport.interceptors.behavior.impl.systemsafety.SystemDialogSafetySemanticsBehaviorInterceptor
import com.kaspersky.components.composesupport.interceptors.watcher.SemanticsWatcherInterceptor
Expand Down Expand Up @@ -42,15 +41,13 @@ class ComposeConfig {
adbServer
),
ElementLoaderSemanticsBehaviorInterceptor(libLogger, elementLoaderParams),
FlakySafeSemanticsBehaviorInterceptor(flakySafetyParams, libLogger),
FailureLoggingSemanticsBehaviorInterceptor(libLogger)
FlakySafeSemanticsBehaviorInterceptor(flakySafetyParams, libLogger)
)
} else {
mutableListOf(
AutoScrollSemanticsBehaviorInterceptor(libLogger, autoScrollParams),
ElementLoaderSemanticsBehaviorInterceptor(libLogger, elementLoaderParams),
FlakySafeSemanticsBehaviorInterceptor(flakySafetyParams, libLogger),
FailureLoggingSemanticsBehaviorInterceptor(libLogger)
FlakySafeSemanticsBehaviorInterceptor(flakySafetyParams, libLogger)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ 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
* Important!
* By default, the interceptor is not used in Kaspresso because this one pollutes logs by error messages that may confuse a user.
* If you desire to change result log (especially in case of an error) we recommend to use [FailureLoggingProvider] directly.
*/
class FailureLoggingSemanticsBehaviorInterceptor(
logger: UiTestLogger
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ androidXCore = "androidx.core:core:1.7.0"
appcompat = "androidx.appcompat:appcompat:1.4.0"
material = "com.google.android.material:material:1.4.0"
constraint = "androidx.constraintlayout:constraintlayout:2.1.2"
multidex = "androidx.multidex:multidex:2.0.1"

lifecycleViewModelKtx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
lifecycleLiveDataKtx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecycle" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import com.kaspersky.kaspresso.logger.UiTestLogger
* The implementation of [DataBehaviorInterceptor] and [FailureLoggingProvider] interfaces.
* Provides failure logging functionality for [DataInteraction.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
* Important!
* By default, the interceptor is not used in Kaspresso because this one pollutes logs by error messages that may confuse a user.
* If you desire to change result log (especially in case of an error) we recommend to use [FailureLoggingProvider] directly.
*/
class FailureLoggingDataBehaviorInterceptor(
logger: UiTestLogger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import com.kaspersky.kaspresso.logger.UiTestLogger
* The implementation of [ViewBehaviorInterceptor] and [FailureLoggingProvider] interfaces.
* Provides failure logging functionality for [ViewInteraction.perform] and [ViewInteraction.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
* Important!
* By default, the interceptor is not used in Kaspresso because this one pollutes logs by error messages that may confuse a user.
* If you desire to change result log (especially in case of an error) we recommend to use [FailureLoggingProvider] directly.
*/
class FailureLoggingViewBehaviorInterceptor(
logger: UiTestLogger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import com.kaspersky.kaspresso.logger.UiTestLogger
* The implementation of [WebBehaviorInterceptor] and [FailureLoggingProvider] interfaces.
* Provides failure logging functionality for [Web.WebInteraction.perform] and [Web.WebInteraction.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
* Important!
* By default, the interceptor is not used in Kaspresso because this one pollutes logs by error messages that may confuse a user.
* If you desire to change result log (especially in case of an error) we recommend to use [FailureLoggingProvider] directly.
*/
class FailureLoggingWebBehaviorInterceptor(
logger: UiTestLogger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import com.kaspersky.kaspresso.logger.UiTestLogger
* The implementation of [DeviceBehaviorInterceptor] and [FailureLoggingProvider] interfaces.
* Provides failure logging functionality for [UiDeviceInteraction.perform] and [UiDeviceInteraction.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
* Important!
* By default, the interceptor is not used in Kaspresso because this one pollutes logs by error messages that may confuse a user.
* If you desire to change result log (especially in case of an error) we recommend to use [FailureLoggingProvider] directly.
*/
class FailureLoggingDeviceBehaviorInterceptor(
logger: UiTestLogger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import com.kaspersky.kaspresso.logger.UiTestLogger
* The implementation of [ObjectBehaviorInterceptor] and [FailureLoggingProvider] interfaces.
* Provides failure logging functionality for [UiObjectInteraction.perform] and [UiObjectInteraction.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
* Important!
* By default, the interceptor is not used in Kaspresso because this one pollutes logs by error messages that may confuse a user.
* If you desire to change result log (especially in case of an error) we recommend to use [FailureLoggingProvider] directly.
*/
class FailureLoggingObjectBehaviorInterceptor(
logger: UiTestLogger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ import com.kaspersky.kaspresso.interceptors.behavior.ViewBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behavior.WebBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behavior.impl.autoscroll.AutoScrollViewBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behavior.impl.autoscroll.AutoScrollWebBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behavior.impl.failure.FailureLoggingDataBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behavior.impl.failure.FailureLoggingViewBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behavior.impl.failure.FailureLoggingWebBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behavior.impl.flakysafety.FlakySafeDataBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behavior.impl.flakysafety.FlakySafeViewBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behavior.impl.flakysafety.FlakySafeWebBehaviorInterceptor
Expand All @@ -84,8 +81,6 @@ import com.kaspersky.kaspresso.interceptors.behaviorkautomator.DeviceBehaviorInt
import com.kaspersky.kaspresso.interceptors.behaviorkautomator.ObjectBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.autoscroll.AutoScrollObjectBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.elementloader.ElementLoaderObjectBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.failure.FailureLoggingDeviceBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.failure.FailureLoggingObjectBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.flakysafety.FlakySafeDeviceBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.flakysafety.FlakySafeObjectBehaviorInterceptor
import com.kaspersky.kaspresso.interceptors.behaviorkautomator.impl.systemsafety.SystemDialogSafetyDeviceBehaviorInterceptor
Expand Down Expand Up @@ -832,12 +827,10 @@ data class Kaspresso(
instrumentalDependencyProviderFactory.getInterceptorProvider<SystemDialogSafetyViewBehaviorInterceptor>(instrumentation),
adbServer
),
FlakySafeViewBehaviorInterceptor(flakySafetyParams, libLogger),
FailureLoggingViewBehaviorInterceptor(libLogger)
FlakySafeViewBehaviorInterceptor(flakySafetyParams, libLogger)
) else mutableListOf(
AutoScrollViewBehaviorInterceptor(autoScrollParams, libLogger),
FlakySafeViewBehaviorInterceptor(flakySafetyParams, libLogger),
FailureLoggingViewBehaviorInterceptor(libLogger)
FlakySafeViewBehaviorInterceptor(flakySafetyParams, libLogger)
)

if (!::dataBehaviorInterceptors.isInitialized) dataBehaviorInterceptors =
Expand All @@ -847,11 +840,9 @@ data class Kaspresso(
instrumentalDependencyProviderFactory.getInterceptorProvider<SystemDialogSafetyViewBehaviorInterceptor>(instrumentation),
adbServer
),
FlakySafeDataBehaviorInterceptor(flakySafetyParams, libLogger),
FailureLoggingDataBehaviorInterceptor(libLogger)
FlakySafeDataBehaviorInterceptor(flakySafetyParams, libLogger)
) else mutableListOf(
FlakySafeDataBehaviorInterceptor(flakySafetyParams, libLogger),
FailureLoggingDataBehaviorInterceptor(libLogger)
FlakySafeDataBehaviorInterceptor(flakySafetyParams, libLogger)
)

if (!::webBehaviorInterceptors.isInitialized) webBehaviorInterceptors =
Expand All @@ -863,14 +854,12 @@ data class Kaspresso(
instrumentalDependencyProviderFactory.getInterceptorProvider<SystemDialogSafetyViewBehaviorInterceptor>(instrumentation),
adbServer
),
FlakySafeWebBehaviorInterceptor(flakySafetyParams, libLogger),
FailureLoggingWebBehaviorInterceptor(libLogger)
FlakySafeWebBehaviorInterceptor(flakySafetyParams, libLogger)
)
} else {
mutableListOf(
AutoScrollWebBehaviorInterceptor(autoScrollParams, libLogger),
FlakySafeWebBehaviorInterceptor(flakySafetyParams, libLogger),
FailureLoggingWebBehaviorInterceptor(libLogger)
FlakySafeWebBehaviorInterceptor(flakySafetyParams, libLogger)
)
}

Expand All @@ -882,8 +871,7 @@ data class Kaspresso(
adbServer
),
ElementLoaderObjectBehaviorInterceptor(libLogger, elementLoaderParams),
FlakySafeObjectBehaviorInterceptor(flakySafetyParams, libLogger),
FailureLoggingObjectBehaviorInterceptor(libLogger)
FlakySafeObjectBehaviorInterceptor(flakySafetyParams, libLogger)
)

if (!::deviceBehaviorInterceptors.isInitialized) deviceBehaviorInterceptors = mutableListOf(
Expand All @@ -892,8 +880,7 @@ data class Kaspresso(
instrumentalDependencyProviderFactory.getInterceptorProvider<SystemDialogSafetyViewBehaviorInterceptor>(instrumentation),
adbServer
),
FlakySafeDeviceBehaviorInterceptor(flakySafetyParams, libLogger),
FailureLoggingDeviceBehaviorInterceptor(libLogger)
FlakySafeDeviceBehaviorInterceptor(flakySafetyParams, libLogger)
)

if (!::stepWatcherInterceptors.isInitialized) stepWatcherInterceptors = mutableListOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.kaspersky.components.kautomator.component.common.assertions

import com.google.common.truth.Truth.assertThat
import com.kaspersky.components.kautomator.intercept.delegate.UiObjectInteractionDelegate
import com.kaspersky.components.kautomator.intercept.exception.UnfoundedUiObjectException
import com.kaspersky.components.kautomator.intercept.operation.UiOperationType

/**
Expand All @@ -27,18 +26,11 @@ interface UiBaseAssertions {
* Checks if the view is not completely displayed
*/
fun isNotDisplayed() {
// the implementation is a little bit tricky because
// UiObjectInteractionDelegate throws UnfoundedUiObjectException in case of absence of a related UIObject2
// that's why we just catch the mentioned exception and do a final check
val notDisplayed = try {
isDisplayed()
false
} catch (exception: UnfoundedUiObjectException) {
true
} catch (exception: Throwable) {
false
}
assertThat(notDisplayed).isTrue()
// the implementation is a little bit tricky skipping 'view.check' way
// the reason: nullable uiObject2 triggers the work of all behavior Interceptors
// which can lead to unexpected behavior
// that's why we check uiObject2 directly
assertThat(view.interaction.uiObject2).isNull()
}

/**
Expand Down
1 change: 1 addition & 0 deletions samples/adbserver-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ dependencies {
implementation(libs.kotlinStdlib)
implementation(libs.appcompat)
implementation(projects.adbServer.adbserverDevice)
implementation(libs.multidex)
}
3 changes: 2 additions & 1 deletion samples/adbserver-sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name="androidx.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand All @@ -22,4 +23,4 @@
</activity>
</application>

</manifest>
</manifest>
1 change: 1 addition & 0 deletions samples/kaspresso-allure-support-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies {
implementation(libs.appcompat)
implementation(libs.material)
implementation(libs.constraint)
implementation(libs.multidex)

androidTestImplementation(projects.kaspresso)
androidTestImplementation(projects.allureSupport)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
tools:ignore="ScopedStorage" />

<application
android:name="androidx.multidex.MultiDexApplication"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
tools:ignore="AllowBackup,GoogleAppIndexingWarning,MissingApplicationIcon">
Expand Down
2 changes: 2 additions & 0 deletions samples/kaspresso-compose-support-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ plugins {

android {
defaultConfig {
minSdk = 21

applicationId = "com.kaspersky.kaspresso.composesupport.com.kaspersky.kaspresso.composesupport.sample"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments["clearPackageData"] = "true"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package com.kaspersky.kaspresso.composesupport.sample.features.flaky

import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.plus

private const val TIMEOUT = 1_000L

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package com.kaspersky.kaspresso.composesupport.sample.features.main

import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
Expand Down
1 change: 1 addition & 0 deletions samples/kaspresso-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies {
implementation(libs.appcompat)
implementation(libs.material)
implementation(libs.constraint)
implementation(libs.multidex)

androidTestImplementation(libs.junit)
androidTestImplementation(projects.kaspresso)
Expand Down
1 change: 1 addition & 0 deletions samples/kaspresso-sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" tools:ignore="ProtectedPermissions"/>

<application
android:name="androidx.multidex.MultiDexApplication"
android:requestLegacyExternalStorage="true"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
Expand Down
Loading