Skip to content

Commit

Permalink
Merge pull request #882 from zebrunner/develop
Browse files Browse the repository at this point in the history
2.6.3 rc
  • Loading branch information
vdelendik authored Jan 30, 2024
2 parents 8c0f75a + 675628e commit c2d4de5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
3 changes: 3 additions & 0 deletions lib/units/device/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ module.exports = function(options) {
.consume(options)
.catch(function(err) {
log.fatal('Setup had an error', err.stack)
if (err.stack.includes("no service started")) {
return lifecycle.graceful(err.stack)
}
lifecycle.fatal()
})
}
9 changes: 9 additions & 0 deletions lib/units/ios-device/plugins/wda.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ module.exports = syrup.serial()
wdaClient.rotation({orientation: 'PORTRAIT'}).then(() => {
iosutil.pressButton.call(wdaClient, message.key)
})
.catch(err => {
log.error('Failed to rotate device to : ', rotation, err)
})
}
// On portait mode -> home button directly
iosutil.pressButton.call(wdaClient, message.key)
Expand Down Expand Up @@ -64,6 +67,12 @@ module.exports = syrup.serial()
// wdaClient.openUrl({url: 'https://www.google.com'})
// })
.on(wire.RotateMessage, (channel, message) => {

// #875 Ignore rotation operation while device is rotating
if (wdaClient.isRotating) {
return
}

const rotation = iosutil.degreesToOrientation(message.rotation)
wdaClient.rotation({orientation: rotation})
.then(() => {
Expand Down
13 changes: 9 additions & 4 deletions lib/units/ios-device/plugins/wda/WdaClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = syrup.serial()
typeKeyDelay: 250,
upperCase: false,
isSwiping: false,
isRotating: false,

startSession: function() {
log.info('verifying wda session status...')
Expand Down Expand Up @@ -459,10 +460,10 @@ module.exports = syrup.serial()
uri: `${options.storageUrl}api/v1/devices/${options.serial}/size`,
})
.then((windowSizeResponse) => {
let {height, width, scale} = JSON.parse(windowSizeResponse)
let {dbHeight, dbWidth, dbScale} = JSON.parse(windowSizeResponse)

// First device session
if (!height || !width || !scale) {
if (!dbHeight || !dbWidth || !dbScale) {
return this.handleRequest({
method: 'GET',
uri: `${this.baseUrl}/session/${this.sessionId}/window/size`,
Expand Down Expand Up @@ -500,9 +501,9 @@ module.exports = syrup.serial()
} else {
log.info('Reusing device size/scale')
if (this.orientation === 'PORTRAIT') {
this.deviceSize = { height: height /= scale, width: width /= scale }
this.deviceSize = { height: dbHeight /= dbScale, width: dbWidth /= dbScale }
} else if (this.orientation === 'LANDSCAPE') {
this.deviceSize = { height: width /= scale, width: height /= scale }
this.deviceSize = { height: dbWidth /= dbScale, width: dbHeight /= dbScale }
}
return this.deviceSize
}
Expand Down Expand Up @@ -566,6 +567,8 @@ module.exports = syrup.serial()
rotation: function(params) {
this.orientation = params.orientation

this.isRotating = true

return this.handleRequest({
method: 'POST',
uri: `${this.baseUrl}/session/${this.sessionId}/orientation`,
Expand All @@ -585,6 +588,8 @@ module.exports = syrup.serial()
rotationDegrees
))
])

this.isRotating = false
})
},
batteryIosEvent: function() {
Expand Down
2 changes: 1 addition & 1 deletion lib/units/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ module.exports = function(options) {
7
))
])
return Promise.delay(3000).then(lifecycle.graceful(err))
return Promise.delay(3000).then(lifecycle.fatal(err))
}
})
}
Expand Down

0 comments on commit c2d4de5

Please sign in to comment.