Closed Vacxe closed 4 years ago
So, how do you plan to match ActionBar's children if they don't have id? The button at least is not a text view, so you can start with that
@Unlimity for both texts we can generalize solution F.E. hasText(<Str/Res>)
or match specific based on text sizes 👢 🔫 .
Also, I think that the navigation button should be a single button on this layout. Maybe first()
?
Yea. Menu buttons can be matched clearly.
Some code from one of my personal projects - in the base screen class I have a couple of methods
fun onToolbar(function: KActionbar.() -> Unit) =
KActionbar().apply(function)
fun onToolbar(id: Int, function: KToolbar.() -> Unit) =
KToolbar { withId(id) }.apply(function)
Allowing me to find either the normal action bar, or a toolbar in the layout with a particular ID. The definition for the action bar might be pertinent to your current issue -
class KActionbar : KBaseView<KActionbar>(
{ withResourceName("action_bar") }
), KToolbarAssertions
interface KToolbarAssertions : BaseAssertions {
fun hasTitle(title: String) {
view.check(matches(hasDescendant(withText(title))))
}
fun hasTitle(title: Int) {
view.check(matches(hasDescendant(withText(title))))
}
}
I was also unable to find the action bar by ID, but it does have a related resource name (action_bar
). And, for completeness, my KToolbar
that doesn't do a whole lot but I referenced in this comment
class KToolbar : KBaseView<KActionbar>, KToolbarAssertions {
constructor(function: ViewBuilder.() -> Unit) : super(function)
constructor(parent: Matcher<View>, function: ViewBuilder.() -> Unit) : super(parent, function)
constructor(parent: DataInteraction, function: ViewBuilder.() -> Unit) : super(parent, function)
}
Does that help at all?
@psh I don't think that base Screen should content this method. And yea, in your suggestion we still have the issue with title
matching.
In any case thanks for the assistance!
@Unlimity smth interesting mate.
IDK why this changes actually affected on AlertDialogTest
In any case, I'll double-check it but it's really odd
See #188
Issue: