How to use DestHandler method in devicefarmer-stf

Best JavaScript code snippet using devicefarmer-stf

DraggableConnectionBehavior.js

Source:DraggableConnectionBehavior.js Github

copy

Full Screen

1import DragBehavior from './DragBehavior';2import { EVENT as CONNECTION_EVENT } from '../connection/Connection';3import { ORIENTATION, MODE as PORT_MODE } from '../connection/Port';4import Geometry from '../utils/Geometry';5import ShapeUI from '../shape/ShapeUI';6function getFakeDescription(position, shape) {7 const diff = Geometry.getNormalizedPosition(position, shape.getPosition());8 const bounds = shape.getBounds();9 let orientation = ORIENTATION.X;10 let direction;11 if (Geometry.isInBetween(position.x, bounds.left, bounds.right)) {12 orientation = ORIENTATION.Y;13 }14 if (orientation === ORIENTATION.Y) {15 direction = diff.y;16 } else {17 direction = diff.x;18 }19 return {20 direction,21 orientation,22 point: position,23 mode: PORT_MODE.DEST,24 };25}26class DraggableConnectionBehavior extends DragBehavior {27 constructor(target, settings) {28 super(target, settings);29 this._dom = {};30 this._shape = null;31 this._otherShape = null;32 this._onPortChange = this._onPortChange.bind(this);33 }34 // eslint-disable-next-line no-unused-vars35 startDrag(position, options) {36 super.startDrag();37 this._dom.origHandler.setAttribute('pointer-events', 'none');38 this._dom.destHandler.setAttribute('pointer-events', 'none');39 // TODO: next line is a workaround, find a way to allow click into canvas with a Connection.40 this._target.getElement().setAttribute('pointer-events', 'none');41 }42 start(shape, draggingPoint) {43 this._shape = shape;44 this._target.getCanvas().setDraggingConnection(this._target, draggingPoint);45 }46 _onGrab(event) {47 if (event.button !== 0) return;48 const { _target } = this;49 const draggingPoint = Number(event.target.dataset.point);50 super._onGrab(event);51 _target.getCanvas().startReconnection(_target, draggingPoint);52 }53 end() {54 const { _target } = this;55 // TODO: this avoid to calling this method more than necessaty times, but maybe it should be replaced by a variable56 // like _ended and another to identify if the behavior was started like _started.57 if (!this._shape && !this._otherShape) return;58 super.endDrag();59 this._shape = null;60 this._otherShape = null;61 this._dom.origHandler.removeAttribute('pointer-events');62 this._dom.destHandler.removeAttribute('pointer-events');63 // TODO: next line is a workaround, find a way to allow click into canvas with a Connection.64 this._target.getElement().removeAttribute('pointer-events');65 // TODO: Check if all inherited classes from DragBehavior make following call,66 // if they do, so it could be move to its end() method.67 this._target.getCanvas().setDraggingConnection(null);68 if (_target.getOrigShape() && _target.getDestShape()) {69 _target.make();70 } else {71 _target.remove();72 }73 }74 // TODO: Consider remove endDrag() method in favor of end().75 endDrag() {76 this.end();77 }78 // eslint-disable-next-line no-unused-vars79 updatePosition(position, { draggingPoint }, modifiers) {80 const shape = this._shape;81 const draggingOrig = draggingPoint === PORT_MODE.ORIG;82 const mode = draggingOrig ? PORT_MODE.DEST : PORT_MODE.ORIG;83 const fakeDescription = this._otherShape84 ? this._otherShape.getConnectionPort(shape, draggingPoint).getDescription()85 : getFakeDescription(position, shape);86 const shapePort = shape.getConnectionPort(fakeDescription, mode);87 const description = shapePort.getDescription();88 if (draggingOrig) {89 this._updateHandlers(fakeDescription, description);90 this._target._draw(fakeDescription, description);91 } else {92 this._updateHandlers(description, fakeDescription);93 this._target._draw(description, fakeDescription);94 }95 }96 onShape(shape) {97 this._otherShape = shape;98 }99 // eslint-disable-next-line no-unused-vars100 outShape(shape) {101 this._otherShape = null;102 }103 _getControlsListeners() {104 return {105 mousedown: this._onGrab,106 mouseup: this._onRelease,107 };108 }109 _createHandlers() {110 const { _target } = this;111 if (!this._dom.origHandler) {112 const commonClass = 'connection-handler';113 this._dom.origHandler = ShapeUI.createHandler();114 this._dom.destHandler = ShapeUI.createHandler();115 this._dom.origHandler.classList.add(commonClass);116 this._dom.destHandler.classList.add(commonClass);117 this._dom.origHandler.dataset.point = PORT_MODE.ORIG;118 this._dom.destHandler.dataset.point = PORT_MODE.DEST;119 // TODO: Fix this access to private member120 _target._addControl(this._dom.origHandler, this._getControlsListeners());121 _target._addControl(this._dom.destHandler, this._getControlsListeners());122 }123 }124 _updateHandlers({ point: origPoint }, { point: destPoint }) {125 if ([origPoint, destPoint].includes(null)) return;126 this._dom.origHandler.setAttribute('cx', origPoint.x);127 this._dom.origHandler.setAttribute('cy', origPoint.y);128 this._dom.destHandler.setAttribute('cx', destPoint.x);129 this._dom.destHandler.setAttribute('cy', destPoint.y);130 }131 _onPortChange(customEvent, { origPort, destPort }) {132 if (origPort && destPort) {133 this._updateHandlers(origPort.getDescription(), destPort.getDescription());134 }135 }136 _getDraggableElement() {137 return [this._dom.origHandler, this._dom.destHandler];138 }139 attach() {140 const { _target } = this;141 _target.getCanvas().addListener(CONNECTION_EVENT.PORT_CHANGE, _target, this._onPortChange,142 this);143 this._createHandlers();144 super.attach();145 }146 detach() {147 const { _target } = this;148 _target.getCanvas().removeListener(CONNECTION_EVENT.PORT_CHANGE, _target, this._onPortChange, this);149 super.detach();150 }151}...

Full Screen

Full Screen

repo.js

Source:repo.js Github

copy

Full Screen

1var path = require('path')2var url = require('url')3var config = require('../config')4var user = require('./user')5var svn = require('./svn')6var git = require('./git')7function checkLimitUsers(credentials, subConfig) {8 return !subConfig.limit_users || subConfig.limit_users.includes(credentials.username);9}10var defaultHandler = {11 list: (repoConfig, credentials, path, callback) => {12 var accessible = [];13 for(var prefix in config.repositories) {14 subConfig = config.repositories[prefix];15 if(checkLimitUsers(credentials, subConfig)) {16 accessible.push(prefix + '/');17 }18 }19 callback(null, accessible);20 },21 update: (repoConfig, credentials, path, callback) => { callback(); }22};23function makeBalancer(funcName, pathIdx) {24 return function() {25 console.log(funcName);26 var credentials = pathIdx > 0 ? arguments[pathIdx-1] : null;27 var origPath = arguments[pathIdx];28 var args = [];29 var prefix = origPath.split('/')[0];30 var subPath = origPath.split('/').slice(1).join('/');31 if(config.repositories[prefix]) {32 var subConfig = config.repositories[prefix];33 subConfig.path = path.resolve(config.path, prefix + '/');34 var destHandler = subConfig.type == 'git' ? git : svn;35 } else {36 var subConfig = {path: config.path};37 var destHandler = defaultHandler;38 }39 if(credentials && !checkLimitUsers(credentials, subConfig)) {40 console.log('Unauthorized user for action ' + funcName + ' on path `' + origPath + '`');41 throw 'Unauthorized user for action ' + funcName + ' on path `' + origPath + '`';42 }43 args.push(subConfig);44 for(var i = 0; i < arguments.length; i++) {45 args.push(i == pathIdx ? subPath : arguments[i]);46 }47 if(!destHandler[funcName]) {48 console.log('Balancer error with path `' + origPath + '`');49 throw 'Balancer error with path `' + origPath + '`';50 }51 return destHandler[funcName].apply(destHandler, args);52 };53}54function getImporterUrl(credentials, path) {55 var params = Object.assign({56 path: path,57 token: user.findToken(credentials),58 display: 'frame',59 autostart: 160 }, config.task_importer_params);61 var q = [];62 for(var k in params) {63 if(params.hasOwnProperty(k)) {64 q.push(k + '=' + encodeURIComponent(params[k]));65 }66 }67 return config.task_importer.url + '?' + q.join('&');68};69var repo = {70 auth: (credentials, callback) => {71 repo.list(credentials, config.auth_path, callback);72 },73 getReverseTaskPath: (taskPath) => {74 // Get a repository relative path to a task75 // (used for generating path to _common)76 var subPath = path.relative(config.path, taskPath);77 var prefix = subPath.split('/')[0];78 if(config.repositories[prefix]) {79 return path.relative(taskPath, path.resolve(config.path, prefix + '/'));80 } else {81 return path.relative(taskPath, config.path);82 }83 },84 getImporterUrl: makeBalancer('getImporterUrl', 1),85 list: makeBalancer('list', 1),86 checkout: makeBalancer('checkout', 1),87 update: makeBalancer('update', 1),88 add: makeBalancer('add', 1),89 commit: makeBalancer('commit', 1),90 addCommit: makeBalancer('addCommit', 1),91 revert: makeBalancer('revert', 1),92 cleanup: makeBalancer('cleanup', 1),93 remove: makeBalancer('remove', 0),94 removeDir: makeBalancer('removeDir', 1),95 createDir: makeBalancer('createDir', 1)96}...

Full Screen

Full Screen

manager.js

Source:manager.js Github

copy

Full Screen

...3var net = require('net')4var ForwardReader = require('./reader')5var ForwardWriter = require('./writer')6// Handles a single connection7function DestHandler(id, conn, options) {8 var dest = net.connect({9 host: options.targetHost10 , port: options.targetPort11 })12 var writer = dest.pipe(new ForwardWriter(id))13 // We can't just pipe to conn because we don't want to end it14 // when the dest closes. Instead we'll send a special packet15 // to it (which is handled by the writer).16 function maybePipeManually() {17 var chunk18 while ((chunk = writer.read())) {19 if (!conn.write(chunk)) {20 break21 }22 }23 }24 function readableListener() {25 maybePipeManually()26 }27 function drainListener() {28 maybePipeManually()29 }30 function endListener() {31 conn.removeListener('drain', drainListener)32 writer.removeListener('readable', readableListener)33 this.emit('end')34 }35 function errorListener() {36 writer.end()37 }38 writer.on('end', endListener.bind(this))39 writer.on('readable', readableListener)40 dest.on('error', errorListener)41 conn.on('drain', drainListener)42 this.end = function() {43 dest.end()44 }45 this.write = function(chunk) {46 dest.write(chunk)47 }48 events.EventEmitter.call(this)49}50util.inherits(DestHandler, events.EventEmitter)51// Handles a single port52function ForwardHandler(conn, options) {53 var destHandlersById = Object.create(null)54 function endListener() {55 this.emit('end')56 }57 function packetEndListener(id) {58 delete destHandlersById[id]59 }60 function packetListener(id, packet) {61 var dest = destHandlersById[id]62 if (packet) {63 if (!dest) {64 // Let's create a new connection65 dest = destHandlersById[id] = new DestHandler(id, conn, options)66 dest.on('end', packetEndListener.bind(null, id))67 }68 dest.write(packet)69 }70 else {71 // It's a simulated fin packet72 if (dest) {73 dest.end()74 }75 }76 }77 function readableListener() {78 // No-op but must exist so that we get the 'end' event.79 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var devicefarmer = require('../index.js');2var destHandler = devicefarmer.DestHandler;3destHandler.getDest('test', function (err, dest) {4 if (err) {5 console.log('error in getDest ' + err);6 } else {7 console.log('getDest successful ' + dest);8 }9});10var devicefarmer = require('../index.js');11var destHandler = devicefarmer.DestHandler;12destHandler.getDest('test', function (err, dest) {13 if (err) {14 console.log('error in getDest ' + err);15 } else {16 console.log('getDest successful ' + dest);17 }18});19var devicefarmer = require('../index.js');20var destHandler = devicefarmer.DestHandler;21destHandler.getDest('test', function (err, dest) {22 if (err) {23 console.log('error in getDest ' + err);24 } else {25 console.log('getDest successful ' + dest);26 }27});

Full Screen

Using AI Code Generation

copy

Full Screen

1var destHandler = require('devicefarmer-stf-client').DestHandler;2destHandler.getDevices().then(function(devices) {3 console.log(devices);4});5var deviceHandler = require('devicefarmer-stf-client').DeviceHandler;6deviceHandler.getDevices().then(function(devices) {7 console.log(devices);8});9var deviceHandler = require('devicefarmer-stf-client').DeviceHandler;10deviceHandler.getDevices().then(function(devices) {11 console.log(devices);12});13var deviceHandler = require('devicefarmer-stf-client').DeviceHandler;14deviceHandler.getDevices().then(function(devices) {15 console.log(devices);16});17var deviceHandler = require('devicefarmer-stf-client').DeviceHandler;18deviceHandler.getDevices().then(function(devices) {19 console.log(devices);20});21var deviceHandler = require('devicefarmer-stf-client').DeviceHandler;22deviceHandler.getDevices().then(function(devices) {23 console.log(devices);24});25var deviceHandler = require('devicefarmer-stf-client').DeviceHandler;26deviceHandler.getDevices().then(function(devices) {27 console.log(devices);28});29var deviceHandler = require('devicefarmer-stf-client').DeviceHandler;30deviceHandler.getDevices().then(function(devices) {31 console.log(devices);32});

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2var destHandler = new stf.DestHandler();3destHandler.getDestinations().then(function(result){4 console.log(result);5});6var stf = require('devicefarmer-stf');7var deviceHandler = new stf.DeviceHandler();8deviceHandler.getDevices().then(function(result){9 console.log(result);10});11var stf = require('devicefarmer-stf');12var deviceHandler = new stf.DeviceHandler();13deviceHandler.getDevices().then(function(result){14 console.log(result);15});16var stf = require('devicefarmer-stf');17var deviceHandler = new stf.DeviceHandler();18deviceHandler.getDevices().then(function(result){19 console.log(result);20});21var stf = require('devicefarmer-stf');22var deviceHandler = new stf.DeviceHandler();23deviceHandler.getDevices().then(function(result){24 console.log(result);25});26var stf = require('devicefarmer-stf');27var deviceHandler = new stf.DeviceHandler();28deviceHandler.getDevices().then(function(result){29 console.log(result);30});31var stf = require('devicefarmer-stf');32var deviceHandler = new stf.DeviceHandler();33deviceHandler.getDevices().then(function(result){34 console.log(result);35});36var stf = require('devicefarmer-stf');37var deviceHandler = new stf.DeviceHandler();38deviceHandler.getDevices().then(function(result){39 console.log(result);40});41var stf = require('devicefarmer-stf');42var deviceHandler = new stf.DeviceHandler();43deviceHandler.getDevices().then(function(result){44 console.log(result);45});46var stf = require('devicefarmer-stf');47var deviceHandler = new stf.DeviceHandler();48deviceHandler.getDevices().then(function(result){49 console.log(result);50});

Full Screen

Using AI Code Generation

copy

Full Screen

1var DestHandler = require('./DestHandler');2var destHandler = new DestHandler();3destHandler.on('error', function(err) {4 console.log('Error: ' + err);5});6destHandler.on('data', function(data) {7 console.log('Data: ' + data);8});9destHandler.on('end', function() {10 console.log('End');11});12destHandler.on('close', function() {13 console.log('Close');14});15destHandler.on('finish', function() {16 console.log('Finish');17});18destHandler.write('Test');19destHandler.end();20var DestHandler = require('./DestHandler');21var destHandler = new DestHandler();22var fs = require('fs');23var file = fs.createWriteStream('dest.txt');24destHandler.on('error', function(err) {25 console.log('Error: ' + err);26});27destHandler.on('data', function(data) {28 console.log('Data: ' + data);29});30destHandler.on('end', function() {31 console.log('End');32});33destHandler.on('close', function() {34 console.log('Close');35});36destHandler.on('finish', function() {37 console.log('Finish');38});39destHandler.pipe(file);40destHandler.write('Test');41destHandler.end();

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2var destHandler = new stf.DestHandler();3destHandler.on('open', function() {4 destHandler.getDevices(function(devices) {5 console.log('Devices: ' + JSON.stringify(devices));6 });7});8var stf = require('devicefarmer-stf');9var destHandler = new stf.DestHandler();10destHandler.on('open', function() {11 destHandler.getDevices(function(devices) {12 console.log('Devices: ' + JSON.stringify(devices));13 });14});15getDevices(callback)16getDevice(deviceId, callback)17getDeviceStatus(deviceId, callback)18getDeviceProvider(deviceId, callback)19getDeviceOwner(deviceId, callback)20getDeviceDisplay(deviceId, callback)21getDeviceBattery(deviceId, callback)

Full Screen

Using AI Code Generation

copy

Full Screen

1var DeviceFarmer = require('devicefarmer-stf');2df.DestHandler('deviceid', 'path/to/file', function(err, res) {3 if (err) {4 console.log(err);5 }6 else {7 console.log(res);8 }9});10var DeviceFarmer = require('devicefarmer-stf');11df.GetFile('deviceid', 'path/to/file', function(err, res) {12 if (err) {13 console.log(err);14 }15 else {16 console.log(res);17 }18});19var DeviceFarmer = require('devicefarmer-stf');20df.GetLog('deviceid', function(err, res) {21 if (err) {22 console.log(err);23 }24 else {25 console.log(res);26 }27});28var DeviceFarmer = require('devicefarmer-stf');29df.GetLog('deviceid', function(err, res) {30 if (err) {31 console.log(err);32 }33 else {34 console.log(res);35 }36});37var DeviceFarmer = require('devicefarmer-stf');38df.GetLog('deviceid', function(err, res) {39 if (err) {40 console.log(err);41 }42 else {43 console.log(res);44 }45});46var DeviceFarmer = require('devicefarmer-stf');

Full Screen

Using AI Code Generation

copy

Full Screen

1var devicefarmer = require('devicefarmer-stf');2var destHandler = new devicefarmer.DestHandler();3destHandler.destination('C:\\Users\\Public\\Documents\\test.txt');4var devicefarmer = require('devicefarmer-stf');5var client = new devicefarmer.DeviceFarmerClient();6client.login('username', 'password', function (err, response) {7 if (err) {8 console.log('Error: ' + err);9 } else {10 console.log('Success: ' + response);11 }12});13var devicefarmer = require('devicefarmer-stf');14var client = new devicefarmer.DeviceFarmerClient();15client.logout('username', 'password', function (err, response) {16 if (err) {17 console.log('Error: ' + err);18 } else {19 console.log('Success: ' + response);20 }21});22var devicefarmer = require('devicefarmer-stf');23var client = new devicefarmer.DeviceFarmerClient();24client.getDeviceList(function (err, response) {25 if (err) {26 console.log('Error: ' + err);27 } else {28 console.log('Success: ' + response);29 }30});31var devicefarmer = require('devicefarmer-stf');32var client = new devicefarmer.DeviceFarmerClient();33client.getDeviceDetails('deviceID', function (err, response) {34 if (err) {35 console.log('Error: ' + err);36 } else {37 console.log('Success: ' + response);38 }39});40var devicefarmer = require('devicefarmer-stf');41var client = new devicefarmer.DeviceFarmerClient();42client.getDeviceStatus('deviceID', function (err, response) {43 if (err) {44 console.log('Error: ' + err);45 } else {46 console.log('Success: ' + response);47 }48});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run devicefarmer-stf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful