-
Notifications
You must be signed in to change notification settings - Fork 5
/
touch.go
33 lines (27 loc) · 1.14 KB
/
touch.go
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
package gwda_ext_opencv
func (dExt *DriverExt) ForceTouch(pathname string, pressure float64, duration ...float64) (err error) {
return dExt.ForceTouchOffset(pathname, pressure, 0.5, 0.5, duration...)
}
func (dExt *DriverExt) ForceTouchOffset(pathname string, pressure, xOffset, yOffset float64, duration ...float64) (err error) {
if len(duration) == 0 {
duration = []float64{1.0}
}
var x, y, width, height float64
if x, y, width, height, err = dExt.FindImageRectInUIKit(pathname); err != nil {
return err
}
return dExt.driver.ForceTouchFloat(x+width*xOffset, y+height*yOffset, pressure, duration[0])
}
func (dExt *DriverExt) TouchAndHold(pathname string, duration ...float64) (err error) {
return dExt.TouchAndHoldOffset(pathname, 0.5, 0.5, duration...)
}
func (dExt *DriverExt) TouchAndHoldOffset(pathname string, xOffset, yOffset float64, duration ...float64) (err error) {
if len(duration) == 0 {
duration = []float64{1.0}
}
var x, y, width, height float64
if x, y, width, height, err = dExt.FindImageRectInUIKit(pathname); err != nil {
return err
}
return dExt.driver.TouchAndHoldFloat(x+width*xOffset, y+height*yOffset, duration[0])
}