2022-12-28 11:27:48 +11:00
|
|
|
package components
|
|
|
|
|
|
|
|
type MenuDriver struct {
|
|
|
|
t *TestDriver
|
|
|
|
hasCheckedTitle bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *MenuDriver) getViewDriver() *ViewDriver {
|
|
|
|
return self.t.Views().Menu()
|
|
|
|
}
|
|
|
|
|
|
|
|
// asserts that the popup has the expected title
|
2023-06-03 15:12:31 +10:00
|
|
|
func (self *MenuDriver) Title(expected *TextMatcher) *MenuDriver {
|
2022-12-28 11:27:48 +11:00
|
|
|
self.getViewDriver().Title(expected)
|
|
|
|
|
|
|
|
self.hasCheckedTitle = true
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
2023-12-22 17:31:45 +01:00
|
|
|
func (self *MenuDriver) Confirm() *MenuDriver {
|
2022-12-28 11:27:48 +11:00
|
|
|
self.checkNecessaryChecksCompleted()
|
|
|
|
|
|
|
|
self.getViewDriver().PressEnter()
|
2023-12-22 17:31:45 +01:00
|
|
|
|
|
|
|
return self
|
2022-12-28 11:27:48 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *MenuDriver) Cancel() {
|
|
|
|
self.checkNecessaryChecksCompleted()
|
|
|
|
|
|
|
|
self.getViewDriver().PressEscape()
|
|
|
|
}
|
|
|
|
|
2023-06-03 15:12:31 +10:00
|
|
|
func (self *MenuDriver) Select(option *TextMatcher) *MenuDriver {
|
2023-02-26 11:49:15 +11:00
|
|
|
self.getViewDriver().NavigateToLine(option)
|
2022-12-28 11:27:48 +11:00
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
2023-06-03 15:12:31 +10:00
|
|
|
func (self *MenuDriver) Lines(matchers ...*TextMatcher) *MenuDriver {
|
2023-02-19 14:47:07 +11:00
|
|
|
self.getViewDriver().Lines(matchers...)
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
2023-06-03 15:12:31 +10:00
|
|
|
func (self *MenuDriver) TopLines(matchers ...*TextMatcher) *MenuDriver {
|
2023-02-19 14:47:07 +11:00
|
|
|
self.getViewDriver().TopLines(matchers...)
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
2023-06-03 16:10:53 +10:00
|
|
|
func (self *MenuDriver) Filter(text string) *MenuDriver {
|
|
|
|
self.getViewDriver().FilterOrSearch(text)
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *MenuDriver) LineCount(matcher *IntMatcher) *MenuDriver {
|
|
|
|
self.getViewDriver().LineCount(matcher)
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
2023-08-04 09:15:07 +10:00
|
|
|
func (self *MenuDriver) Wait(milliseconds int) *MenuDriver {
|
|
|
|
self.getViewDriver().Wait(milliseconds)
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
2023-08-10 09:39:26 +02:00
|
|
|
func (self *MenuDriver) Tooltip(option *TextMatcher) *MenuDriver {
|
|
|
|
self.t.Views().Tooltip().Content(option)
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
2023-12-22 17:31:45 +01:00
|
|
|
func (self *MenuDriver) Tap(f func()) *MenuDriver {
|
|
|
|
self.getViewDriver().Tap(f)
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
2022-12-28 11:27:48 +11:00
|
|
|
func (self *MenuDriver) checkNecessaryChecksCompleted() {
|
|
|
|
if !self.hasCheckedTitle {
|
|
|
|
self.t.Fail("You must check the title of a menu popup by calling Title() before calling Confirm()/Cancel().")
|
|
|
|
}
|
|
|
|
}
|