blob: b226f08857357addc1b098019a109103b4cbe5c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package components
type ConfirmationAsserter struct {
t *TestDriver
hasCheckedTitle bool
hasCheckedContent bool
}
func (self *ConfirmationAsserter) getViewAsserter() *View {
return self.t.Views().Confirmation()
}
// asserts that the confirmation view has the expected title
func (self *ConfirmationAsserter) Title(expected *matcher) *ConfirmationAsserter {
self.getViewAsserter().Title(expected)
self.hasCheckedTitle = true
return self
}
// asserts that the confirmation view has the expected content
func (self *ConfirmationAsserter) Content(expected *matcher) *ConfirmationAsserter {
self.getViewAsserter().Content(expected)
self.hasCheckedContent = true
return self
}
func (self *ConfirmationAsserter) Confirm() {
self.checkNecessaryChecksCompleted()
self.getViewAsserter().PressEnter()
}
func (self *ConfirmationAsserter) Cancel() {
self.checkNecessaryChecksCompleted()
self.getViewAsserter().PressEscape()
}
func (self *ConfirmationAsserter) checkNecessaryChecksCompleted() {
if !self.hasCheckedContent || !self.hasCheckedTitle {
self.t.Fail("You must both check the content and title of a confirmation popup by calling Title()/Content() before calling Confirm()/Cancel().")
}
}
|