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

#19 Use Espresso API to modify views #29

Merged
merged 14 commits into from May 30, 2023
Merged

#19 Use Espresso API to modify views #29

merged 14 commits into from May 30, 2023

Conversation

cmathew
Copy link
Contributor

@cmathew cmathew commented May 26, 2023

this lets developers avoid the issue of findById only returning the first match. I believe it also sets us up to support modifying RecyclerView content.

Keeps the ViewTreeMutator code, since we still want a way to globally modify views (e.g. hiding scrollbars).

@cmathew cmathew requested review from kyeungk and Kritarie May 26, 2023 00:04
@@ -29,34 +29,30 @@ android {
isReturnDefaultValues = true
}
}

sourceSets {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

replaced by screencaptor-test module

}

private fun compareScreenshots(actualScreenShotName: String, @RawRes expectedScreenShotId: Int) {
val screenshot = File(screenShotDirectory).listFiles()!!.find { it.name.contains(actualScreenShotName) }!!
Copy link
Contributor Author

@cmathew cmathew May 26, 2023

Choose a reason for hiding this comment

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

expanded these tests to verify expected pixels. I used raw instead of drawable so that density scaling wouldn't be a factor when comparing freshly-captured PNGs and Android resource PNG

fun getPerformAction(): ViewAction

fun getRestoreInteraction(): ViewInteraction
fun getRestoreAction(): ViewAction
Copy link
Contributor Author

Choose a reason for hiding this comment

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

each mutation knows how to undo itself. This is achieved by placing temporary data into View tags

mutateView(view, desiredValue)
}

protected abstract fun mutateView(view: S, value: T)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

because of the transient nature of their item views, recyclerviews don't use tags as an undo mechanism. They simply call notifyDataSetChanged when its time to reset items to their original state

import android.widget.TextView
import com.wealthfront.screencaptor.R

class TextViewMutator(content: CharSequence): ViewMutator<TextView, CharSequence>(TextView::class.java, content) {
Copy link
Contributor Author

@cmathew cmathew May 26, 2023

Choose a reason for hiding this comment

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

included implementations of some useful mutators: visibility, text, image

@cmathew cmathew merged commit 051950b into master May 30, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants