1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 10:39:25 +02:00

Model the touch plugin after the screen plugin's frame producer. This should allow more forgiving sudden deaths.

This commit is contained in:
Simo Kinnunen 2015-06-08 17:48:39 +09:00
parent f2fd3e54e1
commit a734b6e345
17 changed files with 597 additions and 232 deletions

View file

@ -11,16 +11,19 @@ var streamutil = require('../../../util/streamutil')
module.exports = syrup.serial()
.dependency(require('../support/adb'))
.dependency(require('../support/properties'))
.define(function(options, adb, properties) {
var log = logger.createLogger('device:resources:minitouch')
.dependency(require('../support/abi'))
.define(function(options, adb, properties, abi) {
var log = logger.createLogger('device:resources:minitouch') // jshint ignore:line
var resources = {
bin: {
src: pathutil.vendor(util.format(
'minitouch/%s/minitouch%s'
, properties['ro.product.cpu.abi']
, properties['ro.build.version.sdk'] < 16 ? '-nopie' : ''
))
src: pathutil.requiredMatch(abi.all.map(function(supportedAbi) {
return pathutil.vendor(util.format(
'minitouch/%s/minitouch%s'
, supportedAbi
, abi.pie ? '' : '-nopie'
))
}))
, dest: '/data/local/tmp/minitouch'
, comm: 'minitouch'
, mode: 0755
@ -48,29 +51,9 @@ module.exports = syrup.serial()
.return(res)
}
function ensureNotBusy(res) {
return adb.shell(options.serial, [res.dest, '-h'])
.timeout(10000)
.then(function(out) {
// Can be "Text is busy", "text busy"
return streamutil.findLine(out, (/busy/i))
.timeout(10000)
.then(function() {
log.info('Binary is busy, will retry')
return Promise.delay(1000)
})
.then(function() {
return ensureNotBusy(res)
})
.catch(streamutil.NoSuchLineError, function() {
return res
})
})
}
function installAll() {
return Promise.all([
removeResource(resources.bin).then(installResource).then(ensureNotBusy)
removeResource(resources.bin).then(installResource)
])
}
@ -89,6 +72,13 @@ module.exports = syrup.serial()
.then(function() {
return {
bin: resources.bin.dest
, run: function(cmd) {
return adb.shell(options.serial, util.format(
'exec %s%s'
, resources.bin.dest
, cmd ? util.format(' %s', cmd) : ''
))
}
}
})
})