How to use this.interrupt method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

ui.web.VideoPan.js

Source:ui.web.VideoPan.js Github

copy

Full Screen

1zebkit.package("ui.web", function(pkg, Class) {2 var ui = pkg.cd("..");3 /**4 * Simple video panel that can be used to play a video:5 *6 *7 * // create canvas, add video panel to the center and8 * // play video9 * var canvas = zebkit.ui.zCanvas(500,500).root.properties({10 * layout: new zebkit.layout.BorderLayout(),11 * center: new zebkit.ui.web.VideoPan("trailer.mpg")12 * });13 *14 *15 * @param {String} url an URL to a video16 * @class zebkit.ui.web.VideoPan17 * @extends zebkit.ui.Panel18 * @constructor19 */20 pkg.VideoPan = Class(ui.Panel, [21 function(src) {22 var $this = this;23 /**24 * Original video DOM element that is created25 * to play video26 * @type {Video}27 * @readOnly28 * @attribute video29 */30 this.video = document.createElement("video");31 this.source = document.createElement("source");32 this.source.setAttribute("src", src);33 this.video.appendChild(this.source);34 this.$super();35 // canplaythrough is video event36 this.video.addEventListener("canplaythrough", function() {37 $this.fire("playbackStateUpdated", [$this, "ready"]);38 $this.repaint();39 $this.$continuePlayback();40 }, false);41 this.video.addEventListener("ended", function() {42 $this.fire("playbackStateUpdated", [$this, "end"]);43 $this.$interruptCancelTask();44 }, false);45 this.video.addEventListener("pause", function() {46 $this.fire("playbackStateUpdated", [$this, "pause"]);47 $this.$interruptCancelTask();48 }, false);49 this.video.addEventListener("play", function() {50 $this.$continuePlayback();51 $this.fire("playbackStateUpdated", [$this, "play"]);52 }, false);53 // progress event indicates a loading progress54 // the event is useful to detect recovering from network55 // error56 this.video.addEventListener("progress", function() {57 // if playback has been postponed due to an error58 // let's say that problem seems fixed and delete59 // the cancel task60 if ($this.$cancelTask !== null) {61 $this.$interruptCancelTask();62 // detect if progress event has to try to start animation that has not been63 // started yet or has been canceled for a some reason64 if ($this.video.paused === false) {65 $this.$continuePlayback();66 $this.fire("playbackStateUpdated", [$this, "continue"]);67 }68 }69 }, false);70 this.source.addEventListener("error", function(e) {71 $this.$interruptCancelTask();72 $this.$lastError = e.toString();73 $this.fire("playbackStateUpdated", [$this, "error"]);74 $this.repaint();75 $this.pause();76 }, false);77 this.video.addEventListener("stalled", function() {78 $this.$cancelPlayback();79 }, false);80 this.video.addEventListener("loadedmetadata", function (e) {81 $this.videoWidth = this.videoWidth;82 $this.videoHeight = this.videoHeight;83 $this.$aspectRatio = $this.videoHeight > 0 ? $this.videoWidth / $this.videoHeight : 0;84 $this.vrp();85 }, false);86 },87 function $clazz() {88 this.SignLabel = Class(ui.Panel, [89 function $clazz() {90 this.font = new zebkit.Font("bold", 18);91 },92 function setColor(c) {93 this.kids[0].setColor(c);94 return this;95 },96 function(title) {97 this.$super(new zebkit.layout.FlowLayout("center", "center"));98 this.add(new ui.Label(title).setFont(this.clazz.font));99 this.setBorder(new zebkit.draw.Border("gray", 1, 8));100 this.setPadding(6);101 this.setBackground("white");102 this.setColor("black");103 }104 ]);105 },106 function $prototype(clazz) {107 this.videoWidth = this.videoHeight = 0;108 this.cancelationTimeout = 20000; // 20 seconds109 this.showSign = true;110 this.$animStallCounter = this.$aspectRatio = 0;111 this.$adjustProportions = true;112 this.$lastError = this.$videoBound = this.$cancelTask = null;113 this.$animCurrentTime = -1;114 this.views = {115 pause : new clazz.SignLabel("Pause, press to continue").toView(),116 replay : new clazz.SignLabel("Press to re-play").toView(),117 play : new clazz.SignLabel("Press to play").toView(),118 error : new clazz.SignLabel("Failed, press to re-try").setColor("red").toView(),119 waiting: new clazz.SignLabel("Waiting ...").setColor("orange").toView()120 };121 this.paint = function(g) {122 if (this.video.paused === false &&123 this.video.ended === false &&124 this.$cancelTask === null )125 {126 if (this.video.currentTime !== this.$animCurrentTime) {127 this.$animStallCounter = 0;128 this.repaint();129 } else {130 if (this.$animStallCounter > 180) {131 this.$cancelPlayback();132 } else {133 this.$animStallCounter++;134 this.repaint();135 }136 }137 }138 this.$animCurrentTime = this.video.currentTime;139 if (this.$videoBound === null) {140 this.calcVideoBound();141 }142 g.drawImage(this.video, this.$videoBound.x,143 this.$videoBound.y,144 this.$videoBound.width,145 this.$videoBound.height);146 // draw status sign147 if (this.showSign) {148 var sign = null;149 if (this.$lastError !== null) {150 sign = this.views.error;151 } else {152 if (this.$cancelTask !== null) {153 sign = this.views.waiting;154 } else if (this.video.ended) {155 sign = this.views.replay;156 } else if (this.video.paused) {157 if (this.video.currentTime === 0) {158 sign = this.views.play;159 } else {160 sign = this.views.pause;161 }162 }163 }164 if (sign !== null) {165 this.paintViewAt(g, "center", "center", sign);166 }167 }168 };169 /**170 * Set autoplay for video171 * @param {Boolean} b an autoplay flag172 * @method autoplay173 * @chainable174 */175 this.autoplay = function(b) {176 this.video.autoplay = b;177 return this;178 };179 /**180 * Pause video181 * @method pause182 * @chainable183 */184 this.pause = function() {185 if (this.video.paused === false) {186 this.video.pause();187 this.repaint();188 }189 return this;190 };191 /**192 * Mute sound193 * @param {Boolean} b true to mute the video sound194 * @method mute195 * @chainable196 */197 this.mute = function(b) {198 this.video.muted = b;199 return this;200 };201 /**202 * Start or continue playing video203 * @method play204 * @chainable205 */206 this.play = function() {207 if (this.video.paused === true) {208 if (this.$lastError !== null) {209 this.$lastError = null;210 this.video.load();211 }212 this.video.play();213 this.repaint();214 }215 return this;216 };217 /**218 * Adjust video proportion to fill maximal space with correct ratio219 * @param {Boolean} b true if the video proportion has to be adjusted220 * @method adjustProportions221 * @chainable222 */223 this.adjustProportions = function(b) {224 if (this.$adjustProportions !== b) {225 this.$adjustProportions = b;226 this.vrp();227 }228 return this;229 };230 this.calcPreferredSize = function(target) {231 return {232 width : this.videoWidth,233 height : this.videoHeight234 };235 };236 this.pointerClicked = function(e) {237 if (this.isPaused()) {238 this.play();239 } else {240 this.pause();241 }242 };243 /**244 * Check if the video is paused245 * @method isPaused246 * @return {Boolean} true if the video has been paused247 */248 this.isPaused = function() {249 return this.video.paused;250 };251 /**252 * Check if the video is ended253 * @method isEnded254 * @return {Boolean} true if the video has been ended255 */256 this.isEnded = function() {257 return this.video.ended;258 };259 this.getDuration = function() {260 return this.video.duration;261 };262 this.compSized = function(e) {263 this.$calcVideoBound();264 };265 this.recalc = function() {266 this.$calcVideoBound();267 };268 this.$calcVideoBound = function() {269 this.$videoBound = {270 x : this.getLeft(),271 y : this.getTop(),272 width : this.width - this.getLeft() - this.getBottom(),273 height : this.height - this.getTop() - this.getBottom()274 };275 if (this.$adjustProportions === true && this.$aspectRatio !== 0) {276 var ar = this.$videoBound.width / this.$videoBound.height;277 // ar = 3:1 ar' = 10:3 ar' > ar278 // +-------+ +--------------+279 // | video | | canvas | => decrease canvas width proportionally ar/ar'280 // +-------+ +--------------+281 //282 // ar = 3:1 ar' = 2:1 ar' < ar283 // +-----------+ +------+284 // | video | |canvas| => decrease canvas height proportionally ar'/ar285 // +-----------+ +------+286 if (ar < this.$aspectRatio) {287 this.$videoBound.height = Math.floor((this.$videoBound.height * ar) / this.$aspectRatio);288 } else {289 this.$videoBound.width = Math.floor((this.$videoBound.width * this.$aspectRatio)/ ar);290 }291 this.$videoBound.x = Math.floor((this.width - this.$videoBound.width )/2);292 this.$videoBound.y = Math.floor((this.height - this.$videoBound.height)/2);293 }294 };295 this.$continuePlayback = function() {296 this.$interruptCancelTask();297 if (this.video.paused === false && this.video.ended === false) {298 this.$animCurrentTime = this.video.currentTime;299 this.$animStallCounter = 0;300 this.repaint();301 }302 };303 this.$cancelPlayback = function() {304 if (this.video.paused === true || this.video.ended === true) {305 this.$interruptCancelTask();306 } else {307 if (this.$cancelTask === null) {308 var $this = this;309 this.$postponedTime = new Date().getTime();310 this.$cancelTask = zebkit.environment.setInterval(function() {311 var dt = new Date().getTime() - $this.$postponedTime;312 if (dt > $this.cancelationTimeout) {313 try {314 if ($this.video.paused === false) {315 $this.$lastError = "Playback failed";316 $this.pause();317 $this.repaint();318 $this.fire("playbackStateUpdated", [$this, "error"]);319 }320 } finally {321 $this.$interruptCancelTask();322 }323 } else {324 $this.fire("playbackStateUpdated", [$this, "wait"]);325 }326 }, 200);327 }328 }329 };330 this.$interruptCancelTask = function() {331 if (this.$cancelTask !== null) {332 zebkit.environment.clearInterval(this.$cancelTask);333 this.$postponedTime = this.$cancelTask = null;334 }335 };336 }337 ]).events("playbackStateUpdated");...

Full Screen

Full Screen

additional_delivery.js

Source:additional_delivery.js Github

copy

Full Screen

1BX.namespace("BX.Sale.Handler.Delivery.Additional");2BX.Sale.Handler.Delivery.Additional =3{4 ajaxUrl: "/bitrix/tools/sale/delivery_additional.php",5 interruptFlag: false,6 requestFlag: false,7 sendRequest: function(request)8 {9 if(!request)10 return;11 var postData = request,12 callback = request.callback ? request.callback : null,13 _this = this;14 if(postData.callback)15 delete postData.callback;16 postData.sessid = BX.bitrix_sessid();17 this.requestFlag = true;18 BX.ajax({19 timeout: 120,20 method: 'POST',21 dataType: 'json',22 url: this.ajaxUrl,23 data: postData,24 onsuccess: function(result)25 {26 _this.requestFlag = false;27 if(_this.interruptFlag)28 {29 _this.closeProgressDialog();30 return;31 }32 if(result)33 {34 if(callback && typeof callback == "function")35 callback.call(null, result);36 }37 else38 {39 _this.pb.showError(BX.message('SALE_DLVRS_ADD_LOC_COMP_AJAX_ERROR'));40 }41 if(result && result.ERROR)42 {43 _this.pb.showError(result.ERROR);44 }45 },46 onfailure: function(status)47 {48 _this.requestFlag = false;49 _this.pb.showError("ajax onfailure");50 _this.pb.showError("status: "+ status);51 if(_this.interruptFlag)52 _this.closeProgressDialog();53 }54 });55 },56 startLocationsCompare: function()57 {58 this.showProgressDialog();59 this.sendRequest({60 action: 'locations_compare',61 callback: BX.Sale.Handler.Delivery.Additional.processLocationsCompareAnswer62 });63 },64 processLocationsCompareAnswer: function(answer)65 {66 if(!answer || !answer.stage || !answer.action)67 {68 BX.Sale.Handler.Delivery.Additional.pb.showError(BX.message('SALE_DLVRS_ADD_LOC_COMP_AJAX_ERROR'));69 return;70 }71 if(answer.message)72 BX.Sale.Handler.Delivery.Additional.pb.showMessage(answer.message);73 if(answer.progress)74 BX.Sale.Handler.Delivery.Additional.pb.Update(answer.progress);75 if(answer.error)76 {77 BX.Sale.Handler.Delivery.Additional.pb.showError(answer.error);78 return;79 }80 if(answer.stage && answer.stage == 'finish')81 {82 BX('progress_cancel').value = BX.message('SALE_DLVRS_ADD_LOC_COMP_CLOSE');83 return;84 }85 BX.Sale.Handler.Delivery.Additional.sendRequest({86 action: answer.action,87 stage: answer.stage,88 step: answer.step ? answer.step : '',89 progress: answer.progress ? answer.progress : 0,90 callback: BX.Sale.Handler.Delivery.Additional.processLocationsCompareAnswer91 });92 },93 closeProgressDialog: function()94 {95 if(!this.interruptFlag)96 this.interruptFlag = true;97 if(this.requestFlag)98 return;99 BX.WindowManager.Get().Close();100 if(this.interruptFlag)101 this.interruptFlag = false;102 },103 showProgressDialog: function()104 {105 var popup = new BX.CDialog({106 content: BX.Sale.Handler.Delivery.Additional.pb.getNode(),107 width: 530,108 height: 200,109 draggable: true,110 resizable: true,111 title: BX.message('SALE_DLVRS_ADD_LOC_COMP_TITLE'),112 buttons: [113 {114 title: BX.message('JS_CORE_WINDOW_CANCEL'),115 id: 'progress_cancel',116 name: 'progress_cancel',117 action: function () {118 window.location.reload();119 BX.Sale.Handler.Delivery.Additional.closeProgressDialog();120 }121 }122 ]123 });124 BX.Sale.Handler.Delivery.Additional.pb.Init();125 popup.adjustSizeEx();126 popup.Show();127 BX.Sale.Handler.Delivery.Additional.pb.showError('');128 BX.Sale.Handler.Delivery.Additional.pb.showMessage(BX.message('SALE_DLVRS_ADD_LOC_COMP_PREPARE'));129 },130 pb: {131 width:0,132 obContainer: false,133 obIndicator: false,134 obIndicator2: false,135 Init: function()136 {137 this.obContainer = BX('instal-load-block');138 this.obIndicator = BX('instal-progress-bar-inner-text');139 this.obIndicator2 = BX('instal-progress-bar-span');140 this.obIndicator3 = BX('instal-progress-bar-inner');141 this.obContainer.style.display = '';142 this.width = this.obContainer.clientWidth || this.obContainer.offsetWidth;143 },144 Update: function(percent)145 {146 this.obIndicator.innerHTML = this.obIndicator3.style.width = percent+'%';147 this.obIndicator2.innerHTML = percent+'%';148 },149 showError: function(errorMsg)150 {151 var errDiv = BX("instal-load-error");152 errDiv.innerHTML = errorMsg;153 errDiv.style.display = !!errorMsg ? '' : 'none';154 BX.WindowManager.Get().adjustSizeEx();155 },156 showMessage: function(message, savePrevMsg)157 {158 var msgDiv = BX("instal-load-label"),159 oldMessages = msgDiv.innerHTML;160 msgDiv.innerHTML = (savePrevMsg ? oldMessages +"<br>" : '')+message;161 msgDiv.style.display = !!message ? '' : 'none';162 BX.WindowManager.Get().adjustSizeEx();163 },164 getNode: function()165 {166 var node = BX('instal-load-block');167 if(!node)168 {169 node = BX.create('div', {170 props: {171 className: 'instal-load-block',172 id: 'instal-load-block'173 },174 children:[175 BX.create('div',{176 props: {177 className: 'instal-load-label',178 id: 'instal-load-label'179 }180 }),181 BX.create('div',{182 props: {183 className: 'instal-load-error',184 id: 'instal-load-error'185 }186 }),187 BX.create('div',{188 props: {189 className: 'instal-progress-bar-outer',190 id: 'instal-progress-bar-outer'191 },192 style: {width: '500px'},193 children: [194 BX.create('div',{195 props: {196 className: 'instal-progress-bar-alignment'197 },198 children: [199 BX.create('div',{200 props: {201 className: 'instal-progress-bar-inner',202 id: 'instal-progress-bar-inner'203 },204 style: {width: '0%'},205 children:[206 BX.create('div',{207 props: {208 className: 'instal-progress-bar-inner-text',209 id: 'instal-progress-bar-inner-text'210 },211 style: {width: '500px'},212 html: '0%'213 })214 ]215 }),216 BX.create('div',{217 props: {218 className: 'instal-progress-bar-span',219 id: 'instal-progress-bar-span'220 },221 html: '0%'222 })223 ]224 })225 ]226 })227 ]228 });229 }230 return node;231 }232 }...

Full Screen

Full Screen

script.js

Source:script.js Github

copy

Full Screen

1BX.namespace("BX.Sale.Location.Map");2BX.Sale.Location.Map =3{4 ajaxUrl: "",5 interruptFlag: false,6 requestFlag: false,7 serviceLocationClass: "",8 sendRequest: function(request, callback)9 {10 if(!request)11 return;12 var postData = request,13 _this = this;14 postData.sessid = BX.bitrix_sessid();15 this.requestFlag = true;16 BX.ajax({17 timeout: 300,18 method: 'POST',19 dataType: 'json',20 url: this.ajaxUrl,21 data: postData,22 onsuccess: function(result)23 {24 _this.requestFlag = false;25 if(_this.interruptFlag)26 {27 _this.closeProgressDialog();28 return;29 }30 if(result)31 {32 if(callback && typeof callback == "function")33 callback.call(null, result);34 }35 else36 {37 _this.pb.showError(BX.message('SALE_DLVRS_ADD_LOC_COMP_AJAX_ERROR'));38 }39 if(result && result.ERROR)40 {41 _this.pb.showError(result.ERROR);42 }43 },44 onfailure: function(status)45 {46 _this.requestFlag = false;47 _this.pb.showError("ajax onfailure");48 _this.pb.showError("status: "+ status);49 if(_this.interruptFlag)50 _this.closeProgressDialog();51 }52 });53 },54 startLocationsCompare: function(needToDeleteExist)55 {56 this.showProgressDialog();57 this.sendRequest({58 action: 'locations_map',59 class: BX.Sale.Location.Map.serviceLocationClass,60 needToDeleteExist: needToDeleteExist || false61 },62 BX.Sale.Location.Map.processLocationsCompareAnswer63 );64 },65 processLocationsCompareAnswer: function(answer)66 {67 if(!answer || !answer.stage || !answer.action)68 {69 BX.Sale.Location.Map.pb.showError(BX.message('SALE_DLVRS_ADD_LOC_COMP_AJAX_ERROR'));70 return;71 }72 if(answer.message)73 BX.Sale.Location.Map.pb.showMessage(answer.message);74 if(answer.progress)75 BX.Sale.Location.Map.pb.Update(answer.progress);76 if(answer.error)77 {78 BX.Sale.Location.Map.pb.showError(answer.error);79 return;80 }81 if(answer.stage && answer.stage == 'finish')82 {83 BX('progress_cancel').value = BX.message('SALE_LOCATION_MAP_CLOSE');84 return;85 }86 BX.Sale.Location.Map.sendRequest({87 action: answer.action,88 stage: answer.stage,89 step: answer.step ? answer.step : '',90 progress: answer.progress ? answer.progress : 0,91 class: BX.Sale.Location.Map.serviceLocationClass92 },93 BX.Sale.Location.Map.processLocationsCompareAnswer94 );95 },96 closeProgressDialog: function()97 {98 if(!this.interruptFlag)99 this.interruptFlag = true;100 if(this.requestFlag)101 return;102 BX.WindowManager.Get().Close();103 if(this.interruptFlag)104 this.interruptFlag = false;105 },106 showProgressDialog: function()107 {108 var popup = new BX.CDialog({109 content: BX.Sale.Location.Map.pb.getNode(),110 width: 530,111 height: 200,112 draggable: true,113 resizable: true,114 title: BX.message('SALE_LOCATION_MAP_LOC_MAPPING'),115 buttons: [116 {117 title: BX.message('SALE_LOCATION_MAP_CANCEL'),118 id: 'progress_cancel',119 name: 'progress_cancel',120 action: function () {121 window.location.reload();122 BX.Sale.Location.Map.closeProgressDialog();123 }124 }125 ]126 });127 BX.Sale.Location.Map.pb.Init();128 popup.adjustSizeEx();129 popup.Show();130 BX.Sale.Location.Map.pb.showError('');131 BX.Sale.Location.Map.pb.showMessage(BX.message('SALE_LOCATION_MAP_PREPARING'));132 },133 pb: {134 width:0,135 obContainer: false,136 obIndicator: false,137 obIndicator2: false,138 Init: function()139 {140 this.obContainer = BX('install-load-block');141 this.obIndicator = BX('install-progress-bar-inner-text');142 this.obIndicator2 = BX('install-progress-bar-span');143 this.obIndicator3 = BX('install-progress-bar-inner');144 this.obContainer.style.display = '';145 this.width = this.obContainer.clientWidth || this.obContainer.offsetWidth;146 },147 Update: function(percent)148 {149 this.obIndicator.innerHTML = this.obIndicator3.style.width = percent+'%';150 this.obIndicator2.innerHTML = percent+'%';151 },152 showError: function(errorMsg)153 {154 var errDiv = BX("install-load-error");155 errDiv.innerHTML = errorMsg;156 errDiv.style.display = !!errorMsg ? '' : 'none';157 BX.WindowManager.Get().adjustSizeEx();158 },159 showMessage: function(message, savePrevMsg)160 {161 var msgDiv = BX("install-load-label"),162 oldMessages = msgDiv.innerHTML;163 msgDiv.innerHTML = (savePrevMsg ? oldMessages +"<br>" : '')+message;164 msgDiv.style.display = !!message ? '' : 'none';165 BX.WindowManager.Get().adjustSizeEx();166 },167 getNode: function()168 {169 var node = BX('install-load-block');170 if(!node)171 {172 node = BX.create('div', {173 props: {174 className: 'install-load-block',175 id: 'install-load-block'176 },177 children:[178 BX.create('div',{179 props: {180 className: 'install-load-label',181 id: 'install-load-label'182 }183 }),184 BX.create('div',{185 props: {186 className: 'install-load-error',187 id: 'install-load-error'188 }189 }),190 BX.create('div',{191 props: {192 className: 'install-progress-bar-outer',193 id: 'install-progress-bar-outer'194 },195 style: {width: '500px'},196 children: [197 BX.create('div',{198 props: {199 className: 'install-progress-bar-alignment'200 },201 children: [202 BX.create('div',{203 props: {204 className: 'install-progress-bar-inner',205 id: 'install-progress-bar-inner'206 },207 style: {width: '0%'},208 children:[209 BX.create('div',{210 props: {211 className: 'install-progress-bar-inner-text',212 id: 'install-progress-bar-inner-text'213 },214 style: {width: '500px'},215 html: '0%'216 })217 ]218 }),219 BX.create('div',{220 props: {221 className: 'install-progress-bar-span',222 id: 'install-progress-bar-span'223 },224 html: '0%'225 })226 ]227 })228 ]229 })230 ]231 });232 }233 return node;234 }235 }...

Full Screen

Full Screen

base.js

Source:base.js Github

copy

Full Screen

1'use strict';2/**3 * This is the base class for intercom classes4 *5 * @module services/inter_comm/base6 *7 */8const fs = require('fs');9const rootPrefix = '../..',10 InstanceComposer = require(rootPrefix + '/instance_composer'),11 logger = require(rootPrefix + '/helpers/custom_console_logger');12const IntercomBaseKlass = function(params) {13 const oThis = this;14 oThis.filePath = params.file_path;15 oThis.fromBlock = 0;16 oThis.toBlock = 0;17 oThis.snmData = {};18 oThis.interruptSignalObtained = false;19};20IntercomBaseKlass.prototype = {21 /**22 * Starts the process of the script with initializing processor23 *24 */25 init: function() {26 const oThis = this;27 // let go of all instances28 oThis.ic().instanceMap = {};29 oThis.setContractObj();30 // Read this from a file31 oThis.snmData = JSON.parse(fs.readFileSync(oThis.filePath).toString());32 oThis.checkForFurtherEvents();33 },34 /**35 * Check for further events36 *37 */38 checkForFurtherEvents: async function() {39 const oThis = this;40 try {41 const highestBlock = await this.getChainHighestBlock();42 // return if nothing more to do.43 if (highestBlock - oThis.BLOCK_CONFIRMATION <= oThis.snmData.lastProcessedBlock) return oThis.schedule();44 // consider case in which last block was not processed completely45 oThis.fromBlock = oThis.snmData.lastProcessedBlock + 1;46 oThis.toBlock = highestBlock - oThis.BLOCK_CONFIRMATION;47 const events = await oThis.completeContract.getPastEvents(48 oThis.EVENT_NAME,49 { fromBlock: oThis.fromBlock, toBlock: oThis.toBlock },50 function(error, logs) {51 if (error) logger.error('getPastEvents error:', error);52 logger.info('getPastEvents done from block:', oThis.fromBlock, 'to block:', oThis.toBlock);53 }54 );55 await oThis.processEventsArray(events);56 oThis.schedule();57 } catch (err) {58 logger.info('Exception got:', err);59 if (oThis.interruptSignalObtained) {60 logger.info('Exiting Process....');61 process.exit(1);62 } else {63 oThis.reInit();64 }65 }66 },67 /**68 * Register interrupt signal handlers69 *70 */71 registerInterruptSignalHandlers: function() {72 const oThis = this;73 process.on('SIGINT', function() {74 logger.info('Received SIGINT, cancelling block scanning');75 oThis.interruptSignalObtained = true;76 });77 process.on('SIGTERM', function() {78 logger.info('Received SIGTERM, cancelling block scanning');79 oThis.interruptSignalObtained = true;80 });81 },82 /**83 * Process events array84 *85 * @param {array} events - events array86 *87 */88 processEventsArray: async function(events) {89 const oThis = this,90 promiseArray = [];91 // nothing to do92 if (!events || events.length === 0) {93 oThis.updateIntercomDataFile();94 return Promise.resolve();95 }96 for (let i = 0; i < events.length; i++) {97 const eventObj = events[i],98 j = i;99 // await oThis.processEventObj(eventObj);100 if (oThis.parallelProcessingAllowed()) {101 promiseArray.push(102 new Promise(function(onResolve, onReject) {103 setTimeout(function() {104 oThis105 .processEventObj(eventObj)106 .then(onResolve)107 .catch(function(error) {108 logger.error('##### inside catch block #####: ', error);109 return onResolve();110 });111 }, j * 1000 + 100);112 })113 );114 } else {115 await oThis.processEventObj(eventObj).catch(function(error) {116 logger.error('inside catch block: ', error);117 return Promise.resolve();118 });119 }120 }121 if (oThis.parallelProcessingAllowed()) {122 await Promise.all(promiseArray);123 }124 oThis.updateIntercomDataFile();125 return Promise.resolve();126 },127 /**128 * Schedule129 */130 schedule: function() {131 const oThis = this;132 setTimeout(function() {133 oThis.checkForFurtherEvents();134 }, 5000);135 },136 /**137 * Re init138 */139 reInit: function() {140 const oThis = this;141 setTimeout(function() {142 oThis.init();143 }, 5000);144 },145 /**146 * Update intercom data file147 */148 updateIntercomDataFile: function() {149 const oThis = this;150 oThis.snmData.lastProcessedBlock = oThis.toBlock;151 fs.writeFileSync(oThis.filePath, JSON.stringify(oThis.snmData), function(err) {152 if (err) logger.error(err);153 });154 if (oThis.interruptSignalObtained) {155 logger.info('Exiting Process....');156 process.exit(1);157 }158 }159};160InstanceComposer.registerShadowableClass(IntercomBaseKlass, 'getIntercomBaseKlass');...

Full Screen

Full Screen

M35FD.js

Source:M35FD.js Github

copy

Full Screen

...60 setTimeout(function() {61 this.busy = false;62 this.track = getTrack(sector);63 this.cpu.mem.splice.apply(this.cpu.mem, [address, sectorSize].concat(this.disk.get(sector)));64 this.interrupt();65 }.bind(this), this.getSeekTime(sector) + ioTime);66 }67 };68 69 M35FD.prototype.write = function(sector, address) {70 if(this.busy) this.error(errors.ERROR_BUSY, 0);71 else if(!this.disk) this.error(errors.ERROR_NO_MEDIA, 0);72 else if(this.disk.writeProtected) this.error(errors.ERROR_PROTECTED, 0);73 else {74 this.busy = true;75 this.cpu.mem.b = 1;76 setTimeout(function() {77 this.busy = false;78 this.track = getTrack(sector);79 this.disk.set(sector, this.cpu.mem.slice(address, address + sectorSize));80 this.interrupt();81 }.bind(this), this.getSeekTime(sector) + ioTime);82 }83 };84 85 M35FD.prototype.insert = function(disk) {86 this.disk = disk;87 this.interrupt();88 };89 90 M35FD.prototype.eject = function() {91 var disk = this.disk;92 this.insert(null);93 if(this.busy) {94 this.error(errors.ERROR_EJECT);95 }96 return disk;97 };98 99 M35FD.prototype.interrupt = function() {100 if(this.interrupt && this.cpu) this.cpu.interrupt(this.interrupt);101 };102 103 M35FD.prototype.error = function(error, b) {104 var changed = false;105 if(error !== this.lastError) changed = true;106 if(typeof b !== 'undefined') this.cpu.mem.b = b;107 this.lastError = error;108 if(changed) this.interrupt();109 };110 111 M35FD.prototype.getSeekTime = function(sector) {112 return Math.abs(this.track - getTrack(sector)) * seekTime;113 };114 M35FD.prototype.reset = function() {115 this.busy = false;116 this.lastError = errors.ERROR_NONE;117 this.interruptMessage = 0;118 this.track = 0;119 };120 window.M35FD = M35FD;...

Full Screen

Full Screen

tty_state.js

Source:tty_state.js Github

copy

Full Screen

1// Copyright (c) 2015 Google Inc. All rights reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14/**15 * @constructor16 *17 * Null values indicate that the given property is not known. Unknown18 * properties are not propagated in the copyFrom/copyTo methods.19 */20export var TTYState = function() {21 /** @type {?boolean} */22 this.isatty = null;23 /** @type {?number} */24 this.rows = null;25 /** @type {?number} */26 this.columns = null;27 /** @type {?string} */28 this.interrupt_ = null;29};30export default TTYState;31/**32 * ^C33 */34TTYState.defaultInterrupt = String.fromCharCode('C'.charCodeAt(0) - 64);35/**36 * Copy values from another TTYState instance or an arbitrary object.37 *38 * @param {Object} obj39 * @return {void}40 */41TTYState.prototype.copyFrom = function(obj) {42 if ('isatty' in obj && obj.isatty != null)43 this.isatty = !!obj.isatty;44 if ('rows' in obj && obj.rows != null)45 this.rows = obj.rows;46 if ('columns' in obj && obj.columns != null)47 this.columns = obj.columns;48 if (!this.rows || !this.columns) {49 this.rows = 0;50 this.columns = 0;51 this.isatty = false;52 } else {53 this.isatty = true;54 }55 if (this.rows < 0 || this.columns < 0)56 throw new Error('Invalid tty size.');57 if ('interrupt_' in obj && obj.interrupt_ != null)58 this.interrupt_ = obj.interrupt_;59};60/**61 * @param {string} str62 * @return {void}63 */64TTYState.prototype.setInterrupt = function(str) {65 this.interrupt_ = str;66};67/**68 * @return {string}69 */70TTYState.prototype.getInterrupt = function() {71 if (this.interrupt_ == null)72 return TTYState.defaultInterrupt;73 return this.interrupt_;74};75/**76 * @param {Object} obj77 * @return {void}78 */79TTYState.prototype.copyTo = function(obj) {80 if (this.isatty != null)81 obj.isatty = this.isatty;82 if (this.rows != null)83 obj.rows = this.rows;84 if (this.columns != null)85 obj.columns = this.columns;86 if (this.interrupt != null)87 obj.interrupt = this.interrupt;88};89/**90 * @return {TTYState}91 */92TTYState.prototype.clone = function() {93 var rv = new TTYState();94 rv.copyFrom(this);95 return rv;...

Full Screen

Full Screen

column.js

Source:column.js Github

copy

Full Screen

1import React from 'react';2import ColumnHeader from './column_header';3import PropTypes from 'prop-types';4import { debounce } from 'lodash';5import { scrollTop } from '../../../scroll';6import { isMobile } from '../../../is_mobile';7export default class Column extends React.PureComponent {8 static propTypes = {9 heading: PropTypes.string,10 icon: PropTypes.string,11 children: PropTypes.node,12 active: PropTypes.bool,13 hideHeadingOnMobile: PropTypes.bool,14 };15 handleHeaderClick = () => {16 const scrollable = this.node.querySelector('.scrollable');17 if (!scrollable) {18 return;19 }20 this._interruptScrollAnimation = scrollTop(scrollable);21 }22 scrollTop () {23 const scrollable = this.node.querySelector('.scrollable');24 if (!scrollable) {25 return;26 }27 this._interruptScrollAnimation = scrollTop(scrollable);28 }29 handleScroll = debounce(() => {30 if (typeof this._interruptScrollAnimation !== 'undefined') {31 this._interruptScrollAnimation();32 }33 }, 200)34 setRef = (c) => {35 this.node = c;36 }37 render () {38 const { heading, icon, children, active, hideHeadingOnMobile } = this.props;39 const showHeading = heading && (!hideHeadingOnMobile || (hideHeadingOnMobile && !isMobile(window.innerWidth)));40 const columnHeaderId = showHeading && heading.replace(/ /g, '-');41 const header = showHeading && (42 <ColumnHeader icon={icon} active={active} type={heading} onClick={this.handleHeaderClick} columnHeaderId={columnHeaderId} />43 );44 return (45 <div46 ref={this.setRef}47 role='region'48 aria-labelledby={columnHeaderId}49 className='column'50 onScroll={this.handleScroll}51 >52 {header}53 {children}54 </div>55 );56 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5const expect = chai.expect;6const assert = chai.assert;7const should = chai.should();8const desiredCaps = {9};10driver.init(desiredCaps);11driver.interrupt();12driver.quit();13const wd = require('wd');14const chai = require('chai');15const chaiAsPromised = require('chai-as-promised');16chai.use(chaiAsPromised);17const expect = chai.expect;18const assert = chai.assert;19const should = chai.should();20const desiredCaps = {21};22driver.init(desiredCaps);23driver.interrupt();24driver.quit();25const wd = require('wd');26const chai = require('chai');27const chaiAsPromised = require('chai-as-promised');28chai.use(chaiAsPromised);29const expect = chai.expect;30const assert = chai.assert;31const should = chai.should();32const desiredCaps = {33};34driver.init(desiredCaps);35driver.interrupt();36driver.quit();37const wd = require('wd

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5const expect = chai.expect;6const PORT = 4723;7const HOST = 'localhost';8const config = {9};10describe('XCUITest Driver', function () {11 let driver;12 before(async function () {13 driver = await wd.promiseChainRemote(URL);14 await driver.init(config);15 await driver.sleep(5000);16 });17 it('should be able to use interrupt method', async function () {18 await driver.setImplicitWaitTimeout(0);19 const el = await driver.elementByAccessibilityId('URL');20 await driver.execute('mobile: tap', {element: el});21 await driver.setImplicitWaitTimeout(5000);22 await driver.execute('mobile: interrupt', {});23 await driver.setImplicitWaitTimeout(0);24 await driver.execute('mobile: tap', {element: el});25 await driver.setImplicitWaitTimeout(5000);26 await driver.execute('mobile: interrupt', {});27 await driver.setImplicitWaitTimeout(0);28 await driver.execute('mobile: tap', {element: el});29 await driver.setImplicitWaitTimeout(5000);30 await driver.execute('mobile: interrupt', {});31 await driver.setImplicitWaitTimeout(0);32 await driver.execute('mobile: tap', {element: el});33 await driver.setImplicitWaitTimeout(5000);34 await driver.execute('mobile: interrupt', {});35 await driver.setImplicitWaitTimeout(0);36 await driver.execute('mobile: tap', {element: el});37 await driver.setImplicitWaitTimeout(5000);38 await driver.execute('mobile: interrupt', {});39 await driver.setImplicitWaitTimeout(0);40 await driver.execute('mobile: tap', {element: el});41 await driver.setImplicitWaitTimeout(5000);42 await driver.execute('mobile: interrupt', {});43 await driver.setImplicitWaitTimeout(0);44 await driver.execute('mobile: tap', {element: el});45 await driver.setImplicitWaitTimeout(5000);

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require("webdriverio");2const opts = {3 desiredCapabilities: {4 }5};6const client = wdio.remote(opts);7async function main() {8 await client.init();9 await client.pause(5000);10 await client.interrupt();11 await client.pause(5000);12 await client.deleteSession();13}14main();

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const { exec } = require('child_process');3const assert = require('assert');4const PORT = 4723;5const HOST = 'localhost';6const DEVICE = 'iPhone Simulator';7const BUNDLE_ID = 'com.apple.Preferences';8const DEVICE_UDID = 'D1F9B3B3-6F3D-4D5E-9E3A-3F3A3C3F3D3A';9const driver = wd.promiseChainRemote(HOST, PORT);10const caps = {11};12async function main() {13 await driver.init(caps);14 await driver.sleep(2000);15 await driver.interrupt();16 await driver.sleep(2000);17 await driver.interrupt();18 await driver.quit();19}20main();21info: [debug] [XCUITest] Sending command to instruments: au.background()22info: [debug] [Instruments] [INST] 2018-06-28 07:00:19 +0000 Debug: Got new command 5 from instruments: au.background()23info: [debug] [Instruments] [INST] 2018-06-28 07:00:19 +0000 Debug: evaluating au.background()24info: [debug] [Instruments] [INST] 2018-06-28 07:00:19 +0000 Debug: target.frontMostApp().background()

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5chai.should();6describe('Test Appium Xcuitest Driver interrupt method', function () {7 this.timeout(600000);8 before(async () => {9 await driver.init({

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require("wd");2var assert = require('chai').assert;3var driver;4describe("My First Test", function() {5 this.timeout(300000);6 before(function() {7 var desired = {8 };9 .init(desired)10 .setImplicitWaitTimeout(60000);11 });12 after(function() {13 return driver.quit();14 });15 it("should do something", function() {16 .elementByAccessibilityId("Login")17 .click()18 .elementByAccessibilityId("Username")19 .sendKeys("xxxxx")20 .elementByAccessibilityId("Password")21 .sendKeys("xxxxx")22 .elementByAccessibilityId("Login")23 .click()24 .sleep(10000)25 .elementByAccessibilityId("Logout")26 .click()27 .sleep(10000)28 .elementByAccessibilityId("Login")29 .click()30 .elementByAccessibilityId("Username")31 .sendKeys("xxxxx")32 .elementByAccessibilityId("Password")33 .sendKeys("xxxxx")34 .elementByAccessibilityId("Login")35 .click()36 .sleep(10000)37 .elementByAccessibilityId("Logout")38 .click()39 .sleep(10000)40 .elementByAccessibilityId("Login")41 .click()42 .elementByAccessibilityId("Username")43 .sendKeys("xxxxx")44 .elementByAccessibilityId("Password")45 .sendKeys("xxxxx")46 .elementByAccessibilityId("Login")47 .click()48 .sleep(10000)49 .elementByAccessibilityId("Logout")50 .click()51 .sleep(10000)52 .elementByAccessibilityId("Login")53 .click()54 .elementByAccessibilityId("Username")55 .sendKeys("xxxxx")56 .elementByAccessibilityId("Password")57 .sendKeys("xxxxx")58 .elementByAccessibilityId("Login")

Full Screen

Using AI Code Generation

copy

Full Screen

1"use strict";2const wd = require("wd");3const chai = require("chai");4const chaiAsPromised = require("chai-as-promised");5const chaiString = require("chai-string");6const path = require("path");7const fs = require("fs");8chai.use(chaiAsPromised);9chai.use(chaiString);10chai.should();11chaiAsPromised.transferPromiseness = wd.transferPromiseness;12var scriptDir = path.dirname(fs.realpathSync(__filename));13var appDir = path.join(scriptDir, "..", "..", "apps");14var appPath = path.join(appDir, "TestApp.app");15var testAppSrcDir = path.join(appDir, "TestAppSrc");16var testAppSrcPath = path.join(testAppSrcDir, "ViewController.m");17var appDir = path.join(scriptDir, "..", "..", "apps");18var appPath = path.join(appDir, "TestApp.app");19var testAppSrcDir = path.join(appDir, "TestAppSrc");20var testAppSrcPath = path.join(testAppSrcDir, "ViewController.m");

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 Appium Xcuitest Driver automation tests on LambdaTest cloud grid

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

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful