-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
… to await screenshot completion
@@ -29,34 +29,30 @@ android { | |||
isReturnDefaultValues = true | |||
} | |||
} | |||
|
|||
sourceSets { |
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.
replaced by screencaptor-test module
} | ||
|
||
private fun compareScreenshots(actualScreenShotName: String, @RawRes expectedScreenShotId: Int) { | ||
val screenshot = File(screenShotDirectory).listFiles()!!.find { it.name.contains(actualScreenShotName) }!! |
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.
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 |
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.
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) |
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.
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) { |
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.
included implementations of some useful mutators: visibility, text, image
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).