mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 08:03:30 +02:00
Implement clearBrowser().
This commit is contained in:
@@ -12,14 +12,16 @@ module.exports = syrup.serial()
|
||||
.define(function(options, router, push, adb, input) {
|
||||
var log = logger.createLogger('device:plugins:browsers')
|
||||
|
||||
function pkg(component) {
|
||||
return component.split('/', 1)[0]
|
||||
}
|
||||
|
||||
log.info('Fetching browser list')
|
||||
return input.getBrowsers()
|
||||
.timeout(15000)
|
||||
.then(function(browsers) {
|
||||
browsers.apps.forEach(function(app) {
|
||||
var pkg = app.component.split('/', 1)[0]
|
||||
|
||||
switch (pkg) {
|
||||
switch (pkg(app.component)) {
|
||||
case 'com.android.chrome':
|
||||
app.type = 'chrome'
|
||||
break
|
||||
@@ -66,6 +68,24 @@ module.exports = syrup.serial()
|
||||
})
|
||||
})
|
||||
|
||||
router.on(wire.BrowserClearMessage, function(channel, message) {
|
||||
var reply = wireutil.reply(options.serial)
|
||||
adb.clear(options.serial, pkg(message.browser))
|
||||
.then(function() {
|
||||
push.send([
|
||||
channel
|
||||
, reply.okay()
|
||||
])
|
||||
})
|
||||
.catch(function(err) {
|
||||
log.error('Browser could not be cleared', err.stack)
|
||||
push.send([
|
||||
channel
|
||||
, reply.fail()
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
return browsers
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user