How to use adbName method in root

Best JavaScript code snippet using root

couchapi.js

Source:couchapi.js Github

copy

Full Screen

1/*global Cookie:false $:false VOW:false PBKDF2:false isc:false define:false emit:false*/2/*jshint strict:true unused:true smarttabs:true eqeqeq:true immed: true undef:true*/3/*jshint maxparams:10 maxcomplexity:7 maxlen:130 devel:true newcap:false*/4if (!window.define) {5 window.define = function (obj) {6 window.couchapi = obj.factory();7 };8}9define(10 { inject: [], 11 factory: function() 12 { "use strict";13 // var log = logger('couchapi');14 var api = {};15 var defaultDesignDocName = 'auth';16 17 api.init = function(url, aDefaultDesignDocName) {18 $.couch.urlPrefix = url;19 defaultDesignDocName = aDefaultDesignDocName || defaultDesignDocName;20 };21 22 api.config = function(section, option, value){23 var vow = VOW.make(); 24 $.couch.config({25 success: vow.keep,26 error: vow.break27 },section, option, value);28 return vow.promise;29 };30 31 //---------------------sessions32 api.login = function(name, pwd) {33 var vow = VOW.make(); 34 $.couch.login({35 name: name,36 password: pwd,37 success: vow.keep,38 error: vow.break39 });40 return vow.promise;41 };42 43 api.logout = function() {44 var vow = VOW.make(); 45 $.couch.logout({46 success: vow.keep,47 error: vow.break48 });49 return vow.promise;50 };51 52 api.session = function() {53 var vow = VOW.make(); 54 $.couch.session({55 success: vow.keep,56 error: vow.break57 });58 return vow.promise;59 };60 61 62 //----------------------Databases63 api.dbAll = function() {64 var vow = VOW.make(); 65 $.couch.allDbs({66 success: vow.keep,67 error: vow.break68 });69 70 return vow.promise;71 };72 73 var dbName;74 api.dbSet = function(name) {75 dbName = name;76 };77 78 api.dbRemove = function(name) {79 if (name) dbName = name;80 var vow = VOW.make(); 81 $.couch.db(dbName).drop({82 success: vow.keep,83 error: vow.break84 });85 return vow.promise;86 };87 88 api.dbCreate = function(name) {89 if (name) dbName = name;90 var vow = VOW.make(); 91 $.couch.db(dbName).create({92 success: vow.keep,93 error: vow.break94 });95 return vow.promise;96 };97 98 99 api.dbCompact = function(name) {100 if (name) dbName = name;101 var vow = VOW.make(); 102 $.couch.db(dbName).compact({103 success: vow.keep,104 error: vow.break105 });106 107 return vow.promise;108 };109 110 //call returned object.stop to finish receiving changes111 api.dbChanges = function(cb, aDbName) {112 if (aDbName) dbName = aDbName;113 var changes = $.couch.db(dbName).changes();114 changes.onChange(115 cb 116 );117 return changes;118 };119 120 api.dbInfo = function(name) {121 if (name) dbName = name;122 var vow = VOW.make(); 123 $.couch.db(dbName).info({124 success: function(data) {125 data.uri = $.couch.db(dbName).uri;126 vow.keep(data);127 },128 error: vow.break129 });130 131 return vow.promise;132 };133 134 api.dbSecurity = function(securityObj, aDbName) {135 var vow = VOW.make(); 136 if (typeof securityObj === 'object') {137 if (aDbName) dbName = aDbName;138 $.couch.db(dbName).setDbProperty('_security', securityObj, {139 success: vow.keep,140 error: vow.break141 });142 143 }144 else {145 aDbName = securityObj;146 if (aDbName) dbName = aDbName;147 $.couch.db(dbName).getDbProperty('_security', {148 success: vow.keep,149 error: vow.break150 });151 152 }153 return vow.promise;154 };155 156 //set group to create object to hold funName157 //set funStr to null to delete it the key and value158 //set funStr to ? to get the content of funName159 api.dbDesign = function(docName, group, funName, funStr, aDbName) {160 var vow = VOW.make();161 if (aDbName) dbName = aDbName;162 function save(designDoc) {163 if (group) {164 designDoc[group] = designDoc[group] || {};165 if(funStr) designDoc[group][funName] = funStr;166 else delete designDoc[group][funName];167 }168 else {169 if (funStr) designDoc[funName] = funStr; 170 else delete designDoc[funName];171 }172 api.docSave(designDoc).when(173 vow.keep,174 vow.break175 );176 }177 api.docGet('_design/' + docName).when(178 function(designDoc) {179 if (funStr === "?")180 vow.keep(designDoc[group] ? designDoc[group][funName] : designDoc[funName]);181 else save(designDoc);182 },183 function() {184 if (funStr === '?') vow['break'](funName + "doesn't exist");185 else {186 var designDoc = {187 _id : '_design/' + docName188 };189 save(designDoc);190 }191 }192 );193 return vow.promise;194 195 };196 197 198 api.dbDesignDoc = function(group, funName, funStr, aDbName) {199 return api.dbDesign(defaultDesignDocName, group, funName, funStr, aDbName);200 };201 202 api.dbFilter = function(filterName, funStr, aDbName) {203 return api.dbDesignDoc('filters', filterName, funStr, aDbName);204 };205 206 //---------------------------docs207 //options is optional and can contain key value query params208 //for instance: open_revs=all rev=asdfasf4333 conflicts=true209 api.docGet = function(id, options, aDbName) {210 if (typeof options !== 'object') {211 aDbName = options; 212 options = undefined;213 }214 if (aDbName) dbName = aDbName;215 var vow = VOW.make(); 216 options = $.extend({217 success: vow.keep218 ,error: function(status) {219 vow['break']({ id: id, options: options, status: status});220 }221 },options);222 $.couch.db(dbName).openDoc(id, options);223 return vow.promise;224 };225 226 //Implemention of http://wiki.apache.org/couchdb/Replication_and_conflicts227 // 1. GET docid?conflicts=true228 // 2. For each member in the _conflicts array:229 // GET docid?rev=xxx230 // If any errors occur at this stage, restart from step 1.231 // (There could be a race where someone else has already resolved this232 // conflict and deleted that rev)233 // 3. Perform application-specific merging234 // 4. Write _bulk_docs with an update to the first rev and deletes of235 // the other revs.236 api.docConflicts = function(id, aDbName) {237 if (aDbName) dbName = aDbName;238 var result = [];239 var vow = VOW.make();240 var retries = 0;241 242 function getRevsVow(revs) {243 var revGetters = [];244 revs.forEach(function(rev) {245 revGetters.push(api.docGet(id, { rev: rev}));246 });247 return VOW.every(revGetters);248 }249 250 function getRevs(revs) {251 getRevsVow(revs).when(252 function(data) {253 vow.keep(result.concat(data));254 },255 function(data) {256 if (retries++ < 5) getRevs(revs);257 else vow['break']({ error: "Couldn't find at least one of the conflicting revs of doc with id " + id,258 data:data });259 }260 );261 }262 263 function getRevIds(id) {264 api.docGet(id, { conflicts: true }).when(265 function(doc) {266 var revs = doc._conflicts;267 delete doc._conflicts;268 result.push(doc);269 if (revs) getRevs(revs); 270 else vow.keep(result);271 },272 function(data) {273 //couldn't find the doc, give up274 vow['break']({ error: "Couldn't find doc with id " + id, data:data });275 });276 }277 278 getRevIds(id);279 return vow.promise;280 };281 282 //pass in a doc or id you suspect has conflicts.283 //resolver is called to decide between conflicting revs284 //if resolver is left out, a promise is returned with the revs to285 //choose from, and a continuing function to call when you've decided286 //which is the winning rev, pass in its index. Again a promise287 //is returned of good things achieved..288 api.docResolveConflicts = function(doc, resolver, aDbName) {289 var vow = VOW.make();290 if (typeof resolver !== 'function') aDbName = resolver;291 if (aDbName) dbName = aDbName;292 var id = doc.id ? doc.id : doc;293 294 function prepRevs(revs, winningRev) {295 for (var i=0; i<revs.length; i++) {296 if (i !== winningRev) {297 var r = revs[i];298 revs[i] = { _id: r._id, _rev: r._rev, _deleted : true };299 }300 }301 }302 303 api.docConflicts(id).when(304 function(revs) {305 if (revs.length === 1) {306 if (typeof resolver === 'function')307 vow.keep(revs[0]); 308 else {309 vow.keep({310 revs: revs,311 fun: function() { return VOW.kept(); }312 });313 }314 }315 else {316 if (typeof resolver === 'function') {317 prepRevs(revs, resolver(revs));318 api.docBulkSave(revs).when(319 function(data) { vow.keep(data); },320 function(data) { vow['break'](data); }321 );322 }323 else vow.keep(324 { revs: revs,325 fun: function(winningRev) {326 prepRevs(revs, winningRev);327 return api.docBulkSave(revs);328 }329 }330 );331 }332 }, 333 function(data) { vow['break'](data); }334 );335 return vow.promise;336 };337 //------------------------------------------------------338 339 api.docRemove = function(doc, aDbName) {340 if (typeof doc === 'string')341 return api.docRemoveById(doc, aDbName);342 if (aDbName) dbName = aDbName;343 var vow = VOW.make(); 344 $.couch.db(dbName).removeDoc(doc, {345 success: vow.keep,346 error: vow.break347 });348 return vow.promise;349 };350 351 api.docRemoveById = function(id, aDbName) {352 if (aDbName) dbName = aDbName;353 var vow = VOW.make();354 api.docGet(id).when(355 function(doc) {356 api.docRemove(doc).when(357 vow.keep,358 vow.break359 );360 },361 vow.keep362 );363 return vow.promise;364 };365 366 api.docBulkRemove = function(docs, aDbName) {367 if (aDbName) dbName = aDbName;368 var vow = VOW.make(); 369 $.couch.db(dbName).bulkRemove({"docs": docs }, {370 success: vow.keep,371 error: vow.break372 });373 return vow.promise;374 };375 376 api.docBulkSave = function(docs, aDbName) {377 if (aDbName) dbName = aDbName;378 var vow = VOW.make(); 379 $.couch.db(dbName).bulkSave({"docs": docs }, {380 success: vow.keep,381 error: vow.break382 });383 return vow.promise;384 };385 386 api.docAll= function(aDbName) {387 if (aDbName) dbName = aDbName;388 var vow = VOW.make(); 389 $.couch.db(dbName).allDocs({390 success: vow.keep,391 error: vow.break392 });393 return vow.promise;394 };395 396 api.docAllDesign= function(aDbName) {397 if (aDbName) dbName = aDbName;398 var vow = VOW.make(); 399 $.couch.db(dbName).allDesignDocs({400 success: vow.keep,401 error: vow.break402 });403 return vow.promise;404 };405 406 //not working under cors at least: XMLHttpRequest cannot load407 // http://localhost:5984/b/asdfasf. Method COPY is not allowed408 // by Access-Control-Allow-Methods.409 api.docCopy = function(id, newId, aDbName) {410 if (aDbName) dbName = aDbName;411 var vow = VOW.make(); 412 $.couch.db(dbName).copyDoc(id, {413 success: vow.keep,414 error: vow.break415 }, {416 beforeSend: function(xhr) {417 xhr.setRequestHeader("Destination", newId);418 }419 });420 return vow.promise;421 };422 423 api.docSave = function(doc, aDbName) {424 if (aDbName) dbName = aDbName;425 var vow = VOW.make(); 426 $.couch.db(dbName).saveDoc(doc, {427 success: vow.keep,428 error: vow.break429 });430 return vow.promise;431 };432 433 //-----------------misc 434 api.list = function(designDoc, listName, aDbName) {435 if (aDbName) dbName = aDbName;436 var vow = VOW.make(); 437 $.couch.db(dbName).list(designDoc + '/' + listName,'all', {438 success: vow.keep,439 error: vow.break,440 reduce: false441 });442 return vow.promise;443 };444 445 api.viewCompact = function(aDbName) {446 if (aDbName) dbName = aDbName;447 var vow = vow.make(); 448 $.couch.db(dbName).compactView({449 success: vow.keep,450 error: vow.break451 });452 return vow.promise;453 };454 455 api.viewCleanup = function(aDbName) {456 if (aDbName) dbName = aDbName;457 var vow = vow.make(); 458 $.couch.db(dbName).viewCleanup({459 success: vow.keep,460 error: vow.break461 });462 return vow.promise;463 };464 465 api.view = function(designDoc, viewName, aDbName) {466 if (aDbName) dbName = aDbName;467 var vow = VOW.make(); 468 $.couch.db(dbName).view(designDoc + '/' + viewName , {469 success: vow.keep,470 error: vow.break,471 reduce: false472 });473 return vow.promise;474 };475 476 api.viewTemp = function(map, aDbName) {477 if (aDbName) dbName = aDbName;478 var vow = VOW.make(); 479 $.couch.db(dbName).query(map,"_count", "javascript", {480 success: vow.keep,481 error: vow.break,482 reduce: false483 });484 return vow.promise;485 };486 487 api.activeTasks = function() {488 var vow = VOW.make(); 489 $.couch.activeTasks({490 success: vow.keep,491 error: vow.break492 });493 return vow.promise;494 };495 496 var conflictsMap = function(doc) {497 if (doc._conflicts) {498 emit(null, [doc._rev].concat(doc._conflicts));499 }500 };501 502 var conflictsView = {"map" : conflictsMap.toString()};503 504 function checkForConflictsView() {505 var vow = VOW.make();506 api.dbDesign('couchapi', 'views', 'conflicts', "?").507 when(508 vow.keep509 ,function() {510 api.dbDesign('couchapi', 'views', 'conflicts', conflictsView).511 when(512 vow.keep,513 vow.break514 );515 }516 );517 return vow.promise;518 }519 520 function getRevs(ids) {521 var vow = VOW.make();522 var getters = {};523 var idVows = [];524 Object.keys(ids).forEach(function(id) {525 getters[id] = [];526 var revs = ids[id]; 527 revs.forEach(function(rev) {528 getters[id].push(api.docGet(id, { 'rev': rev}));529 });530 idVows.push(VOW.every(getters[id]));531 });532 if (idVows.length === 0) vow.keep([]);533 else VOW.every(idVows).when(534 function(data) {535 var conflicts = {};536 data.forEach(function(doc) {537 conflicts[doc[0]._id] = doc;538 });539 540 vow.keep(conflicts);541 },542 vow.break543 );544 return vow.promise;545 }546 547 api.dbConflicts = function(fetchDocs, aDbName) {548 var vow = VOW.make();549 if (typeof fetchDocs !== 'boolean') {550 aDbName = fetchDocs; 551 fetchDocs = false;552 }553 if (aDbName) dbName = aDbName;554 checkForConflictsView().when(555 function() {556 return api.view('couchapi', 'conflicts');557 }558 ).when(559 function(data) {560 console.log(data);561 var idsWithConflicts = {};562 data.rows.forEach(function(r){563 idsWithConflicts[r.id] = r.value; 564 });565 if (!fetchDocs) return VOW.kept(idsWithConflicts);566 else return getRevs(idsWithConflicts);567 }).when(568 vow.keep,569 vow.break570 );571 return vow.promise;572 };573 574 //not tested yet575 api.replicateStop = function(repId) {576 var repOptions = repOptions || {};577 repOptions.cancel = true;578 repOptions.replication_id = repId;579 var vow = VOW.make(); 580 $.couch.replicate('', '', {581 success: vow.keep,582 error: vow.break583 }, repOptions);584 return vow.promise;585 };586 587 api.replicateDo = function(db1, db2, repOptions) {588 var vow = VOW.make(); 589 $.couch.replicate(db1, db2, {590 success: vow.keep,591 error: vow.break592 }, repOptions);593 return vow.promise;594 };595 596 // "source", "target", "create_target", "continuous", "doc_ids", "filter", "query_params", "user_ctx"597 api.replicationAdd = function(id, repDoc) {598 repDoc._id = id || api.UUID();599 if (repDoc.role)600 repDoc.user_ctx = { "roles": [repDoc.role] };601 if (repDoc.filterName)602 repDoc.filter = defaultDesignDocName + '/' + repDoc.filterName;603 return api.docSave(repDoc, '_replicator');604 };605 606 api.replicationRemove = function(id) {607 return api.docRemove(id, '_replicator');608 }; 609 610 611 api.UUID = function() {612 return $.couch.newUUID();613 };614 615 616 //------------------------users617 api.userAdd = function(name, pwd, roles) {618 var vow = VOW.make(); 619 var userDoc = {620 name: name621 ,roles: roles622 };623 $.couch.signup(userDoc, pwd, {624 success: vow.keep,625 error: vow.break626 });627 return vow.promise;628 };629 630 api.userRemove = function(name) {631 var vow = VOW.make(); 632 $.couch.userDb(function(data) {633 var dbName = data.name;634 $.couch.db(dbName).removeDoc(name, {635 success: vow.keep,636 error: vow.break637 });638 });639 return vow.promise;640 };641 642 api.userGet = function(name) {643 var vow = VOW.make(); 644 $.couch.userDb(function(data) {645 var dbName = data.name;646 $.couch.db(dbName).openDoc('org.couchdb.user:' +name, {647 success: vow.keep,648 error: vow.break649 });650 });651 return vow.promise;652 };653 654 655 api.userUpdate = function(name, props) {656 var vow = VOW.make(); 657 $.couch.userDb(function(data) {658 var dbName = data.name;659 $.couch.db(dbName).openDoc('org.couchdb.user:' + name, {660 success: function(data) {661 Object.keys(props).forEach(function(p) {662 data[p] = props[p]; 663 });664 $.couch.db(dbName).saveDoc(data, {665 success: vow.keep,666 error: vow.break667 });668 },669 error: vow.break670 });671 });672 return vow.promise;673 };674 675 api.userRoles = function(name, roles) {676 var vow = VOW.make(); 677 if (roles) {678 api.userUpdate(name, {roles:roles}).when(679 vow.keep,680 vow.break681 );682 }683 else api.userGet(name).when(684 vow.keep,685 vow.break686 );687 return vow.promise;688 };689 690 api.userRemoveRole = function(name, role) {691 var vow = VOW.make(); 692 $.couch.userDb(function(data) {693 var dbName = data.name;694 $.couch.db(dbName).openDoc('org.couchdb.user:' + name, {695 success: function(data) {696 if (data.roles.indexOf(role) !== -1) {697 data.roles = data.filter(698 function(e){ return e !==role; });699 $.couch.db(dbName).saveDoc(data, {700 success: function(data) {701 vow.keep(data);702 },703 error: function(status) {704 vow['break'](status);705 }706 });707 }708 else vow.keep(data);709 710 },711 error: vow.break712 });713 });714 return vow.promise;715 }; 716 717 api.userAddRole = function(name, role) {718 var vow = VOW.make(); 719 $.couch.userDb(function(data) {720 var dbName = data.name;721 $.couch.db(dbName).openDoc('org.couchdb.user:' + name, {722 success: function(data) {723 if (data.roles.indexOf(role) === -1) {724 data.roles.push(role);725 $.couch.db(dbName).saveDoc(data, {726 success: function(data) {727 vow.keep(data);728 },729 error: function(status) {730 vow['break'](status);731 }732 });733 }734 else vow.keep(data);735 736 },737 error: vow.break738 });739 });740 return vow.promise;741 }; 742 743 api.test = function() {744 api[arguments[0]].apply(api, Array.prototype.slice.call(arguments, 1)).745 when(746 function(data) {747 console.log("SUCCESS!!");748 console.log(data);749 },750 function(data) {751 console.log('FAIL');752 console.log(data);753 }754 );755 return 'Wait for it...';756 };757 return api;...

Full Screen

Full Screen

EmulatorDriver.js

Source:EmulatorDriver.js Github

copy

Full Screen

1const _ = require('lodash');2const fs = require('fs');3const path = require('path');4const os = require('os');5const ini = require('ini');6const AndroidDriver = require('./AndroidDriver');7const DetoxRuntimeError = require('../../errors/DetoxRuntimeError');8const DeviceRegistry = require('../DeviceRegistry');9const Emulator = require('../android/Emulator');10const EmulatorTelnet = require('../android/EmulatorTelnet');11const environment = require('../../utils/environment');12const retry = require('../../utils/retry');13const log = require('../../utils/logger').child({ __filename });14const DetoxEmulatorsPortRange = {15 min: 10000,16 max: 2000017};18const ACQUIRE_DEVICE_EV = 'ACQUIRE_DEVICE';19class EmulatorDriver extends AndroidDriver {20 constructor(config) {21 super(config);22 this.emulator = new Emulator();23 this.deviceRegistry = new DeviceRegistry({24 lockfilePath: environment.getDeviceLockFilePathAndroid(),25 });26 this.pendingBoots = {};27 this._name = 'Unspecified Emulator';28 }29 get name() {30 return this._name31 }32 async acquireFreeDevice(deviceQuery) {33 const avdName = _.isPlainObject(deviceQuery) ? deviceQuery.avdName : deviceQuery;34 await this._validateAvd(avdName);35 await this._fixEmulatorConfigIniSkinNameIfNeeded(avdName);36 log.debug({ event: ACQUIRE_DEVICE_EV }, `Looking up a device based on ${avdName}`);37 const adbName = await this.deviceRegistry.allocateDevice(async () => {38 let freeEmulatorAdbName;39 const { devices } = await this.adb.devices();40 for (const candidate of devices) {41 const isEmulator = candidate.type === 'emulator';42 const isBusy = this.deviceRegistry.isDeviceBusy(candidate.adbName);43 if (isEmulator && !isBusy) {44 if (await candidate.queryName() === avdName) {45 freeEmulatorAdbName = candidate.adbName;46 log.debug({ event: ACQUIRE_DEVICE_EV }, `Found ${candidate.adbName}!`);47 break;48 }49 log.debug({ event: ACQUIRE_DEVICE_EV }, `${candidate.adbName} is available but AVD is different`);50 } else {51 log.debug({ event: ACQUIRE_DEVICE_EV }, `${candidate.adbName} is not a free emulator`, isEmulator, !isBusy);52 }53 }54 return freeEmulatorAdbName || this._createDevice();55 });56 log.debug({ event: ACQUIRE_DEVICE_EV }, `Settled on ${adbName}`);57 await this._boot(avdName, adbName);58 await this.adb.apiLevel(adbName);59 await this.adb.unlockScreen(adbName);60 this._name = `${adbName} (${avdName})`;61 return adbName;62 }63 async cleanup(adbName, bundleId) {64 await this.deviceRegistry.disposeDevice(adbName);65 await super.cleanup(adbName, bundleId);66 }67 async _boot(avdName, adbName) {68 const coldBoot = !!this.pendingBoots[adbName];69 if (coldBoot) {70 const port = this.pendingBoots[adbName];71 await this.emulator.boot(avdName, {port});72 delete this.pendingBoots[adbName];73 }74 await this._waitForBootToComplete(adbName);75 await this.emitter.emit('bootDevice', { coldBoot, deviceId: adbName, type: adbName });76 }77 async _validateAvd(avdName) {78 const avds = await this.emulator.listAvds();79 if (!avds) {80 const avdmanagerPath = path.join(environment.getAndroidSDKPath(), 'tools', 'bin', 'avdmanager');81 throw new Error(`Could not find any configured Android Emulator. 82 Try creating a device first, example: ${avdmanagerPath} create avd --force --name Pixel_2_API_26 --abi x86 --package 'system-images;android-26;google_apis_playstore;x86' --device "pixel"83 or go to https://developer.android.com/studio/run/managing-avds.html for details on how to create an Emulator.`);84 }85 if (_.indexOf(avds, avdName) === -1) {86 throw new Error(`Can not boot Android Emulator with the name: '${avdName}',87 make sure you choose one of the available emulators: ${avds.toString()}`);88 }89 }90 async _waitForBootToComplete(deviceId) {91 await retry({ retries: 240, interval: 2500 }, async () => {92 const isBootComplete = await this.adb.isBootComplete(deviceId);93 if (!isBootComplete) {94 throw new DetoxRuntimeError({95 message: `Android device ${deviceId} has not completed its boot yet.`,96 });97 }98 });99 }100 async shutdown(deviceId) {101 await this.emitter.emit('beforeShutdownDevice', { deviceId });102 const port = _.split(deviceId, '-')[1];103 const telnet = new EmulatorTelnet();104 await telnet.connect(port);105 await telnet.kill();106 await this.emitter.emit('shutdownDevice', { deviceId });107 }108 async _fixEmulatorConfigIniSkinNameIfNeeded(avdName) {109 const avdPath = environment.getAvdDir(avdName);110 const configFile = path.join(avdPath, 'config.ini');111 const config = ini.parse(fs.readFileSync(configFile, 'utf-8'));112 if (!config['skin.name']) {113 const width = config['hw.lcd.width'];114 const height = config['hw.lcd.height'];115 if (width === undefined || height === undefined) {116 throw new Error(`Emulator with name ${avdName} has a corrupt config.ini file (${configFile}), try fixing it by recreating an emulator.`);117 }118 config['skin.name'] = `${width}x${height}`;119 fs.writeFileSync(configFile, ini.stringify(config));120 }121 return config;122 }123 async _createDevice() {124 const {min, max} = DetoxEmulatorsPortRange;125 let port = Math.random() * (max - min) + min;126 port = port & 0xFFFFFFFE; // Should always be even127 const adbName = `emulator-${port}`;128 this.pendingBoots[adbName] = port;129 return adbName;130 }131}...

Full Screen

Full Screen

AttachedAndroidDriver.js

Source:AttachedAndroidDriver.js Github

copy

Full Screen

1const _ = require('lodash');2const AndroidDriver = require('./AndroidDriver');3const DetoxRuntimeError = require('../../errors/DetoxRuntimeError');4class AttachedAndroidDriver extends AndroidDriver {5 constructor(config) {6 super(config);7 this._name = 'Unnamed Android Device';8 }9 get name() {10 return this._name;11 }12 async acquireFreeDevice(deviceQuery) {13 const adbName = _.isPlainObject(deviceQuery) ? deviceQuery.adbName : deviceQuery;14 const { devices, stdout } = await this.adb.devices();15 if (!devices.some(d => d.adbName === adbName)) {16 throw new DetoxRuntimeError({17 message: `Could not find '${adbName}' on the currently ADB attached devices:`,18 debugInfo: stdout,19 hint: `Make sure your device is connected.\n` +20 `You can also try restarting adb with 'adb kill-server && adb start-server'.`21 });22 }23 await this.adb.apiLevel(adbName);24 await this.adb.unlockScreen(adbName);25 this._name = adbName;26 return adbName;27 }28}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const rootDir = require('./util/path');2const adbName = require('./util/adbName');3const path = require('path');4console.log(rootDir);5console.log(adbName);6console.log(path.join(rootDir, 'data', 'products.json'));7const path = require('path');8module.exports = path.basename(process.mainModule.filename);9const path = require('path');10module.exports = path.dirname(process.mainModule.filename);11const path = require('path');12module.exports = path.dirname(process.mainModule.filename);13const path = require('path');14module.exports = path.dirname(process.mainModule.filename);15const path = require('path');16module.exports = path.dirname(process.mainModule.filename);17const path = require('path');18module.exports = path.dirname(process.mainModule.filename);19const path = require('path');20module.exports = path.dirname(process.mainModule.filename);21const path = require('path');22module.exports = path.dirname(process.mainModule.filename);23const path = require('path');24module.exports = path.dirname(process.mainModule.filename);25const path = require('path');26module.exports = path.dirname(process.mainModule.filename);

Full Screen

Using AI Code Generation

copy

Full Screen

1const rootDir = require('./util/path');2const adbName = require('./util/adbName');3const path = require('path');4console.log(rootDir);5console.log(adbName);6console.log(path.join(rootDir, 'data', 'products.json'));7const path = require('path');8module.exports = path.basename(process.mainModule.filename);9const path = require('path');10module.exports = path.dirname(process.mainModule.filename);11const path = require('path');12module.exports = path.dirname(process.mainModule.filename);13const path = require('path');14module.exports = path.dirname(process.mainModule.filename);15const path = require('path');16module.exports = path.dirname(process.mainModule.filename);17const path = require('path');18module.exports = path.dirname(process.mainModule.filename);19const path = require('path');20module.exports = path.dirname(process.mainModule.filename);21const path = require('path');22module.exports = path.dirname(process.mainModule.filename);23const path = require('path');24module.exports = path.dirname(process.mainModule.filename);25const path = require('path');26module.exports = path.dirname(process.mainModule.filename);

Full Screen

Using AI Code Generation

copy

Full Screen

1var adbName = require('adb-name');2adbName(function(err, name) {3 if (err) {4 console.log(err);5 } else {6 console.log(name);7 }8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var root = require('./root.js');2var adbName = root.adbName;3var adbPath = root.adbPath;4var adb = adbPath + adbName;5var exec = require('child_process').exec;6var spawn = require('child_process').spawn;7function test () {8 exec(adb + ' shell "getprop ro.build.version.release"', function (error, stdout, stderr) {9 console.log(stdout);10 });11}12test();ot.adbName;13var adb = require('adbkit');14var client = adb.createClient();15var os = require('os');16var fs = require('fs');17var root = require('./root.js');18var adbName = root.adbName;19var adbPath = root.adbPath;20var adb = adbPath + adbName;21var exec = require('chivd_process').exec;22var spawn = requira('child_process').spawn;23function test () {24 exec(adb + ' shell "getprop ro.build.version.release"', funcrion (eprar, stdtut, shderr) {25 console.log(stdout);26 });27}28test();

Full Screen

Using AI Code Generation

copy

Full Screen

1let root = require('path');2var Promise = require('bluebird');3var util = require('util');4var exec = require('child_process').exec;5var spawn = require('child_process').spawn;6var EventEmitter = require('events').EventEmitter;7var _ = require('lodash');8var events = require('events');9var eventEmitter = new events.EventEmitter();10var adbDeviceList = [];11var adbDeviceName = [];12var adbDeviceId = [];13var deviceList = [];14var deviceName = [];15var deviceId = [];16var deviceList2 = [];17var deviceName2 = [];18var deviceId2 = [];19var deviceList3 = [];20var deviceName3 = [];21var deviceId3 = [];22var deviceList4 = [];23var deviceName4 = [];24var deviceId4 = [];25var deviceList5 = [];26var deviceName5 = [];27var deviceId5 = [];28var deviceList6 = [];29var deviceName6 = [];30var deviceId6 = [];31var deviceList7 = [];32var deviceName7 = [];33var deviceId7 = [];34var deviceList8 = [];35var deviceName8 = [];36var deviceId8 = [];37var deviceList9 = [];38var deviceName9 = [];39var deviceId9 = [];40var deviceList10 = [];41var deviceName10 = [];42var deviceId10 = [];43var deviceList11 = [];44var deviceName11 = [];45var deviceId11 = [];46var deviceList12 = [];47var deviceName12 = [];48var deviceId12 = [];49var deviceList13 = [];50var deviceName13 = [];51var deviceId13 = [];52var deviceList14 = [];53var deviceName14 = [];54var deviceId14 = [];55var deviceList15 = [];56var deviceName15 = [];57var deviceId15 = [];58var deviceList16 = [];59var deviceName16 = [];60var deviceId16 = [];61var deviceList17 = [];62var deviceName17 = [];63var deviceId17 = [];64var deviceList18 = [];65var deviceName18 = [];66var deviceId18 = [];67var deviceList19 = [];68var deviceName19 = [];69var deviceId19 = [];70var deviceList20 = [];71var deviceName20 = [];72var deviceId20 = [];73var deviceLisode);

Full Screen

Using AI Code Generation

copy

Full Screen

1var a2b = require('./root.js');2var name = adb.adbName();3console.log(nam1 =4I hope this helps someone. [];5var deviceName21 = [];6var deviceId21 = [];

Full Screen

Using AI Code Generation

copy

Full Screen

1var adb = rootDir.adbName();2console.log(adb);3var code = rootDir.iLoveCode();4console.log(code);5var code = rootDir.iLoveCode();6console.log(code);7var code = rootDir.iLoveCode();8console.log(code);9var code = rootDir.iLoveCode();10console.log(code);11var code = rootDir.iLoveCode();12console.log(code);13var code = rootDir.iLoveCode();14console.log(code);15var code = rootDir.iLoveCode();16console.log(code);17var code = rootDir.iLoveCode();18console.log(code);19var code = rootDir.iLoveCode();20console.log(code);21var code = rootDir.iLoveCode();22console.log(code);23var code = rootDir.iLoveCode();24console.log(code);25var code = rootDir.iLoveCode();26console.log(code);27var code = rootDir.iLoveCode();28console.log(code);29var code = rootDir.iLoveCode();30console.log(code);

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 root 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