Skip to content

Commit

Permalink
Map Touchscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Apr 23, 2024
1 parent 71c0c04 commit f18d21e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 8 additions & 1 deletion browser/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ func mapPage(vu moduleVU, p *common.Page) mapping {
"throttleCPU": p.ThrottleCPU,
"throttleNetwork": p.ThrottleNetwork,
"title": p.Title,
"touchscreen": rt.ToValue(p.GetTouchscreen()).ToObject(rt),
"touchscreen": mapTouchscreen(vu, p.GetTouchscreen()),
"type": p.Type,
"uncheck": p.Uncheck,
"url": p.URL,
Expand Down Expand Up @@ -788,6 +788,13 @@ func mapPage(vu moduleVU, p *common.Page) mapping {
return maps
}

// mapTouchscreen to the JS module.
func mapTouchscreen(_ moduleVU, ts *common.Touchscreen) mapping {
return mapping{
"tap": ts.Tap,
}
}

// mapWorker to the JS module.
func mapWorker(vu moduleVU, w *common.Worker) mapping {
return mapping{
Expand Down
11 changes: 7 additions & 4 deletions browser/mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ func TestMappings(t *testing.T) {
return mapConsoleMessage(moduleVU{VU: vu}, &common.ConsoleMessage{})
},
},
"mapTouchscreen": {
apiInterface: (*touchscreenAPI)(nil),
mapp: func() mapping {
return mapTouchscreen(moduleVU{VU: vu}, &common.Touchscreen{})
},
},
} {
tt := tt
t.Run(name, func(t *testing.T) {
Expand Down Expand Up @@ -520,10 +526,7 @@ type keyboardAPI interface { //nolint: unused
}

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

Expand Down

0 comments on commit f18d21e

Please sign in to comment.