Skip to content

Commit

Permalink
Merge pull request #778 from zebrunner/develop
Browse files Browse the repository at this point in the history
2.5.2
  • Loading branch information
vdelendik authored Aug 29, 2023
2 parents ede13e4 + 0127973 commit 24df404
Show file tree
Hide file tree
Showing 28 changed files with 834 additions and 629 deletions.
4 changes: 2 additions & 2 deletions lib/units/ios-device/plugins/devicenotifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = syrup.serial()
const log = logger.createLogger('device:plugins:notifier')
const notifier = {}

notifier.setDeviceTemporaryUnavialable = function(err) {
notifier.setDeviceTemporaryUnavailable = function(err) {
group.get()
.then((currentGroup) => {
push.send([
Expand All @@ -22,7 +22,7 @@ module.exports = syrup.serial()
])
})
.catch(err => {
log.error('Cannot set device temporary unavialable', err)
log.error('Cannot set device temporary unavailable', err)
})
}

Expand Down
6 changes: 0 additions & 6 deletions lib/units/ios-device/plugins/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ function execShellCommand(cmd) {
}

const installApp = (udid, filepath, id, isSimulator) => {
// #565 unable to do go-ios actions vs iOS with dashes in udid
udid = udid.replace("-", "")

const simulatorCommands = [
`cd ${filepath} && unzip * && xcrun simctl install ${udid} *.app`,
];
Expand All @@ -54,9 +51,6 @@ const installApp = (udid, filepath, id, isSimulator) => {
}

const launchApp = (udid, bundleId, isSimulator) => {
// #565 unable to do go-ios actions vs iOS with dashes in udid
udid = udid.replace("-", "")

const simulatorCommands = [
`xcrun simctl launch ${udid} ${bundleId}`,
];
Expand Down
2 changes: 1 addition & 1 deletion lib/units/ios-device/plugins/reboot.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = syrup.serial()

router.on(wire.RebootMessage, (channel) => {
const reply = wireutil.reply(options.serial)
let udid = options.serial.replace("-", "")
let udid = options.serial
exec(`ios reboot --udid=${udid}`) // this command that launches restart
Promise.delay(5000)
.then(() => {
Expand Down
28 changes: 23 additions & 5 deletions lib/units/ios-device/plugins/screen/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = syrup.serial()

function handleSocketError(err, message) {
log.error(message, err)
notifier.setDeviceTemporaryUnavialable(err)
notifier.setDeviceTemporaryUnavailable(err)
ws.close()
}

Expand Down Expand Up @@ -92,10 +92,28 @@ module.exports = syrup.serial()

ws.on('close', function() {
// @TODO handle close event
//stream.socket.onclose()
WdaClient.stopSession()
isConnectionAlive = false
log.important('ws on close event')
// stream.socket.onclose()
const orientation = WdaClient.orientation

const stoppingSession = () => {
WdaClient.stopSession()
isConnectionAlive = false
log.important('ws on close event')
}

if (orientation === 'PORTRAIT') {
return stoppingSession()
}

// #770: Reset rotation to Portrait when closing device

const rotationPromise = new Promise((resolve, reject) => {
// Ensure that rotation is done, then stop session
WdaClient.rotation({orientation: 'PORTRAIT'})
resolve()
})

rotationPromise.then(() => stoppingSession())
})
ws.on('error', function() {
// @TODO handle error event
Expand Down
12 changes: 12 additions & 0 deletions lib/units/ios-device/plugins/util/iosutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ let iosutil = {
return 'UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT'
}
},
orientationToDegrees: function(orientation) {
switch (orientation) {
case 'PORTRAIT':
return 0
case 'LANDSCAPE':
return 90
case 'UIA_DEVICE_ORIENTATION_PORTRAIT_UPSIDEDOWN':
return 180
case 'UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT':
return 270
}
},
pressButton: function(key) {
switch (key) {
case 'volume_up':
Expand Down
28 changes: 24 additions & 4 deletions lib/units/ios-device/plugins/wda/WdaClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ module.exports = syrup.serial()
return Promise.resolve()
}

this.handleRequest({
return this.handleRequest({
method: 'DELETE',
uri: `${this.baseUrl}/session/${currentSessionId}`
})

},
typeKey: function(params) {

Expand Down Expand Up @@ -533,8 +534,17 @@ module.exports = syrup.serial()
this.getOrientation()

this.size()
})

const rotationDegrees = iosutil.orientationToDegrees(this.orientation)

push.send([
wireutil.global,
wireutil.envelope(new wire.RotationEvent(
options.serial,
rotationDegrees
))
])
})
},
batteryIosEvent: function() {
return this.handleRequest({
Expand Down Expand Up @@ -636,13 +646,23 @@ module.exports = syrup.serial()
return resolve(response)
})
.catch(err => {
let errMes = err.error.value.message

// #762: Skip lock error message
if (err.error.value.message.includes('Timed out while waiting until the screen gets locked')) {
if (errMes.includes('Timed out while waiting until the screen gets locked')) {
return
}
if (err.error.value.message.includes('Unable To Rotate Device')) {

// #765: Skip rotation error message
if (errMes.includes('Unable To Rotate Device')) {
return log.info('The current application does not support rotation')
}

// #770 Skip session crash, immediately restart after Portrait mode reset
if (errMes.includes('Session does not exist')) {
return this.startSession()
}

recoverDevice()
// #409: capture wda/appium crash asap and exit with status 1 from stf
//notifier.setDeviceTemporaryUnavialable(err)
Expand Down
13 changes: 1 addition & 12 deletions lib/units/websocket/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,17 +400,6 @@ module.exports = function(options) {
}
})
})
.on(wire.ConnectivityEvent, function(channel, message) {
var {serial} = message
delete message.serial
socket.emit('device.change', {
important: false,
data: {
serial: serial,
network: message
}
})
})
.on(wire.PhoneStateEvent, function(channel, message) {
var {serial} = message
delete message.serial
Expand Down Expand Up @@ -676,7 +665,7 @@ module.exports = function(options) {
} catch(e) {
log.error(e)
}

})
.on('input.touchMoveIos', function(channel, data) {
data.duration = 0.042
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = function blurElementDirective($parse, $timeout) {
module.exports = function blurElementDirective(
$parse,
$rootScope,
$timeout,
) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
Expand All @@ -13,7 +17,15 @@ module.exports = function blurElementDirective($parse, $timeout) {
})

element.bind('blur', function() {
scope.$apply(model.assign(scope, false))
if(!$rootScope.$$phase) {
scope.$apply(() => {
model.assign(scope, false)
})
} else {
scope.$applyAsync(() => {
model.assign(scope, false)
})
}
})
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = function focusElementDirective($parse, $timeout) {
module.exports = function focusElementDirective(
$parse,
$rootScope,
$timeout,
) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
Expand All @@ -14,7 +18,15 @@ module.exports = function focusElementDirective($parse, $timeout) {

element.bind('blur', function() {
if (model && model.assign) {
scope.$apply(model.assign(scope, false))
if(!$rootScope.$$phase) {
scope.$apply(() => {
model.assign(scope, false)
})
} else {
scope.$applyAsync(() => {
model.assign(scope, false)
})
}
}
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
module.exports =
function FatalMessageServiceFactory($uibModal, $location, $route, $interval,
StateClassesService) {
var FatalMessageService = {}
function FatalMessageServiceFactory(
$interval,
$location,
$route,
$uibModal,
StateClassesService,
) {
const FatalMessageService = {}
let intervalDeviceInfo

var intervalDeviceInfo

var ModalInstanceCtrl = function($scope, $uibModalInstance, device,
tryToReconnect) {
const ModalInstanceCtrl = function(
$scope,
$uibModalInstance,
device,
tryToReconnect,
) {
$scope.ok = function() {
$uibModalInstance.close(true)
$route.reload()
Expand Down Expand Up @@ -43,7 +51,7 @@ module.exports =
$uibModalInstance.dismiss('cancel')
}

var destroyInterval = function() {
const destroyInterval = function() {
if (angular.isDefined(intervalDeviceInfo)) {
$interval.cancel(intervalDeviceInfo)
intervalDeviceInfo = undefined
Expand All @@ -56,7 +64,7 @@ module.exports =
}

FatalMessageService.open = function(device, tryToReconnect) {
var modalInstance = $uibModal.open({
const modalInstance = $uibModal.open({
template: require('./fatal-message.pug'),
controller: ModalInstanceCtrl,
resolve: {
Expand All @@ -73,8 +81,9 @@ module.exports =
}, function() {

})
}

return modalInstance
}

return FatalMessageService
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = angular.module('stf.temporarily-unavailable', [
require('stf/common-ui/modals/common').name
])
.factory('TemporarilyUnavailableService', require('./temporarily-unavailable-service'))
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
module.exports =
function TemporarilyUnavialableServiceFactory($uibModal, $location, $window) {
function TemporarilyUnavailableServiceFactory($uibModal, $location, $window, $route) {
var service = {}

var ModalInstanceCtrl = function($scope, $uibModalInstance, message) {
$scope.ok = function() {
$uibModalInstance.close(true)
$window.location.reload()
$route.reload() // TODO: check if works and git history
}

$scope.message = message

$scope.cancel = function() {
$uibModalInstance.dismiss('cancel')
//document.getElementById('temporarily-unavialable').remove()
}

$scope.second = function() {
$uibModalInstance.dismiss()
$location.path('/devices/')
//document.getElementById('temporarily-unavialable').remove()
}

}

service.open = function(message) {
const tempModal = document.getElementById('temporarily-unavialable')
const tempModal = document.getElementById('temporarily-unavailable')

if(!tempModal) {
var modalInstance = $uibModal.open({
template: require('./temporarily-unavialable.pug'),
template: require('./temporarily-unavailable.pug'),
controller: ModalInstanceCtrl,
resolve: {
message: function() {
return message
}
}
},
openedClass: '_temporarily-unavailable-modal',
windowClass: 'temporarily-unavailable-modal',
windowTopClass: '_top',
})

modalInstance.result.then(function() {
}, function() {
})

return modalInstance
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.stf-modal#temporarily-unavialable
.stf-modal#temporarily-unavailable
.modal-header.dialog-header-errorX
button(type='button', ng-click='cancel()').close ×
h4.modal-title.text-danger
Expand Down

This file was deleted.

Loading

0 comments on commit 24df404

Please sign in to comment.