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

Issue 249/compose support #307

Merged
merged 30 commits into from
Nov 15, 2021
Merged

Issue 249/compose support #307

merged 30 commits into from
Nov 15, 2021

Conversation

matzuk
Copy link
Member

@matzuk matzuk commented Nov 6, 2021

What remains:

  • autoscroll behavior interceptor for Jetpack Compose
  • compose (or-then) functionality for Jetpack Compose
  • Jetpack Compose tests on the JVM environment
  • Readme
  • Add ".idea" to VCS according to this article

enabled = false
}
}
// todo doesn't work on AGP 4.2.2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RuslanMingaliev such api is not available now

@@ -1,13 +1,15 @@
[versions]
kotlin = "1.4.32"
kotlin = "1.5.21"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.5.31 causes weird problems, postponed

}
}

// temp solution
Copy link
Member Author

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

kaspresso/build.gradle.kts Outdated Show resolved Hide resolved
kaspresso/build.gradle.kts Outdated Show resolved Hide resolved
@@ -30,7 +30,10 @@ class FlakySafeObjectBehaviorInterceptor(
interaction: UiObjectInteraction,
assertion: UiObjectAssertion,
activity: () -> T
): T = flakySafely(action = activity)
): T = flakySafely(action = {
interaction.reFindUiObject()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improvements of Kautomator stability

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you describe the problem?

Copy link
Member Author

@matzuk matzuk Nov 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This one must be relocated to a separate Interceptor. Thanks that you've highlighted.
  2. Good question about stability. So, the concept is similar to the one that we had in Loader...Interceptor. But, the architecture solution is better and the same with Jetpack Compose Intercepting (see old weird methods like loadView and etc.). Better stability is achieved due to changing the order of behavior interceptors (try to reload earlier). I think, there were cases when SystemDialog and Scrolling Interceptors consumed all allocated time, that's why there was no time to reload Element. But, I don't have tests where I can check it.
  3. Abstractions don't leak because BehaviorInterceptor offers access to all possible data (Interaction, Action, Assert). So, we give broad possibilities to do something with all of this. Also, I tried to reload an Element by using of custom getter where we recalculate the element. But, such a solution provides some edge cases like recalculation in absolutely all cases, possible caching of property that can lead to an inconsistent state, and others.

…er functionality is relocated from FlakySafety functionality to the separate classes

[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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мб нам его до 7 поднять?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried but I got a lot of errors with our plugins =(

eakurnikov
eakurnikov previously approved these changes Nov 9, 2021
Copy link
Collaborator

@eakurnikov eakurnikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nnoooice

interaction.perform(action)
},
operation = {
acc, deviceBehaviorInterceptor ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Линт внутри меня говорит, что тут форматирование поехало)0)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will check it

* @return true if object was found, false otherwise
*/
fun tryToFindUiObject(): Boolean {
private fun calculateUiObject(): UiObject2? {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему calculate то? Она вроде не считает ничего

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, maybe there is a sense to put another name.

package com.kaspersky.kaspressample.jetpackcompose.resources

// Like R, but C
object C {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это твое изобретение или это паттерн типо рекомендованный? Элементы по строке ищутся?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RuslanMingaliev suggested such an approach. I like it =)

kaspresso/build.gradle.kts Outdated Show resolved Hide resolved
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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too verbose logging, I think

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's not. Have a look at logs running examples.

@@ -30,7 +30,10 @@ class FlakySafeObjectBehaviorInterceptor(
interaction: UiObjectInteraction,
assertion: UiObjectAssertion,
activity: () -> T
): T = flakySafely(action = activity)
): T = flakySafely(action = {
interaction.reFindUiObject()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you describe the problem?

// 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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change the previous behavior?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous solution required an additional method of UiObjectInteractionDelegate which was too poor because made an abstraction leak.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a bug, there is a solution in the comments

Copy link
Member Author

Choose a reason for hiding this comment

The 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?

@matzuk matzuk merged commit f25f393 into master Nov 15, 2021
@AzamatCherchesov AzamatCherchesov deleted the issue-249/compose-support branch September 7, 2023 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants