How to use B.delay method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

89-delay_spec.js

Source:89-delay_spec.js Github

copy

Full Screen

1/**2 * Copyright JS Foundation and other contributors, http://js.foundation3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 **/16var should = require("should");17var delayNode = require("nr-test-utils").require("@node-red/nodes/core/function/89-delay.js");18var helper = require("node-red-node-test-helper");19var RED = require("nr-test-utils").require("node-red/lib/red");20var GRACE_PERCENTAGE=10;21var nanosToSeconds = 1000000000;22var millisToSeconds = 1000;23var secondsToMinutes = 60;24var secondsToHours = 3600;25var secondsToDays = 86400;26describe('delay Node', function() {27 beforeEach(function(done) {28 helper.startServer(done);29 });30 afterEach(function(done) {31 RED.settings.nodeMessageBufferMaxLength = 0;32 helper.unload();33 helper.stopServer(done);34 });35 it('should be loaded', function(done) {36 var flow = [{"id":"delayNode1","type":"delay", "nbRateUnits":"1", "name":"delayNode","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"day","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"wires":[[]]}];37 helper.load(delayNode, flow, function() {38 var delayNode1 = helper.getNode("delayNode1");39 delayNode1.should.have.property('name', 'delayNode');40 delayNode1.should.have.property('rate', 86400000);41 done();42 });43 });44 it('should be able to set rate to hour', function(done) {45 var flow = [{"id":"delayNode1","type":"delay", "nbRateUnits":"1", "name":"delayNode","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"hour","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"wires":[[]]}];46 helper.load(delayNode, flow, function() {47 var delayNode1 = helper.getNode("delayNode1");48 delayNode1.should.have.property('name', 'delayNode');49 delayNode1.should.have.property('rate', 3600000);50 done();51 });52 });53 it('should be able to set rate to minute', function(done) {54 var flow = [{"id":"delayNode1","type":"delay", "nbRateUnits":"1", "name":"delayNode","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"wires":[[]]}];55 helper.load(delayNode, flow, function() {56 var delayNode1 = helper.getNode("delayNode1");57 delayNode1.should.have.property('name', 'delayNode');58 delayNode1.should.have.property('rate', 60000);59 done();60 });61 });62 var TimeUnitEnum = {63 MILLIS : "milliseconds",64 SECONDS : "seconds",65 MINUTES : "minutes",66 HOURS : "hours",67 DAYS : "days"68 }69 /**70 * Tells whether two numeric values are close enough to each other71 * @param actualValue - the value we're testing72 * @param expectedValue - the value we're matching the test value against73 * @param tolerancePercent - the percentage of tolerated deviation (0 means equals)74 */75 function closeEnough(actualValue, expectedValue, tolerancePercent) {76 var toReturn;77 var toleranceFraction = expectedValue * (tolerancePercent/100);78 var minExpected = expectedValue - toleranceFraction;79 var maxExpected = expectedValue + toleranceFraction;80 if (actualValue >= minExpected && actualValue <= maxExpected) {81 toReturn = true;82 } else {83 toReturn = false;84 }85 return toReturn;86 }87 /**88 * Runs a delay test89 * @param aTimeout - the timeout quantity90 * @param aTimeoutUnit - the unit of the timeout: milliseconds, seconds, minutes, hours, days91 */92 function genericDelayTest(aTimeout, aTimeoutUnit, done) {93 var flow = [{"id":"delayNode1","type":"delay","name":"delayNode","pauseType":"delay","timeout":aTimeout,"timeoutUnits":aTimeoutUnit,"rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"wires":[["helperNode1"]]},94 {id:"helperNode1", type:"helper", wires:[]}];95 helper.load(delayNode, flow, function() {96 var delayNode1 = helper.getNode("delayNode1");97 var helperNode1 = helper.getNode("helperNode1");98 helperNode1.on("input", function(msg) {99 try {100 var endTime = process.hrtime(startTime);101 var runtimeNanos = ( (endTime[0] * nanosToSeconds) + endTime[1] );102 var runtimeSeconds = runtimeNanos / nanosToSeconds;103 var aTimeoutUnifiedToSeconds;104 // calculating the timeout in seconds105 if (aTimeoutUnit == TimeUnitEnum.MILLIS) {106 aTimeoutUnifiedToSeconds = aTimeout / millisToSeconds;107 } else if (aTimeoutUnit == TimeUnitEnum.SECONDS) {108 aTimeoutUnifiedToSeconds = aTimeout;109 } else if (aTimeoutUnit == TimeUnitEnum.MINUTES) {110 aTimeoutUnifiedToSeconds = aTimeout * secondsToMinutes;111 } else if (aTimeoutUnit == TimeUnitEnum.HOURS) {112 aTimeoutUnifiedToSeconds = aTimeout * secondsToHours;113 } else if (aTimeoutUnit == TimeUnitEnum.DAYS) {114 aTimeoutUnifiedToSeconds = aTimeout * secondsToDays;115 }116 if (closeEnough(runtimeSeconds, aTimeoutUnifiedToSeconds, GRACE_PERCENTAGE)) {117 done();118 } else {119 try {120 should.fail(null, null, "Delayed runtime seconds " + runtimeSeconds + " was not close enough to exlected timeout seconds: " + aTimeoutUnifiedToSeconds);121 } catch (err) {122 done(err);123 }124 }125 } catch(err) {126 done(err);127 }128 });129 var startTime = process.hrtime();130 delayNode1.receive({payload:"delayMe"});131 });132 }133 /**134 * We send a message, take a timestamp then when the message is received by the helper node, we take another timestamp.135 * Then check if the message has been delayed by the expected amount.136 */137 it('delays the message in seconds', function(done) {138 genericDelayTest(0.5, "seconds", done);139 });140 it('delays the message in milliseconds', function(done) {141 genericDelayTest(500, "milliseconds", done);142 });143 it('delays the message in minutes', function(done) { // this is also 0.5 seconds144 genericDelayTest(0.00833, "minutes", done);145 });146 it('delays the message in hours', function(done) { // this is also 0.5 seconds147 genericDelayTest(0.0001388, "hours", done);148 });149 it('delays the message in days', function(done) { // this is also 0.5 seconds150 genericDelayTest(0.000005787, "days", done);151 });152 /**153 * Runs a rate limit test - only testing seconds!154 * @param aLimit - the message limit count155 * @param nbUnit - the multiple of the unit, aLimit Message for nbUnit Seconds156 * @param runtimeInMillis - when to terminate run and count messages received157 */158 function genericRateLimitSECONDSTest(aLimit, nbUnit, runtimeInMillis, rateValue, done) {159 var flow = [{"id":"delayNode1","type":"delay","nbRateUnits":nbUnit,"name":"delayNode","pauseType":"rate","timeout":5,"timeoutUnits":"seconds","rate":aLimit,"rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"wires":[["helperNode1"]]},160 {id:"helperNode1", type:"helper", wires:[]}];161 helper.load(delayNode, flow, function() {162 var delayNode1 = helper.getNode("delayNode1");163 var helperNode1 = helper.getNode("helperNode1");164 var receivedMessagesStack = [];165 var rate = 1000 / aLimit * nbUnit;166 var receiveTimestamp;167 helperNode1.on("input", function(msg) {168 if (receiveTimestamp) {169 var elapse = process.hrtime(receiveTimestamp);170 var receiveInterval = (elapse[0] * 1000) + ((elapse[1] / nanosToSeconds) * 1000);171 receiveInterval.should.be.above(rate * 0.9);172 }173 receiveTimestamp = process.hrtime();174 receivedMessagesStack.push(msg);175 });176 var possibleMaxMessageCount = Math.ceil(aLimit * (runtimeInMillis / 1000) + aLimit); // +aLimit as at the start of the 2nd period, we're allowing the 3rd burst177 var i = 0;178 for (; i < possibleMaxMessageCount + 1; i++) {179 delayNode1.receive({ payload: i, rate: rateValue });180 }181 setTimeout(function() {182 try {183 receivedMessagesStack.length.should.be.lessThan(possibleMaxMessageCount);184 for (var j = 0; j < receivedMessagesStack.length; j++) {185 if (receivedMessagesStack[j].payload === j) {186 if (j === (receivedMessagesStack.length -1)) { // last message, all matched so far187 done();188 }189 } else {190 should.fail(null, null, "Received messages were not received in order. Message was " + receivedMessagesStack[i].payload + " on count " + i);191 }192 }193 } catch (err) {194 done(err);195 }196 }, runtimeInMillis);197 });198 }199 it('limits the message rate to 1 per second', function(done) {200 genericRateLimitSECONDSTest(1, 1, 1500, null, done);201 });202 it('limits the message rate to 1 per 2 seconds', function(done) {203 this.timeout(6000);204 genericRateLimitSECONDSTest(1, 2, 3000, null, done);205 });206 it('limits the message rate to 2 per seconds, 2 seconds', function(done) {207 this.timeout(6000);208 genericRateLimitSECONDSTest(2, 1, 2100, null, done);209 });210 it('limits the message rate using msg.rate', function (done) {211 RED.settings.nodeMessageBufferMaxLength = 3;212 genericRateLimitSECONDSTest(1, 1, 1500, 2000, done);213 });214 /**215 * Runs a rate limit test with drop support - only testing seconds!216 * @param aLimit - the message limit count217 * @param nbUnit - the multiple of the unit, aLimit Message for nbUnit Seconds218 * @param runtimeInMillis - when to terminate run and count messages received219 */220 function dropRateLimitSECONDSTest(aLimit, nbUnit, runtimeInMillis, rateValue, sendIntermediate, done) {221 if (!done) {222 done = sendIntermediate;223 sendIntermediate = false;224 }225 var outputs = 1;226 if (sendIntermediate) {227 outputs = 2;228 }229 var flow = [230 {"id":"delayNode1","type":"delay","name":"delayNode","pauseType":"rate","timeout":5,"nbRateUnits":nbUnit,"timeoutUnits":"seconds","rate":aLimit,"rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,outputs:outputs,"wires":[["helperNode1"],["helperNode2"]]},231 {id:"helperNode1", type:"helper", wires:[]},232 {id:"helperNode2", type:"helper", wires:[]}233 ]234 ;235 helper.load(delayNode, flow, function() {236 var delayNode1 = helper.getNode("delayNode1");237 var helperNode1 = helper.getNode("helperNode1");238 var helperNode2 = helper.getNode("helperNode2");239 var receivedMessagesStack = [];240 var receivedIntermediateMessagesStack = [];241 // Add a small grace to the calculated delay242 var rate = 1000/aLimit + 10;243 var receiveTimestamp;244 helperNode1.on("input", function(msg) {245 if (receiveTimestamp) {246 var elapse = process.hrtime(receiveTimestamp);247 var receiveInterval = (elapse[0] * 1000) + ((elapse[1] / nanosToSeconds) * 1000);248 receiveInterval.should.be.above(rate * 0.9);249 }250 receiveTimestamp = process.hrtime();251 receivedMessagesStack.push(msg);252 });253 helperNode2.on("input", function(msg) {254 receivedIntermediateMessagesStack.push(msg);255 });256 var possibleMaxMessageCount = Math.ceil(aLimit * (runtimeInMillis / 1000) + aLimit); // +aLimit as at the start of the 2nd period, we're allowing the 3rd burst257 var i = 0;258 delayNode1.receive({ payload: i, rate: rateValue });259 i++;260 for (; i < possibleMaxMessageCount + 1; i++) {261 setTimeout(function() {262 delayNode1.receive({payload:i});263 }, 2 * ((rate * i) / possibleMaxMessageCount) );264 }265 //we need to send a message delayed so that it doesn't get dropped266 setTimeout(function() {267 delayNode1.receive({payload:++i});268 }, runtimeInMillis - 300); // should give enough time to squeeze another message in269 setTimeout(function() {270 try {271 receivedMessagesStack.length.should.be.lessThan(possibleMaxMessageCount + 1);272 receivedMessagesStack.length.should.be.greaterThan(2); // ensure that we receive more than 1st and last message273 receivedMessagesStack[0].payload.should.be.exactly(0); // means we received the last message injected just before test termination274 var foundAtLeastOneDrop = false;275 for (var i = 0; i < receivedMessagesStack.length; i++) {276 if (i > 0) {277 if (receivedMessagesStack[i].payload - receivedMessagesStack[i - 1].payload > 1) {278 foundAtLeastOneDrop = true;279 }280 }281 }282 foundAtLeastOneDrop.should.be.true();283 if (sendIntermediate) {284 receivedIntermediateMessagesStack.length.should.be.greaterThan(0);285 } else {286 receivedIntermediateMessagesStack.length.should.be.exactly(0);287 }288 done();289 } catch (err) {290 done(err);291 }292 }, runtimeInMillis);293 });294 }295 it('limits the message rate to 1 per second, 4 seconds, with drop', function(done) {296 this.timeout(6000);297 dropRateLimitSECONDSTest(1, 1, 4000, null, done);298 });299 it('limits the message rate to 1 per 2 seconds, 4 seconds, with drop', function(done) {300 this.timeout(6000);301 dropRateLimitSECONDSTest(1, 2, 4500, null, done);302 });303 it('limits the message rate to 2 per second, 5 seconds, with drop', function(done) {304 this.timeout(6000);305 dropRateLimitSECONDSTest(2, 1, 5000, null, done);306 });307 it('limits the message rate to 2 per second, 5 seconds, with drop, 2nd output', function(done) {308 this.timeout(6000);309 dropRateLimitSECONDSTest(2, 1, 5000, null, true, done);310 });311 it('limits the message rate with drop using msg.rate', function (done) {312 this.timeout(6000);313 RED.settings.nodeMessageBufferMaxLength = 3;314 dropRateLimitSECONDSTest(2, 1, 5000, 1000, done);315 });316 /**317 * Returns true if the actualTimeout is gracefully in between the timeoutFrom and timeoutTo318 * values. Gracefully means that inBetween could actually mean smaller/greater values319 * than the timeout range so long as it's within an actual grace percentage.320 * @param timeoutFrom - The expected timeout range (low number)321 * @param timeoutTo - The expected timeout range (high number)322 * @param actualTimeout - The actual measured timeout value of test323 * @param allowedGracePercent - The percentage of grace allowed324 */325 function inBetweenDelays(timeoutFrom, timeoutTo, actualTimeout, allowedGracePercent) {326 if (closeEnough(actualTimeout, timeoutFrom, allowedGracePercent)) {327 return true;328 } else if (closeEnough(actualTimeout, timeoutTo, allowedGracePercent)) {329 return true;330 } else if (timeoutFrom < actualTimeout && timeoutTo > actualTimeout) {331 return true;332 } else {333 return false;334 }335 }336 /**337 * Runs a VARIABLE DELAY test, checks if the delay is in between the given timeout values338 * @param aTimeoutFrom - the timeout quantity which is the minimal acceptable wait period339 * @param aTimeoutTo - the timeout quantity which is the maximum acceptable wait period340 * @param aTimeoutUnit - the unit of the timeout: milliseconds, seconds, minutes, hours, days341 * @param delay - the variable delay: milliseconds342 */343 function variableDelayTest(aTimeoutFrom, aTimeoutTo, aTimeoutUnit, delay, done) {344 var flow = [{"id":"delayNode1","type":"delay","name":"delayNode","pauseType":"delayv","timeout":0.5,"timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":aTimeoutFrom,"randomLast":aTimeoutTo,"randomUnits":aTimeoutUnit,"drop":false,"wires":[["helperNode1"]]},345 {id:"helperNode1", type:"helper", wires:[]}];346 helper.load(delayNode, flow, function() {347 var delayNode1 = helper.getNode("delayNode1");348 var helperNode1 = helper.getNode("helperNode1");349 helperNode1.on("input", function(msg) {350 try {351 var endTime = process.hrtime(startTime);352 var runtimeNanos = ( (endTime[0] * nanosToSeconds) + endTime[1] );353 var runtimeSeconds = runtimeNanos / nanosToSeconds;354 var aTimeoutFromUnifiedToSeconds;355 var aTimeoutToUnifiedToSeconds;356 // calculating the timeout in seconds357 if (aTimeoutUnit == TimeUnitEnum.MILLIS) {358 aTimeoutFromUnifiedToSeconds = aTimeoutFrom / millisToSeconds;359 aTimeoutToUnifiedToSeconds = aTimeoutTo / millisToSeconds;360 } else if (aTimeoutUnit == TimeUnitEnum.SECONDS) {361 aTimeoutFromUnifiedToSeconds = aTimeoutFrom;362 aTimeoutToUnifiedToSeconds = aTimeoutTo;363 } else if (aTimeoutUnit == TimeUnitEnum.MINUTES) {364 aTimeoutFromUnifiedToSeconds = aTimeoutFrom * secondsToMinutes;365 aTimeoutToUnifiedToSeconds = aTimeoutTo * secondsToMinutes;366 } else if (aTimeoutUnit == TimeUnitEnum.HOURS) {367 aTimeoutFromUnifiedToSeconds = aTimeoutFrom * secondsToHours;368 aTimeoutToUnifiedToSeconds = aTimeoutTo * secondsToHours;369 } else if (aTimeoutUnit == TimeUnitEnum.DAYS) {370 aTimeoutFromUnifiedToSeconds = aTimeoutFrom * secondsToDays;371 aTimeoutToUnifiedToSeconds = aTimeoutTo * secondsToDays;372 }373 if (inBetweenDelays(aTimeoutFromUnifiedToSeconds, aTimeoutToUnifiedToSeconds, runtimeSeconds, GRACE_PERCENTAGE)) {374 done();375 } else {376 try {377 should.fail(null, null, "Delayed runtime seconds " + runtimeSeconds + " was not \"in between enough\" enough to expected values of: " + aTimeoutFromUnifiedToSeconds + " and " + aTimeoutToUnifiedToSeconds);378 } catch (err) {379 done(err);380 }381 }382 } catch(err) {383 done(err);384 }385 });386 var startTime = process.hrtime();387 delayNode1.receive({payload:"delayMe", delay:delay});388 });389 }390 it('variable delay set by msg.delay the message in milliseconds', function(done) {391 variableDelayTest("200", "300", "milliseconds", 250, done);392 });393 it('variable delay is the default if msg.delay not specified', function(done) {394 variableDelayTest("450", "550", "milliseconds", null, done);395 });396 it('variable delay is zero if msg.delay is zero', function(done) {397 variableDelayTest("0", "20", "milliseconds", 0, done);398 });399 it('variable delay is zero if msg.delay is negative', function(done) {400 variableDelayTest("0", "20", "milliseconds", -250, done);401 });402 /**403 * Runs a RANDOM DELAY test, checks if the delay is in between the given timeout values404 * @param aTimeoutFrom - the timeout quantity which is the minimal acceptable wait period405 * @param aTimeoutTo - the timeout quantity which is the maximum acceptable wait period406 * @param aTimeoutUnit - the unit of the timeout: milliseconds, seconds, minutes, hours, days407 */408 function randomDelayTest(aTimeoutFrom, aTimeoutTo, aTimeoutUnit, done) {409 var flow = [{"id":"delayNode1","type":"delay","name":"delayNode","pauseType":"random","timeout":5,"timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":aTimeoutFrom,"randomLast":aTimeoutTo,"randomUnits":aTimeoutUnit,"drop":false,"wires":[["helperNode1"]]},410 {id:"helperNode1", type:"helper", wires:[]}];411 helper.load(delayNode, flow, function() {412 var delayNode1 = helper.getNode("delayNode1");413 var helperNode1 = helper.getNode("helperNode1");414 helperNode1.on("input", function(msg) {415 try {416 var endTime = process.hrtime(startTime);417 var runtimeNanos = ( (endTime[0] * nanosToSeconds) + endTime[1] );418 var runtimeSeconds = runtimeNanos / nanosToSeconds;419 var aTimeoutFromUnifiedToSeconds;420 var aTimeoutToUnifiedToSeconds;421 // calculating the timeout in seconds422 if (aTimeoutUnit == TimeUnitEnum.MILLIS) {423 aTimeoutFromUnifiedToSeconds = aTimeoutFrom / millisToSeconds;424 aTimeoutToUnifiedToSeconds = aTimeoutTo / millisToSeconds;425 } else if (aTimeoutUnit == TimeUnitEnum.SECONDS) {426 aTimeoutFromUnifiedToSeconds = aTimeoutFrom;427 aTimeoutToUnifiedToSeconds = aTimeoutTo;428 } else if (aTimeoutUnit == TimeUnitEnum.MINUTES) {429 aTimeoutFromUnifiedToSeconds = aTimeoutFrom * secondsToMinutes;430 aTimeoutToUnifiedToSeconds = aTimeoutTo * secondsToMinutes;431 } else if (aTimeoutUnit == TimeUnitEnum.HOURS) {432 aTimeoutFromUnifiedToSeconds = aTimeoutFrom * secondsToHours;433 aTimeoutToUnifiedToSeconds = aTimeoutTo * secondsToHours;434 } else if (aTimeoutUnit == TimeUnitEnum.DAYS) {435 aTimeoutFromUnifiedToSeconds = aTimeoutFrom * secondsToDays;436 aTimeoutToUnifiedToSeconds = aTimeoutTo * secondsToDays;437 }438 if (inBetweenDelays(aTimeoutFromUnifiedToSeconds, aTimeoutToUnifiedToSeconds, runtimeSeconds, GRACE_PERCENTAGE)) {439 done();440 } else {441 try {442 should.fail(null, null, "Delayed runtime seconds " + runtimeSeconds + " was not \"in between enough\" enough to expected values of: " + aTimeoutFromUnifiedToSeconds + " and " + aTimeoutToUnifiedToSeconds);443 } catch (err) {444 done(err);445 }446 }447 } catch(err) {448 done(err);449 }450 });451 var startTime = process.hrtime();452 delayNode1.receive({payload:"delayMe"});453 });454 }455 it('randomly delays the message in seconds', function(done) {456 randomDelayTest(0.4, 0.8, "seconds", done);457 });458 it('randomly delays the message in milliseconds', function(done) {459 randomDelayTest("400", "800", "milliseconds", done);460 });461 it('randomly delays the message in minutes', function(done) {462 randomDelayTest(0.0066, 0.0133, "minutes", done);463 });464 it('delays the message in hours', function(done) {465 randomDelayTest(0.000111111, 0.000222222, "hours", done);466 });467 it('delays the message in days', function(done) {468 randomDelayTest(0.0000046296, 0.0000092593, "days", done);469 });470 it('handles delay queue', function(done) {471 this.timeout(2000);472 var flow = [{id:"delayNode1", type :"delay","name":"delayNode","nbRateUnits":"1","pauseType":"queue","timeout":1,"timeoutUnits":"seconds","rate":4,"rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"wires":[["helperNode1"]]},473 {id:"helperNode1", type:"helper", wires:[]}];474 helper.load(delayNode, flow, function() {475 var delayNode1 = helper.getNode("delayNode1");476 var helperNode1 = helper.getNode("helperNode1");477 var t = Date.now();478 helperNode1.on("input", function(msg) {479 msg.should.have.a.property('payload');480 msg.should.have.a.property('topic');481 try {482 if (msg.topic === "_none_") {483 msg.payload.should.equal(2);484 (Date.now() - t).should.be.approximately(500,200);485 }486 else if (msg.topic === "A") {487 msg.payload.should.equal(4);488 (Date.now() - t).should.be.approximately(750,200);489 }490 else {491 msg.topic.should.equal("B");492 msg.payload.should.equal(1);493 (Date.now() - t).should.be.approximately(1000,200);494 done();495 }496 } catch(e) {497 done(e);498 }499 });500 setTimeout(function() {501 // send test messages502 delayNode1.receive({payload:1}); // send something with blank topic503 delayNode1.receive({payload:1,topic:"A"}); // and something with a fixed topic504 delayNode1.receive({payload:1,topic:"B"}); // and something else with a fixed topic (3rd tick)505 delayNode1.receive({payload:2,topic:"A"}); // these should replace them in queue506 delayNode1.receive({payload:3,topic:"A"}); // ditto507 delayNode1.receive({payload:2}); // so only this should get out on first tick508 delayNode1.receive({payload:4,topic:"A"}); // and this one on second tick509 }, 275); // wait one tick beofre starting.. (to test no messages in queue path.)510 });511 });512 it('handles timed queue', function(done) {513 this.timeout(2000);514 var flow = [{"id":"delayNode1","type":"delay","name":"delayNode","pauseType":"timed","timeout":1,"timeoutUnits":"seconds","rate":2,"rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"wires":[["helperNode1"]]},515 {id:"helperNode1", type:"helper", wires:[]}];516 helper.load(delayNode, flow, function() {517 var delayNode1 = helper.getNode("delayNode1");518 var helperNode1 = helper.getNode("helperNode1");519 var t = Date.now();520 helperNode1.on("input", function(msg) {521 msg.should.have.a.property('payload');522 msg.should.have.a.property('topic');523 try {524 if (msg.topic === "_none_") {525 msg.payload.should.equal(2);526 (Date.now() - t).should.be.approximately(500,200);527 }528 else if (msg.topic === "A") {529 msg.payload.should.equal(4);530 (Date.now() - t).should.be.approximately(500,200);531 }532 else {533 msg.topic.should.equal("B");534 msg.payload.should.equal(1);535 (Date.now() - t).should.be.approximately(500,200);536 done();537 }538 } catch(e) {539 done(e);540 }541 });542 // send test messages543 delayNode1.receive({payload:1}); // send something with blank topic544 delayNode1.receive({payload:1,topic:"A"}); // and something with a fixed topic545 delayNode1.receive({payload:1,topic:"B"}); // and something else with a fixed topic546 delayNode1.receive({payload:2,topic:"A"}); // these should replace them in queue547 delayNode1.receive({payload:3,topic:"A"}); // ditto548 delayNode1.receive({payload:2}); // so all should go on first tick549 delayNode1.receive({payload:4,topic:"A"}); // and nothing on second550 });551 });552 it('can flush delay queue', function(done) {553 this.timeout(2000);554 var flow = [{"id":"delayNode1","type":"delay","name":"delayNode","pauseType":"delay","timeout":1,"timeoutUnits":"seconds","rate":2,"rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"wires":[["helperNode1"]]},555 {id:"helperNode1", type:"helper", wires:[]}];556 helper.load(delayNode, flow, function() {557 var delayNode1 = helper.getNode("delayNode1");558 var helperNode1 = helper.getNode("helperNode1");559 var t = Date.now();560 var c = 0;561 helperNode1.on("input", function(msg) {562 msg.should.have.a.property('payload');563 msg.should.have.a.property('topic');564 try {565 if (msg.topic === "foo") {566 msg.payload.should.equal(1);567 (Date.now() - t).should.be.approximately(0,100);568 c = c + 1;569 }570 else {571 if (msg.topic === "bar") {572 msg.payload.should.equal(1);573 (Date.now() - t).should.be.approximately(0,100);574 c = c + 1;575 }576 }577 if (c === 5) { done(); }578 } catch(e) {579 done(e);580 }581 });582 // send test messages583 delayNode1.receive({payload:1,topic:"foo"}); // send something with blank topic584 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic585 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic586 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic587 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic588 setImmediate( function() { delayNode1.receive({flush:true}); }); // reset the queue589 });590 });591 it('can part flush delay queue', function(done) {592 this.timeout(2000);593 var flow = [{"id":"delayNode1","type":"delay","name":"delayNode","pauseType":"delay","timeout":1,"timeoutUnits":"seconds","rate":2,"rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"wires":[["helperNode1"]]},594 {id:"helperNode1", type:"helper", wires:[]}];595 helper.load(delayNode, flow, function() {596 var delayNode1 = helper.getNode("delayNode1");597 var helperNode1 = helper.getNode("helperNode1");598 var t = Date.now();599 var c = 0;600 helperNode1.on("input", function(msg) {601 msg.should.have.a.property('payload');602 msg.should.have.a.property('topic');603 try {604 if (msg.topic === "foo") {605 msg.payload.should.equal(1);606 (Date.now() - t).should.be.approximately(0,100);607 c = c + 1;608 }609 else if (msg.topic === "bar") {610 msg.payload.should.equal(1);611 (Date.now() - t).should.be.approximately(200,100);612 c = c + 1;613 }614 else if (msg.topic === "boo") {615 msg.payload.should.equal(1);616 (Date.now() - t).should.be.approximately(400,100);617 c = c + 1;618 }619 if (c === 5) { done(); }620 } catch(e) {621 done(e);622 }623 });624 // send test messages625 delayNode1.receive({payload:1,topic:"foo"});626 setImmediate( function() { delayNode1.receive({payload:1,topic:"foo"}); } );627 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } );628 setImmediate( function() { delayNode1.receive({payload:1,topic:"boo"}); } );629 setImmediate( function() { delayNode1.receive({payload:1,topic:"boo"}); } );630 setImmediate( function() { delayNode1.receive({flush:2}); });631 setTimeout( function() { delayNode1.receive({flush:1}); }, 200);632 setTimeout( function() { delayNode1.receive({flush:4}); }, 400);633 });634 });635 it('can reset delay queue', function(done) {636 this.timeout(2000);637 var flow = [{"id":"delayNode1","type":"delay","name":"delayNode","pauseType":"delay","timeout":1,"timeoutUnits":"seconds","rate":2,"rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"wires":[["helperNode1"]]},638 {id:"helperNode1", type:"helper", wires:[]}];639 helper.load(delayNode, flow, function() {640 var delayNode1 = helper.getNode("delayNode1");641 var helperNode1 = helper.getNode("helperNode1");642 var t = Date.now();643 var c = 0;644 helperNode1.on("input", function(msg) {645 c = c + 1;646 });647 setTimeout( function() {648 if (c === 0) { done(); }649 }, 700);650 // send test messages651 delayNode1.receive({payload:1,topic:"foo"}); // send something with blank topic652 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic653 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic654 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic655 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic656 setImmediate( function() { delayNode1.receive({reset:true}); }); // reset the queue657 });658 });659 it('can flush rate limit queue', function(done) {660 this.timeout(2000);661 var flow = [{"id":"delayNode1","type":"delay","name":"delayNode","pauseType":"rate","timeout":1,"timeoutUnits":"seconds","rate":2,"rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"wires":[["helperNode1"]]},662 {id:"helperNode1", type:"helper", wires:[]}];663 helper.load(delayNode, flow, function() {664 var delayNode1 = helper.getNode("delayNode1");665 var helperNode1 = helper.getNode("helperNode1");666 var t = Date.now();667 var c = 0;668 helperNode1.on("input", function(msg) {669 msg.should.have.a.property('payload');670 msg.should.have.a.property('topic');671 try {672 if (msg.topic === "foo") {673 msg.payload.should.equal(1);674 (Date.now() - t).should.be.approximately(0,100);675 c = c + 1;676 }677 else {678 if (msg.topic === "bar") {679 msg.payload.should.equal(1);680 (Date.now() - t).should.be.approximately(0,100);681 c = c + 1;682 }683 }684 if (c === 5) { done(); }685 } catch(e) {686 done(e);687 }688 });689 // send test messages690 delayNode1.receive({payload:1,topic:"foo"}); // send something with blank topic691 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic692 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic693 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic694 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic695 setImmediate( function() { delayNode1.receive({flush:true}); }); // reset the queue696 });697 });698 it('can part flush rate limit queue', function(done) {699 this.timeout(2000);700 var flow = [{"id":"delayNode1","type":"delay","name":"delayNode","pauseType":"rate","timeout":1,"timeoutUnits":"seconds","rate":2,"rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"wires":[["helperNode1"]]},701 {id:"helperNode1", type:"helper", wires:[]}];702 helper.load(delayNode, flow, function() {703 var delayNode1 = helper.getNode("delayNode1");704 var helperNode1 = helper.getNode("helperNode1");705 var t = Date.now();706 var c = 0;707 helperNode1.on("input", function(msg) {708 msg.should.have.a.property('payload');709 msg.should.have.a.property('topic');710 try {711 if (msg.topic === "foo") {712 msg.payload.should.equal(1);713 (Date.now() - t).should.be.approximately(0,100);714 c = c + 1;715 }716 else if (msg.topic === "bar") {717 msg.payload.should.equal(1);718 (Date.now() - t).should.be.approximately(200,100);719 c = c + 1;720 }721 else if (msg.topic === "boo") {722 msg.payload.should.equal(1);723 (Date.now() - t).should.be.approximately(400,100);724 c = c + 1;725 }726 if (c === 5) { done(); }727 } catch(e) {728 done(e);729 }730 });731 // send test messages732 delayNode1.receive({payload:1,topic:"foo"});733 setImmediate( function() { delayNode1.receive({payload:1,topic:"foo"}); } );734 setImmediate( function() { delayNode1.receive({payload:1,topic:"foo"}); } );735 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } );736 setImmediate( function() { delayNode1.receive({payload:1,topic:"boo"}); } );737 setImmediate( function() { delayNode1.receive({flush:2}); });738 setTimeout( function() { delayNode1.receive({flush:1}); }, 200);739 setTimeout( function() { delayNode1.receive({flush:4}); }, 400);740 });741 });742 it('can part push to front of rate limit queue', function(done) {743 this.timeout(2000);744 var flow = [{"id":"delayNode1","type":"delay","name":"delayNode","pauseType":"rate","timeout":1,"timeoutUnits":"seconds","rate":1,"rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"wires":[["helperNode1"]]},745 {id:"helperNode1", type:"helper", wires:[]}];746 helper.load(delayNode, flow, function() {747 var delayNode1 = helper.getNode("delayNode1");748 var helperNode1 = helper.getNode("helperNode1");749 var t = Date.now();750 var c = 0;751 helperNode1.on("input", function(msg) {752 msg.should.have.a.property('payload');753 msg.should.have.a.property('topic');754 try {755 if (msg.topic === "aoo") {756 msg.payload.should.equal(1);757 (Date.now() - t).should.be.approximately(2,50);758 c = c + 1;759 }760 else if (msg.topic === "eoo") {761 msg.payload.should.equal(1);762 (Date.now() - t).should.be.approximately(4,50);763 c = c + 1;764 }765 else if (msg.topic === "coo") {766 msg.payload.should.equal(1);767 (Date.now() - t).should.be.approximately(202,50);768 c = c + 1;769 }770 else if (msg.topic === "boo") {771 msg.payload.should.equal(1);772 (Date.now() - t).should.be.approximately(406,50);773 c = c + 1;774 }775 else if (msg.topic === "doo") {776 msg.payload.should.equal(1);777 (Date.now() - t).should.be.approximately(4,50);778 c = c + 1;779 }780 if (c === 5) { done(); }781 } catch(e) {782 done(e);783 }784 });785 // send test messages786 delayNode1.receive({payload:1,topic:"aoo"});787 setImmediate( function() { delayNode1.receive({payload:1,topic:"boo"}); } );788 setImmediate( function() { delayNode1.receive({payload:1,topic:"coo",toFront:true}); } );789 setImmediate( function() { delayNode1.receive({payload:1,topic:"doo",toFront:true,flush:1}); } );790 setImmediate( function() { delayNode1.receive({payload:1,topic:"eoo",toFront:true}); } );791 setImmediate( function() { delayNode1.receive({flush:1}); });792 setTimeout( function() { delayNode1.receive({flush:1}); }, 200);793 setTimeout( function() { delayNode1.receive({flush:4}); }, 400);794 });795 });796 it('can reset rate limit queue', function(done) {797 this.timeout(2000);798 var flow = [{"id":"delayNode1","type":"delay","name":"delayNode","pauseType":"rate","timeout":1,"timeoutUnits":"seconds","rate":2,"rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"wires":[["helperNode1"]]},799 {id:"helperNode1", type:"helper", wires:[]}];800 helper.load(delayNode, flow, function() {801 var delayNode1 = helper.getNode("delayNode1");802 var helperNode1 = helper.getNode("helperNode1");803 var t = Date.now();804 var c = 0;805 helperNode1.on("input", function(msg) {806 msg.should.have.a.property('payload');807 msg.should.have.a.property('topic');808 try {809 if (msg.topic === "foo") {810 msg.payload.should.equal(1);811 (Date.now() - t).should.be.approximately(0,100);812 c = c + 1;813 }814 } catch(e) {815 done(e);816 }817 });818 setTimeout( function() {819 if (c === 1) { done(); }820 }, 700);821 // send test messages822 delayNode1.receive({payload:1,topic:"foo"}); // send something with blank topic823 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic824 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic825 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic826 setImmediate( function() { delayNode1.receive({payload:1,topic:"bar"}); } ); // send something with blank topic827 setImmediate( function() { delayNode1.receive({reset:true}); }); // reset the queue828 });829 });830 /* Messaging API support */831 function mapiDoneTestHelper(done, pauseType, drop, msgAndTimings) {832 const completeNode = require("nr-test-utils").require("@node-red/nodes/core/common/24-complete.js");833 const flow = [{id:"delayNode1",type:"delay",name:"delayNode", pauseType:pauseType, timeout:"1", timeoutUnits: "seconds",834 rate: "1", nbRateUnits: "1", rateUnits: "second", randomFirst:"950", randomLast:"1050",randomUnits:"milliseconds",835 drop: drop, wires: [[]]},836 {id:"completeNode1",type:"complete",scope: ["delayNode1"],uncaught:false,wires:[["helperNode1"]]},837 {id:"helperNode1",type:"helper", wires:[[]]}];838 const numMsgs = msgAndTimings.length;839 helper.load([delayNode, completeNode], flow, function () {840 const delayNode1 = helper.getNode("delayNode1");841 const helperNode1 = helper.getNode("helperNode1");842 const t = Date.now();843 let c = 0;844 helperNode1.on("input", function (msg) {845 msg.should.have.a.property('payload', msgAndTimings[c].msg.payload);846 (Date.now() - t).should.be.approximately(msgAndTimings[c].avr, msgAndTimings[c].var);847 c += 1;848 if ( c === numMsgs) {849 done();850 }851 });852 for (let i = 0; i < numMsgs; i++) {853 setImmediate( function() { delayNode1.receive(msgAndTimings[i].msg); } );854 }855 });856 }857 it('calls done when queued message is emitted (type: delay)', function(done) {858 mapiDoneTestHelper(done, "delay", false, [{msg:{payload:1}, avr:1000, var:100}]);859 });860 it('calls done when queued message is emitted (type: delayv)', function(done) {861 mapiDoneTestHelper(done, "delayv", false, [{msg:{payload:1, delay:1000}, avr:1000, var:100}]);862 });863 it('calls done when queued message is emitted (type: delay)', function(done) {864 mapiDoneTestHelper(done, "random", false, [{msg:{payload:1}, avr:1000, var:100}]);865 });866 it('calls done when queued message is cleared (type: delay)', function(done) {867 mapiDoneTestHelper(done, "delay", false, [{msg:{payload:1}, avr:100, var:100},868 {msg:{payload:2,reset:true}, avr:100, var:100}]);869 });870 it('calls done when queued message is cleared (type: delayv)', function(done) {871 mapiDoneTestHelper(done, "delayv", false, [{msg:{payload:1, delay:1000}, avr:100, var:100},872 {msg:{payload:2, reset:true}, avr:100, var:100}]);873 });874 it('calls done when queued message is cleared (type: random)', function(done) {875 mapiDoneTestHelper(done, "random", false, [{msg:{payload:1}, avr:100, var:100},876 {msg:{payload:2,reset:true}, avr:100, var:100}]);877 });878 it('calls done when queued message is flushed (type: delay)', function(done) {879 mapiDoneTestHelper(done, "delay", false, [{msg:{payload:1}, avr:100, var:100},880 {msg:{payload:2,flush:true}, avr:100, var:100}]);881 });882 it('calls done when queued message is flushed (type: delayv)', function(done) {883 mapiDoneTestHelper(done, "delayv", false, [{msg:{payload:1, delay:1000}, avr:100, var:100},884 {msg:{payload:2, flush:true}, avr:100, var:100}]);885 });886 it('calls done when queued message is flushed (type: random)', function(done) {887 mapiDoneTestHelper(done, "random", false, [{msg:{payload:1}, avr:100, var:100},888 {msg:{payload:2,flush:true}, avr:100, var:100}]);889 });890 it('calls done when rated message is emitted (drop: false)', function(done) {891 mapiDoneTestHelper(done, "rate", false, [{msg:{payload:1}, avr:0, var:100},892 {msg:{payload:2}, avr:1000, var:100}]);893 });894 it('calls done when rated message is emitted (drop: true)', function(done) {895 mapiDoneTestHelper(done, "rate", true, [{msg:{payload:1}, avr:0, var:100},896 {msg:{payload:2}, avr:0, var:100}]);897 });898 it('calls done when rated message is flushed', function(done) {899 mapiDoneTestHelper(done, "rate", false, [{msg:{payload:1}, avr:0, var:100},900 {msg:{payload:2}, avr:0, var:100},901 {msg:{payload:3,flush:true}, avr:0, var:100}]);902 });903 it('calls done when queued messages are sent (queue)', function(done) {904 this.timeout(3000);905 mapiDoneTestHelper(done, "queue", false, [{msg:{payload:1,topic:"A"}, avr:1000, var:700},906 {msg:{payload:2,topic:"B"}, avr:2000, var:700}]);907 });908 it('calls done when queued messages are sent (timed)', function(done) {909 mapiDoneTestHelper(done, "timed", false, [{msg:{payload:1,topic:"a"}, avr:500, var:700},910 {msg:{payload:2,topic:"b"}, avr:500, var:700}]);911 });912 it('calls done when queue is reset (queue/timed)', function(done) {913 mapiDoneTestHelper(done, "timed", false, [{msg:{payload:1,topic:"a"}, avr:0, var:500},914 {msg:{payload:2,reset:true}, avr:0, var:500}]);915 });916 it('calls done when queue is flushed (queue/timed)', function(done) {917 mapiDoneTestHelper(done, "timed", false, [{msg:{payload:1,topic:"a"}, avr:0, var:500},918 {msg:{payload:2,flush:true}, avr:0, var:500}]);919 });...

Full Screen

Full Screen

screenshot-consts.js

Source:screenshot-consts.js Github

copy

Full Screen

1'use strict';2const path = require('path');3const BUNDLE_NAME = require('../../package.json').name;4const MAX_LOWERTHIRD_NAMES = 5;5const STANDARD_DELAY = 375;6const FINISHED_DELAY = 2000;7const STANDARD_REPLICANT_PREFILLS = {8 allBids: undefined,9 allPrizes: undefined,10 currentBids: undefined,11 currentIntermission: undefined,12 currentPrizes: undefined,13 currentRun: undefined,14 'interview:names': undefined,15 recordTrackerEnabled: undefined,16 scores: undefined,17 stopwatch: undefined,18 total: undefined,19 tweets: undefined20};21const transitionBefore = function (page) {22 return page.evaluate(async () => {23 await document.querySelector('gdq-transition').waitForInit(); // eslint-disable-line no-undef24 });25};26module.exports = {27 BUNDLE_CONFIG: {},28 TEST_CASES: [{29 route: `bundles/${BUNDLE_NAME}/graphics/break.html`,30 additionalDelay: 1000,31 replicantPrefills: STANDARD_REPLICANT_PREFILLS32 }, {33 route: `bundles/${BUNDLE_NAME}/graphics/break.html`,34 nameAppendix: 'fanart',35 additionalDelay: 2000,36 replicantPrefills: STANDARD_REPLICANT_PREFILLS,37 before: async page => {38 const tweet = require(path.resolve(__dirname, '../fixtures/arguments/tweet.json'));39 await page.evaluate(t => {40 return new Promise(resolve => {41 const tl = document.querySelector('gdq-break').$.fanart.playItem(t); // eslint-disable-line no-undef42 tl.call(() => {43 resolve();44 }, null, null, '+=0.03');45 });46 }, tweet);47 }48 }, {49 route: `bundles/${BUNDLE_NAME}/graphics/transition.html`,50 nameAppendix: 'initial',51 selector: 'gdq-transition',52 entranceMethodName: null,53 additionalDelay: STANDARD_DELAY,54 replicantPrefills: STANDARD_REPLICANT_PREFILLS,55 before: transitionBefore56 }, {57 route: `bundles/${BUNDLE_NAME}/graphics/transition.html`,58 nameAppendix: 'fromOpenToClosed',59 selector: 'gdq-transition',60 entranceMethodName: 'fromOpenToClosed',61 additionalDelay: STANDARD_DELAY,62 replicantPrefills: STANDARD_REPLICANT_PREFILLS,63 before: transitionBefore64 }, {65 route: `bundles/${BUNDLE_NAME}/graphics/transition.html`,66 nameAppendix: 'fromClosedToOpen',67 selector: 'gdq-transition',68 entranceMethodName: 'fromClosedToOpen',69 entranceMethodArgs: [{fadeOutVideos: true}],70 additionalDelay: STANDARD_DELAY,71 replicantPrefills: STANDARD_REPLICANT_PREFILLS,72 before: transitionBefore73 }, {74 route: `bundles/${BUNDLE_NAME}/graphics/transition.html`,75 nameAppendix: 'fromPartialToClosed',76 selector: 'gdq-transition',77 entranceMethodName: 'fromPartialToClosed',78 additionalDelay: STANDARD_DELAY,79 replicantPrefills: STANDARD_REPLICANT_PREFILLS,80 before: transitionBefore81 }, {82 route: `bundles/${BUNDLE_NAME}/graphics/transition.html`,83 nameAppendix: 'fromClosedToPartial',84 selector: 'gdq-transition',85 entranceMethodName: 'fromClosedToPartial',86 entranceMethodArgs: [{fadeOutVideos: true}],87 additionalDelay: STANDARD_DELAY,88 replicantPrefills: {89 ...STANDARD_REPLICANT_PREFILLS,90 currentHost: undefined,91 nowPlaying: undefined92 },93 before: transitionBefore94 }, {95 route: `bundles/${BUNDLE_NAME}/graphics/interview.html`,96 nameAppendix: 'blank',97 additionalDelay: STANDARD_DELAY,98 replicantPrefills: STANDARD_REPLICANT_PREFILLS99 }, {100 route: `bundles/${BUNDLE_NAME}/graphics/lttp_tracker.html`,101 additionalDelay: 1500,102 replicantPrefills: STANDARD_REPLICANT_PREFILLS103 }, {104 route: `bundles/${BUNDLE_NAME}/graphics/omnibar.html`,105 additionalDelay: STANDARD_DELAY,106 replicantPrefills: STANDARD_REPLICANT_PREFILLS107 }, {108 route: `bundles/${BUNDLE_NAME}/graphics/widescreen_2_mario.html`,109 additionalDelay: STANDARD_DELAY,110 replicantPrefills: STANDARD_REPLICANT_PREFILLS111 }]112};113const gameplayLayoutTestCases = [{114 route: `bundles/${BUNDLE_NAME}/graphics/3ds.html`,115 additionalDelay: STANDARD_DELAY,116 replicantPrefills: STANDARD_REPLICANT_PREFILLS117}, {118 route: `bundles/${BUNDLE_NAME}/graphics/ds.html`,119 additionalDelay: STANDARD_DELAY,120 replicantPrefills: STANDARD_REPLICANT_PREFILLS121}, {122 route: `bundles/${BUNDLE_NAME}/graphics/ds_vertical.html`,123 additionalDelay: STANDARD_DELAY,124 replicantPrefills: STANDARD_REPLICANT_PREFILLS125}, {126 route: `bundles/${BUNDLE_NAME}/graphics/gameboy_1.html`,127 additionalDelay: STANDARD_DELAY,128 replicantPrefills: STANDARD_REPLICANT_PREFILLS129}, {130 route: `bundles/${BUNDLE_NAME}/graphics/gameboy_2.html`,131 additionalDelay: STANDARD_DELAY,132 replicantPrefills: STANDARD_REPLICANT_PREFILLS133}, {134 route: `bundles/${BUNDLE_NAME}/graphics/gameboy_3.html`,135 additionalDelay: STANDARD_DELAY,136 replicantPrefills: STANDARD_REPLICANT_PREFILLS137}, {138 route: `bundles/${BUNDLE_NAME}/graphics/gameboy_4.html`,139 additionalDelay: STANDARD_DELAY,140 replicantPrefills: STANDARD_REPLICANT_PREFILLS141}, {142 route: `bundles/${BUNDLE_NAME}/graphics/gba_1.html`,143 additionalDelay: STANDARD_DELAY,144 replicantPrefills: STANDARD_REPLICANT_PREFILLS145}, {146 route: `bundles/${BUNDLE_NAME}/graphics/gba_2.html`,147 additionalDelay: STANDARD_DELAY,148 replicantPrefills: STANDARD_REPLICANT_PREFILLS149}, {150 route: `bundles/${BUNDLE_NAME}/graphics/gba_4.html`,151 additionalDelay: STANDARD_DELAY,152 replicantPrefills: STANDARD_REPLICANT_PREFILLS153}, {154 route: `bundles/${BUNDLE_NAME}/graphics/standard_1.html`,155 additionalDelay: STANDARD_DELAY,156 replicantPrefills: STANDARD_REPLICANT_PREFILLS,157 coopTests: [2, 4]158}, {159 route: `bundles/${BUNDLE_NAME}/graphics/standard_1_smalttp.html`,160 replicantPrefills: {161 smalttpData: undefined162 }163}, {164 route: `bundles/${BUNDLE_NAME}/graphics/standard_2.html`,165 additionalDelay: STANDARD_DELAY,166 replicantPrefills: STANDARD_REPLICANT_PREFILLS167}, {168 route: `bundles/${BUNDLE_NAME}/graphics/standard_3.html`,169 additionalDelay: STANDARD_DELAY,170 replicantPrefills: STANDARD_REPLICANT_PREFILLS171}, {172 route: `bundles/${BUNDLE_NAME}/graphics/standard_4.html`,173 additionalDelay: STANDARD_DELAY,174 replicantPrefills: STANDARD_REPLICANT_PREFILLS175}, {176 route: `bundles/${BUNDLE_NAME}/graphics/widescreen_1.html`,177 additionalDelay: STANDARD_DELAY,178 replicantPrefills: STANDARD_REPLICANT_PREFILLS179}, {180 route: `bundles/${BUNDLE_NAME}/graphics/widescreen_2.html`,181 additionalDelay: STANDARD_DELAY,182 replicantPrefills: STANDARD_REPLICANT_PREFILLS183}, {184 route: `bundles/${BUNDLE_NAME}/graphics/widescreen_4.html`,185 additionalDelay: STANDARD_DELAY,186 replicantPrefills: STANDARD_REPLICANT_PREFILLS187}, {188 route: `bundles/${BUNDLE_NAME}/graphics/widescreen_4_2.html`,189 additionalDelay: STANDARD_DELAY,190 replicantPrefills: STANDARD_REPLICANT_PREFILLS191}];192gameplayLayoutTestCases.forEach(testCase => {193 module.exports.TEST_CASES.push({194 ...testCase,195 nameAppendix: 'not_started',196 replicantPrefills: {197 ...STANDARD_REPLICANT_PREFILLS,198 ...testCase.replicantPrefills,199 gameAudioChannels: [{200 sd: {muted: false, fadedBelowThreshold: false},201 hd: {muted: false, fadedBelowThreshold: false}202 }, {203 sd: {muted: false, fadedBelowThreshold: false},204 hd: {muted: false, fadedBelowThreshold: false}205 }, {206 sd: {muted: false, fadedBelowThreshold: false},207 hd: {muted: false, fadedBelowThreshold: false}208 }, {209 sd: {muted: false, fadedBelowThreshold: false},210 hd: {muted: false, fadedBelowThreshold: false}211 }]212 }213 }, {214 ...testCase,215 nameAppendix: 'running',216 replicantPrefills: {217 ...STANDARD_REPLICANT_PREFILLS,218 ...testCase.replicantPrefills,219 stopwatch: {220 state: 'running',221 time: {222 days: 0,223 hours: 1,224 minutes: 2,225 seconds: 3,226 milliseconds: 400,227 formatted: '1:02:03.4',228 raw: 3723400,229 timestamp: 1526531543450230 },231 results: [232 null,233 null,234 null,235 null236 ]237 }238 }239 }, {240 ...testCase,241 nameAppendix: 'finished',242 additionalDelay: FINISHED_DELAY,243 replicantPrefills: {244 ...STANDARD_REPLICANT_PREFILLS,245 ...testCase.replicantPrefills,246 stopwatch: {247 state: 'finished',248 time: {249 days: 0,250 hours: 1,251 minutes: 2,252 seconds: 3,253 milliseconds: 400,254 formatted: '1:02:03.4',255 raw: 3723400,256 timestamp: 1526531543450257 },258 results: [{259 time: {260 days: 0,261 hours: 1,262 minutes: 2,263 seconds: 3,264 milliseconds: 400,265 formatted: '1:02:03.4',266 raw: 3723400,267 timestamp: 1526589137479268 },269 place: 1,270 forfeit: false271 }, {272 time: {273 days: 0,274 hours: 1,275 minutes: 2,276 seconds: 3,277 milliseconds: 400,278 formatted: '1:02:03.4',279 raw: 3723400,280 timestamp: 1526589137479281 },282 place: 2,283 forfeit: true284 }, {285 time: {286 days: 0,287 hours: 1,288 minutes: 2,289 seconds: 3,290 milliseconds: 400,291 formatted: '1:02:03.4',292 raw: 3723400,293 timestamp: 1526589137479294 },295 place: 3,296 forfeit: false297 }, {298 time: {299 days: 0,300 hours: 1,301 minutes: 2,302 seconds: 3,303 milliseconds: 400,304 formatted: '1:02:03.4',305 raw: 3723400,306 timestamp: 1526589137479307 },308 place: 4,309 forfeit: false310 }]311 }312 }313 });314 if (testCase.coopTests) {315 testCase.coopTests.forEach(numberOfRunners => {316 module.exports.TEST_CASES.push({317 ...testCase,318 nameAppendix: `coop_${numberOfRunners}`,319 replicantPrefills: {320 ...STANDARD_REPLICANT_PREFILLS,321 ...testCase.replicantPrefills,322 currentRun: {323 name: 'Pre-Show',324 longName: 'Pre-Show',325 console: 'Unknown',326 commentators: 'Unknown',327 category: 'Hype',328 setupTime: '0',329 order: 1,330 estimate: '0:32:00',331 releaseYear: '',332 runners: [333 {name: 'SpikeVegeta', stream: 'spikevegeta'},334 {name: 'Blechy', stream: 'bellery_'},335 {name: 'Protomagicalgirl', stream: 'protomagicalgirl'},336 {name: 'JHobz', stream: 'jhobz296'}337 ].slice(0, numberOfRunners),338 notes: '',339 coop: true,340 id: 2640,341 pk: 2640,342 type: 'run'343 }344 }345 });346 });347 }348});349// Interview lowerthird tests.350for (let i = 1; i <= MAX_LOWERTHIRD_NAMES; i++) {351 module.exports.TEST_CASES.push({352 route: `bundles/${BUNDLE_NAME}/graphics/interview.html`,353 nameAppendix: `lowerthird-${i}`,354 selector: 'gdq-lowerthird',355 entranceMethodName: 'show',356 entranceMethodArgs: [[357 {name: 'one wwwwwWWWWWwwwwwWWWWWwwwwwWWWWW', title: 'one title WWWWWwwwwwWWWWWwwwww'},358 {name: 'two', title: 'two title'},359 {name: 'three wwwwwWWWWWwwwwwWWWWWwwwwwWWWWW', title: 'three title WWWWWwwwwwWWWWWwwwww'},360 {name: 'four', title: ''},361 {name: 'five wwwwwWWWWWwwwwwWWWWWwwwwwWWWWW', title: 'five title WWWWWwwwwwWWWWWwwwww'}362 ].slice(0, i)],363 additionalDelay: STANDARD_DELAY364 });...

Full Screen

Full Screen

script.js

Source:script.js Github

copy

Full Screen

1/* global $ TweenMax Power0 Power1 Power2 Power3 */23var stopWatch,4 loops = 1;56//A simple helper function to do display:none to multiple items7function hideAll(whichOnes) {8 for (var q = 0; q < whichOnes.length; q++) {9 $(whichOnes[q]).hide();10 }11}12//This will echo how many seconds have passed13function returnTimer() {14 stopWatch = ((new Date().getTime()) - stopWatch) * 0.001;15 console.log(stopWatch + " seconds");16}17//Set the initial states of all divs here18function setInitialStates() {19 hideAll([20 // images21 '.bg1',22 '.copy1',23 '.logo_white', 24 '.copy2txt1',25 '.copy2txt2',26 '.copy2txt3',27 '.copy2txt4',28 '.copy2plus1',29 '.copy2plus2',30 '.copy2plus3',31 '.copy2plus4',32 '.legal',33 '.blue_container',34 '.content_blue_container',35 '.logo_blue', 36 '.copy3',37 '.cta',38 '.left_border',39 '.bottom_border',40 '.right_border', 41 '.cta',42 '.logo1',43 '.backOpacity',44 '.copy4',45 ]);46}4748function resetAll() {49 TweenMax.set($(".container").find('*'), { clearProps: "all" });50}5152function replay() {53 TweenMax.killTweensOf($(".container").find('*'));54 resetAll();55 setInitialStates();56 seq01();57}5859function mainInit() {60 setInitialStates();61 $('.container').show();62 stopWatch = new Date().getTime();63 seq01();64}6566function seq01() {67 var twnDelay = 0;68 $(".bg1").show();69 $(".copy1").show();70 $(".logo_white").show();71 TweenMax.from($(".bg1"), 3, { alpha: 1, ease: Power2.easeOut, delay: twnDelay });72 twnDelay += 0.2;73 TweenMax.from($(".logo_white"), 3, { alpha: 1,x:0, ease: Power2.easeOut, delay: twnDelay });74 twnDelay += 0.5;75 TweenMax.from($(".copy1"), 3, { alpha: 0, x:0, ease: Power2.easeOut, delay: twnDelay });76 twnDelay += 1.5;77 TweenMax.delayedCall(twnDelay, seq02);78}7980function seq02() {81 var twnDelay = 0;82 $('.copy2txt1').show(); 83 $('.copy2plus1').show(); 84 $('.copy2txt2').show(); 85 $('.copy2plus2').show(); 86 $('.copy2txt3').show(); 87 $('.copy2plus3').show(); 88 $('.copy2txt4').show(); 89 $('.copy2plus4').show();90 91 $('.backOpacity').show();92 TweenMax.to($(".bg1"), 1, { alpha: 1, ease: Power2.easeOut, delay: twnDelay });93 twnDelay += 0.2;94 TweenMax.to($(".copy1"), 1, { alpha: 0, ease: Power2.easeOut, delay: twnDelay });95 twnDelay += 0.5;96 TweenMax.from($(".backOpacity"), 1.5, { alpha: 0, ease: Power2.easeOut, delay: twnDelay });97 twnDelay += 0.6; 98 TweenMax.from($(".copy2plus1"), 3, { alpha: 0, ease: Power2.easeOut, delay: twnDelay });99 TweenMax.from($(".copy2txt1"), 3, { alpha: 0, ease: Power2.easeOut, delay: twnDelay });100 twnDelay += 0.6; 101 TweenMax.from($(".copy2plus2"), 3, { alpha: 0, ease: Power2.easeOut, delay: twnDelay });102 TweenMax.from($(".copy2txt2"), 3, { alpha: 0, ease: Power2.easeOut, delay: twnDelay });103 twnDelay += 0.6; 104 TweenMax.from($(".copy2plus3"), 3, { alpha: 0, ease: Power2.easeOut, delay: twnDelay });105 TweenMax.from($(".copy2txt3"), 3, { alpha: 0, ease: Power2.easeOut, delay: twnDelay });106 twnDelay += 0.6; 107 TweenMax.from($(".copy2plus4"), 3, { alpha: 0, ease: Power2.easeOut, delay: twnDelay });108 TweenMax.from($(".copy2txt4"), 3, { alpha: 0, ease: Power2.easeOut, delay: twnDelay });109 110 twnDelay += 2.2;111 TweenMax.delayedCall(twnDelay, seq03);112}113function seq03() {114 var twnDelay = 0; 115 $('.copy3').show(); 116 twnDelay += 0.4; 117 TweenMax.to($(".bg1"), 1, { alpha: 1, ease: Power2.easeOut, delay: twnDelay });118 TweenMax.to($(".copy2plus1,.copy2plus2,.copy2plus3,.copy2plus4,.copy2txt1,.copy2txt2,.copy2txt3,.copy2txt4"), 1, { alpha: 0, ease: Power2.easeOut, delay: twnDelay });119 twnDelay += 0.4; 120 TweenMax.from($(".copy3"), 1, { alpha: 0, ease: Power2.easeOut, delay: twnDelay }); 121 twnDelay += 1;122 TweenMax.delayedCall(twnDelay, seq04);123}124function seq04() {125 var twnDelay = 0; 126 $('.left_border').show();127 $('.bottom_border').show();128 $('.right_border').show();129 $('.logo_blue').show();130 $('.copy4').show();131 $('.copy4a').show();132 $('.blue_container').show();133 $('.content_blue_container').show();134 $('.cta').show();135 $('.legal').show(); 136 TweenMax.to($(".bg1"), 1, { alpha: 1, scale:0.56, y:-38, x:90, ease: Quad.easeInOut, delay: twnDelay });137 TweenMax.to($(".copy3,.backOpacity"), 1.5, { alpha: 0, ease: Power2.easeOut, delay: twnDelay }); 138 twnDelay += 0.6;139 TweenMax.from($(".left_border"), 0.6, { height: 0, ease: Power1.easeOut, delay: twnDelay });140 twnDelay += 0.3;141 TweenMax.from($(".bottom_border"), 0.4, { width: 0, ease: Power1.easeOut, delay: twnDelay +0.30});142 143 TweenMax.from($(".logo_blue"), 0.9, { alpha: 0, ease: Power2.easeOut, delay: twnDelay +0.30 });144 twnDelay += 0.2;145 TweenMax.from($(".right_border"), 0.6, { y: 600, ease: Power1.easeOut, delay: twnDelay+0.35 }); 146 twnDelay += 1.2;147 TweenMax.from($(".copy4"), 2, { alpha: 0, ease: Power2.easeOut, delay: twnDelay });148 twnDelay += 0.3;149 TweenMax.from($(".copy4a"), 2, { alpha: 0, ease: Power2.easeOut, delay: twnDelay });150 twnDelay += 1;151 TweenMax.from($(".blue_container"), 0.9, { width: 0, ease: Power2.easeOut, delay: twnDelay });152 twnDelay += 0.8;153 TweenMax.from($(".content_blue_container"), 0.9, { alpha: 0, ease: Power2.easeOut, delay: twnDelay }); 154 TweenMax.from($(".legal"), 0.9, { opacity: 0, ease: Power1.easeOut, delay: twnDelay });155 twnDelay += 0.8;156 TweenMax.from($(".cta"), 0.9, { alpha: 0,x:-300, ease: Power2.easeOut, delay: twnDelay }); 157 twnDelay += 3.0;158 if (loops > 0) {159 loops -= 1;160 TweenMax.to($(".white_bg"), 0.3, { alpha: 1, ease: Power2.easeOut, delay: twnDelay });161 twnDelay += 0.1;162 TweenMax.to($(".white_bg"), 0.5, { alpha: 0, ease: Power2.easeOut, delay: twnDelay });163 TweenMax.delayedCall(twnDelay, function() {164 TweenMax.delayedCall(0, replay);165 });166 }167} ...

Full Screen

Full Screen

conditionaldelay_test.js

Source:conditionaldelay_test.js Github

copy

Full Screen

1// Copyright 2008 The Closure Library Authors. 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.14goog.provide('goog.async.ConditionalDelayTest');15goog.setTestOnly('goog.async.ConditionalDelayTest');16goog.require('goog.async.ConditionalDelay');17goog.require('goog.testing.MockClock');18goog.require('goog.testing.jsunit');19var invoked = false;20var delay = null;21var clock = null;22var returnValue = true;23var onSuccessCalled = false;24var onFailureCalled = false;25function callback() {26 invoked = true;27 return returnValue;28}29function setUp() {30 clock = new goog.testing.MockClock(true);31 invoked = false;32 returnValue = true;33 onSuccessCalled = false;34 onFailureCalled = false;35 delay = new goog.async.ConditionalDelay(callback);36 delay.onSuccess = function() { onSuccessCalled = true; };37 delay.onFailure = function() { onFailureCalled = true; };38}39function tearDown() {40 clock.dispose();41 delay.dispose();42}43function testDelay() {44 delay.start(200, 200);45 assertFalse(invoked);46 clock.tick(100);47 assertFalse(invoked);48 clock.tick(100);49 assertTrue(invoked);50}51function testStop() {52 delay.start(200, 500);53 assertTrue(delay.isActive());54 clock.tick(100);55 assertFalse(invoked);56 delay.stop();57 clock.tick(100);58 assertFalse(invoked);59 assertFalse(delay.isActive());60}61function testIsActive() {62 assertFalse(delay.isActive());63 delay.start(200, 200);64 assertTrue(delay.isActive());65 clock.tick(200);66 assertFalse(delay.isActive());67}68function testRestart() {69 delay.start(200, 50000);70 clock.tick(100);71 delay.stop();72 assertFalse(invoked);73 delay.start(200, 50000);74 clock.tick(199);75 assertFalse(invoked);76 clock.tick(1);77 assertTrue(invoked);78 invoked = false;79 delay.start(200, 200);80 clock.tick(200);81 assertTrue(invoked);82 assertFalse(delay.isActive());83}84function testDispose() {85 delay.start(200, 200);86 delay.dispose();87 assertTrue(delay.isDisposed());88 clock.tick(500);89 assertFalse(invoked);90}91function testConditionalDelay_Success() {92 returnValue = false;93 delay.start(100, 300);94 clock.tick(99);95 assertFalse(invoked);96 clock.tick(1);97 assertTrue(invoked);98 assertTrue(delay.isActive());99 assertFalse(delay.isDone());100 assertFalse(onSuccessCalled);101 assertFalse(onFailureCalled);102 returnValue = true;103 invoked = false;104 clock.tick(100);105 assertTrue(invoked);106 assertFalse(delay.isActive());107 assertTrue(delay.isDone());108 assertTrue(onSuccessCalled);109 assertFalse(onFailureCalled);110 invoked = false;111 clock.tick(200);112 assertFalse(invoked);113}114function testConditionalDelay_Failure() {115 returnValue = false;116 delay.start(100, 300);117 clock.tick(99);118 assertFalse(invoked);119 clock.tick(1);120 assertTrue(invoked);121 assertTrue(delay.isActive());122 assertFalse(delay.isDone());123 assertFalse(onSuccessCalled);124 assertFalse(onFailureCalled);125 invoked = false;126 clock.tick(100);127 assertTrue(invoked);128 assertFalse(onSuccessCalled);129 assertFalse(onFailureCalled);130 invoked = false;131 clock.tick(90);132 assertFalse(invoked);133 clock.tick(10);134 assertTrue(invoked);135 assertFalse(delay.isActive());136 assertFalse(delay.isDone());137 assertFalse(onSuccessCalled);138 assertTrue(onFailureCalled);139}140function testInfiniteDelay() {141 returnValue = false;142 delay.start(100, -1);143 // Test in a big enough loop.144 for (var i = 0; i < 1000; ++i) {145 clock.tick(80);146 assertTrue(delay.isActive());147 assertFalse(delay.isDone());148 assertFalse(onSuccessCalled);149 assertFalse(onFailureCalled);150 }151 delay.stop();152 assertFalse(delay.isActive());153 assertFalse(delay.isDone());154 assertFalse(onSuccessCalled);155 assertFalse(onFailureCalled);156}157function testCallbackScope() {158 var callbackCalled = false;159 var scopeObject = {};160 function internalCallback() {161 assertEquals(this, scopeObject);162 callbackCalled = true;163 return true;164 }165 delay = new goog.async.ConditionalDelay(internalCallback, scopeObject);166 delay.start(200, 200);167 clock.tick(201);168 assertTrue(callbackCalled);...

Full Screen

Full Screen

delay_test.js

Source:delay_test.js Github

copy

Full Screen

1// Copyright 2007 The Closure Library Authors. 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.14goog.provide('goog.async.DelayTest');15goog.setTestOnly('goog.async.DelayTest');16goog.require('goog.async.Delay');17goog.require('goog.testing.MockClock');18goog.require('goog.testing.jsunit');19var invoked = false;20var delay = null;21var clock = null;22function callback() {23 invoked = true;24}25function setUp() {26 clock = new goog.testing.MockClock(true);27 invoked = false;28 delay = new goog.async.Delay(callback, 200);29}30function tearDown() {31 clock.dispose();32 delay.dispose();33}34function testDelay() {35 delay.start();36 assertFalse(invoked);37 clock.tick(100);38 assertFalse(invoked);39 clock.tick(100);40 assertTrue(invoked);41}42function testStop() {43 delay.start();44 clock.tick(100);45 assertFalse(invoked);46 delay.stop();47 clock.tick(100);48 assertFalse(invoked);49}50function testIsActive() {51 assertFalse(delay.isActive());52 delay.start();53 assertTrue(delay.isActive());54 clock.tick(200);55 assertFalse(delay.isActive());56}57function testRestart() {58 delay.start();59 clock.tick(100);60 delay.stop();61 assertFalse(invoked);62 delay.start();63 clock.tick(199);64 assertFalse(invoked);65 clock.tick(1);66 assertTrue(invoked);67 invoked = false;68 delay.start();69 clock.tick(200);70 assertTrue(invoked);71}72function testStartIfNotActive() {73 delay.startIfNotActive();74 clock.tick(100);75 delay.stop();76 assertFalse(invoked);77 delay.startIfNotActive();78 clock.tick(199);79 assertFalse(invoked);80 clock.tick(1);81 assertTrue(invoked);82 invoked = false;83 delay.start();84 clock.tick(199);85 assertFalse(invoked);86 delay.startIfNotActive();87 clock.tick(1);88 assertTrue(invoked);89}90function testOverride() {91 delay.start(50);92 clock.tick(49);93 assertFalse(invoked);94 clock.tick(1);95 assertTrue(invoked);96}97function testDispose() {98 delay.start();99 delay.dispose();100 assertTrue(delay.isDisposed());101 clock.tick(500);102 assertFalse(invoked);103}104function testFire() {105 delay.start();106 clock.tick(50);107 delay.fire();108 assertTrue(invoked);109 assertFalse(delay.isActive());110 invoked = false;111 clock.tick(200);112 assertFalse(113 'Delay fired early with fire call, timeout should have been ' +114 'cleared',115 invoked);116}117function testFireIfActive() {118 delay.fireIfActive();119 assertFalse(invoked);120 delay.start();121 delay.fireIfActive();122 assertTrue(invoked);123 invoked = false;124 clock.tick(300);125 assertFalse(126 'Delay fired early with fireIfActive, timeout should have been ' +127 'cleared',128 invoked);...

Full Screen

Full Screen

delaySettingsComponent.js

Source:delaySettingsComponent.js Github

copy

Full Screen

1var DelaySettings = /*#__PURE__*/function () {2 "use strict";3 4 // divName;5 // div;6 // targetDiv;7 // randomDelaySwitch;8 // delayTimeout;9 // maxDelay;10 // maxDelayInput;11 // randomChecked;12 // resolveDelay = () => {};13 function DelaySettings(component) {14 this.divName = component.divName;15 16 this.resolveDelay = function () {};17 }18 19 var _proto = DelaySettings.prototype;20 21 _proto.createDelaySettingsTemplate = function createDelaySettingsTemplate(divName) {22 var delaySettingsTemplate = "\n <label class=\"randomTimeInput\">\n Max Delay (seconds):<input type='number' min='0' value='0' id='" + divName + "MaxDelayTime' class=\"delayTimeInput\">\n <span>Random Delay</span> <input id='" + divName + "RandomDelaySwitch' type=\"checkbox\"> \n <span class=\"delay-slider round\"></span>\n </label>\n ";23 return delaySettingsTemplate;24 };25 26 _proto.show = function show() {27 this.div = this.createDelaySettingsTemplate(this.divName);28 this.targetDiv = document.getElementById(this.divName + "DelaySwitchSettings");29 this.targetDiv.insertAdjacentHTML('afterbegin', this.div);30 this.initDelayValues();31 console.log(this.targetDiv);32 };33 34 _proto.hide = function hide() {35 this.targetDiv.innerHTML = "";36 this.maxDelay = 0;37 this.resetDelay();38 };39 40 _proto.initDelayValues = function initDelayValues() {41 var _this = this;42 43 this.randomDelaySwitch = document.getElementById(this.divName + "RandomDelaySwitch");44 this.maxDelayInput = document.getElementById(this.divName + "MaxDelayTime");45 46 this.maxDelayInput.oninput = function () {47 _this.maxDelay = _this.maxDelayInput.value;48 };49 50 this.randomDelaySwitch.onclick = function () {51 _this.maxDelay = _this.maxDelayInput.value;52 53 if (_this.randomDelaySwitch.checked == true) {54 _this.randomChecked = true; //TODO: Potentially add another component to specify 'minimum' delay time55 } else {56 _this.randomChecked = false;57 }58 };59 };60 61 _proto.setDelay = async function setDelay() {62 if (this.randomChecked == true) {63 this.maxDelay = Math.random() * this.maxDelayInput.value;64 console.log("Random delayed enabled for " + this.divName + ", maxDelay is " + this.maxDelay + " sec");65 }66 67 console.log("Delay for " + this.divName + ", maxDelay is " + this.maxDelay + " sec");68 await this.delay(this.maxDelay * 1000);69 };70 71 _proto.resetDelay = function resetDelay() {72 clearTimeout(this.delayTimeout);73 this.resolveDelay();74 };75 76 _proto.delay = async function delay(ms) {77 var _this2 = this;78 79 return new Promise(function (resolve) {80 _this2.delayTimeout = setTimeout(resolve, ms);81 _this2.resolveDelay = resolve; // testing this extra resolve. Mabye will fix premature stop playing time issue82 });83 };84 85 return DelaySettings;...

Full Screen

Full Screen

classtorc_1_1generic_1_1PortDelay.js

Source:classtorc_1_1generic_1_1PortDelay.js Github

copy

Full Screen

1var classtorc_1_1generic_1_1PortDelay =2[3 [ "Type", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#a45cb19496b2b5a502e6ff4fc105e9e24", [4 [ "eTypeDelay", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#a45cb19496b2b5a502e6ff4fc105e9e24aa6652c502f8e1f67fbc43d52c1eeb60f", null ],5 [ "eTypeLoadDelay", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#a45cb19496b2b5a502e6ff4fc105e9e24a578aebd3992b143d513c860bd4dbc459", null ]6 ] ],7 [ "PortDelay", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#ab99aef530d22fc0d9f71e853f4d95131", null ],8 [ "~PortDelay", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#a5edb1426eb490a911820f9460caf9d5b", null ],9 [ "PortDelay", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#afa150712a34ab20353ecb8cba7d36515", null ],10 [ "getAcLoad", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#ace26f23e9937daf056a82683fcdfa5af", null ],11 [ "getDelay", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#a19b1d258fe85df1354bf02df589d7981", null ],12 [ "getDerivation", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#afb89957a0ba41301aafa70d92fb3d003", null ],13 [ "getTransition", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#a78d3a3107a24e28425980d4fac7f25f3", null ],14 [ "getType", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#ad253db4f38a4039fe18d8ceed6e9b206", null ],15 [ "operator=", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#a0c461939892256ffe2772d5bf2289d0e", null ],16 [ "setAcLoad", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#abaf99c5e69b27289adf65c49745c684e", null ],17 [ "setDelay", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#ab33451b0f8567429b1447bb4fda24054", null ],18 [ "setDerivation", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#a52e76a5c176e2c9bf93f481a172f42d2", null ],19 [ "setTransition", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#a63e378668f70badc5cb074cdc45fa141", null ],20 [ "setType", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#a7b8ff0b308dbbf50974aebbb6be7ca56", null ],21 [ "mAcLoad", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#a756b2e1c3898bb84dc078fab5c4f5880", null ],22 [ "mDelay", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#af97a37198225e7b8bb75f08f013e7fd6", null ],23 [ "mDerivation", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#a1412cb51023ff901e12fd38d6d69b879", null ],24 [ "mTransition", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#a17de015b3b4a5079243e4861434b3f44", null ],25 [ "mType", "d6/d68/classtorc_1_1generic_1_1PortDelay.html#a7af0bd82d037ab01d624a863d9ed0a77", null ]...

Full Screen

Full Screen

classtorc_1_1generic_1_1PathDelay.js

Source:classtorc_1_1generic_1_1PathDelay.js Github

copy

Full Screen

1var classtorc_1_1generic_1_1PathDelay =2[3 [ "Factory", "dd/d4b/classtorc_1_1generic_1_1PathDelay_1_1Factory.html", "dd/d4b/classtorc_1_1generic_1_1PathDelay_1_1Factory" ],4 [ "Pointer", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#aa542c6a420841f883b001bf0a3dae4ea", null ],5 [ "Type", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#ada56209702c7b3b537311ad9a8837712", null ],6 [ "WeakPointer", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#adfc2332b355880138234e8dbc94ef0dc", null ],7 [ "PathDelay", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#aaebd780e89f96955011dbbe689ad1721", null ],8 [ "~PathDelay", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#a8cf0a7d3becae5085dead5960cc2896e", null ],9 [ "PathDelay", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#a59be8601f6cbc68975b351ad7d370437", null ],10 [ "addEvent", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#a3b077fdb80d852799ce06ce4a4bcc295", null ],11 [ "getDelay", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#a4836fcdc25fd76aca979efecd658545f", null ],12 [ "getEvents", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#a78af1554af156b9fc293bbcd072552ac", null ],13 [ "getSharedThis", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#a0eaf75c752d45cd9a7c12dc87383838c", null ],14 [ "operator=", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#a3670e0d59ebeecc2dddda95f804ee084", null ],15 [ "setDelay", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#a3c721ff5e33e90ad0b253ed33ce9e18f", null ],16 [ "setEvents", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#ae8235ad0ac7620c37c3c055ebc53aa40", null ],17 [ "setWeakThis", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#ac9318ea3a2b0aaaff1bb44ea10b09260", null ],18 [ "FactoryType< PathDelay >", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#a2dfc5fae261bc6b0e4a1a3b70858861a", null ],19 [ "mDelay", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#ad7bed5488a5f26ae98b49a5a6a6634a7", null ],20 [ "mEvents", "d0/dbd/classtorc_1_1generic_1_1PathDelay.html#a8595109c508518670bcf704d183f2af1", null ]...

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 should = chai.should();6const B = wd.PromiseChainWebdriver;7const config = {

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .withCapabilities({4 })5 .build();6driver.sleep(5000).then(function() {7 driver.executeScript("mobile: delay", {duration: 5}).then(function() {8 console.log('delayed for 5 seconds');9 });10});11driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { remote } = require('webdriverio')2const opts = {3 capabilities: {4 }5}6async function main () {7 const client = await remote(opts)8 await client.$('someElement').click()9 await client.delay(2000)10 await client.$('someOtherElement').click()11 await client.deleteSession()12}13main()14{15 "scripts": {16 },17 "repository": {

Full Screen

Using AI Code Generation

copy

Full Screen

1const B = require('bluebird');2const wd = require('wd');3const desired = {4};5driver.init(desired)6 .then(() => B.delay(10000))7 .then(() => driver.quit());

Full Screen

Using AI Code Generation

copy

Full Screen

1const B = require('bluebird');2const driver = require('./driver');3B.delay(5000)4 .then(() => {5 return driver.elementByAccessibilityId('Click me!');6 })7 .then((element) => {8 return element.click();9 })10 .then(() => {11 return driver.elementByAccessibilityId('I am a clickable button');12 })13 .then((element) => {14 return element.click();15 })16 .then(() => {17 return driver.quit();18 })19 .catch((err) => {20 console.log(err);21 });22const wd = require('wd');23const B = require('bluebird');24const driver = wd.promiseChainRemote('localhost', 4723);25B.promisifyAll(driver);26const desired = {27};28 .init(desired)29 .setImplicitWaitTimeout(5000);30module.exports = driver;

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('XCUITestDriver - delay', function () {2 it('should delay', async function () {3 await driver.delay(1000);4 });5});6commands.delay = async function (ms) {7 await B.delay(ms);8};9commands.delay = async function (ms) {10 await B.delay(ms);11};12commands.delay = async function (ms) {13 await B.delay(ms);14};15commands.delay = async function (ms) {16 await B.delay(ms);17};18commands.delay = async function (ms) {19 await B.delay(ms);20};21commands.delay = async function (ms) {22 await B.delay(ms);23};24commands.delay = async function (ms) {25 await B.delay(ms);26};27commands.delay = async function (ms) {28 await B.delay(ms);29};30commands.delay = async function (ms) {31 await B.delay(ms);32};33commands.delay = async function (ms) {34 await B.delay(ms);35};36commands.delay = async function (ms) {37 await B.delay(ms);38};39commands.delay = async function (ms) {40 await B.delay(ms);41};

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