Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit afc9230

Browse files
committed
Map Touchscreen
1 parent 982e39c commit afc9230

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

browser/mapping.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ func mapPage(vu moduleVU, p *common.Page) mapping {
709709
"throttleCPU": p.ThrottleCPU,
710710
"throttleNetwork": p.ThrottleNetwork,
711711
"title": p.Title,
712-
"touchscreen": rt.ToValue(p.GetTouchscreen()).ToObject(rt),
712+
"touchscreen": mapTouchscreen(vu, p.GetTouchscreen()),
713713
"type": p.Type,
714714
"uncheck": p.Uncheck,
715715
"url": p.URL,
@@ -788,6 +788,13 @@ func mapPage(vu moduleVU, p *common.Page) mapping {
788788
return maps
789789
}
790790

791+
// mapTouchscreen to the JS module.
792+
func mapTouchscreen(_ moduleVU, ts *common.Touchscreen) mapping {
793+
return mapping{
794+
"tap": ts.Tap,
795+
}
796+
}
797+
791798
// mapWorker to the JS module.
792799
func mapWorker(vu moduleVU, w *common.Worker) mapping {
793800
return mapping{

browser/mapping_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ func TestMappings(t *testing.T) {
193193
return mapConsoleMessage(moduleVU{VU: vu}, &common.ConsoleMessage{})
194194
},
195195
},
196+
"mapTouchscreen": {
197+
apiInterface: (*touchscreenAPI)(nil),
198+
mapp: func() mapping {
199+
return mapTouchscreen(moduleVU{VU: vu}, &common.Touchscreen{})
200+
},
201+
},
196202
} {
197203
tt := tt
198204
t.Run(name, func(t *testing.T) {
@@ -520,10 +526,7 @@ type keyboardAPI interface { //nolint: unused
520526
}
521527

522528
// touchscreenAPI is the interface of a touchscreen.
523-
// TODO: map this to page.GetTouchscreen(). Currently, the common.TouchscreenAPI type
524-
// mapping is not tested using this interface. We use the concrete type
525-
// without testing its exported methods.
526-
type touchscreenAPI interface { //nolint: unused
529+
type touchscreenAPI interface {
527530
Tap(x float64, y float64) error
528531
}
529532

0 commit comments

Comments
 (0)