How to use setUp method in robotframework-appiumlibrary

Best Python code snippet using robotframework-appiumlibrary_python

test_pubsub_3_1.js

Source:test_pubsub_3_1.js Github

copy

Full Screen

1/*******************************************************************************2 * test_pubsub_3_1.js:3 * Component of the DOH-based test suite for the OpenAjax Hub.4 *5 * JavaScript logic for the unit test for routines having to do with managing event6 * publishing and event subscribing. (The "event hub" or "topic bus".)7 * [ This is a port of the Hub 1.0 testcases found in _TestPubSub.js. ]8 *9 * Copyright 2008 OpenAjax Alliance10 *11 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 12 * use this file except in compliance with the License. You may obtain a copy 13 * of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless 14 * required by applicable law or agreed to in writing, software distributed 15 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 16 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations under the License.18 *19 ******************************************************************************/20/***********************************************************************21 * js3_122 **********************************************************************/23var js3_1 = {};24js3_1_0 = {};25js3_1_1 = {};26js3_1_2 = {};27js3_1_3 = {};28js3_1_4 = {};29js3_1_5 = {};30js3_1_6 = {};31js3_1_7 = {};32js3_1_8 = {};33//////////////////////////////////////////////////////34js3_1_0.run = function(scriptnum) {35 js3_1_0.scriptnum = scriptnum;36 js3_1_0.subscribe = {};37 js3_1_0.setup = {};38 js3_1_0.fire = {};39 js3_1_0.check = {};40 // In callback for topic X, publish on topic X 41 this.hubClient.subscribe("pub.same", js3_1.cbPubSame, this, function( subscriptionID, success, errCode ) {42 js3_1_0.do_setup.call(this, "_trigger");43 }, "_trigger");44}45js3_1.cbPubSame = function(subject, message, subscriberData) {46 if(message.step == "setup") {47 js3_1_0.do_fire.call(this, subscriberData);48 } else if(message.step == "fire") { 49 js3_1_0.do_check.call(this, subscriberData);50 } else if(message.step == "check") {51 js3_1_0.do_finish.call(this, subscriberData);52 } else {53 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] );54 }55 return;56}57js3_1_0.do_setup = function(subscriberName) {58 js3_1_0.subscribe[subscriberName] = true;59 if (js3_1_0.subscribe["_trigger"] === true) {60 this.hubClient.publish("pub.same", { step: "setup" }); 61 }62}63js3_1_0.do_fire = function(data) {64 js3_1_0.setup[data] = true;65 if (js3_1_0.setup["_trigger"] === true) {66 this.hubClient.publish("pub.same", { step: "fire" });67 }68}69js3_1_0.do_check = function(data) {70 js3_1_0.fire[data] = true;71 if (js3_1_0.fire["_trigger"] === true) {72 this.hubClient.publish("pub.same", { step: "check" });73 }74}75js3_1_0.do_finish = function(data) {76 js3_1_0.check[data] = true;77 if (js3_1_0.check["_trigger"] === true) {78 if (js3_1_0.setup["_trigger"] === true && 79 js3_1_0.fire["_trigger"] === true && 80 js3_1_0.check["_trigger"] === true) {81 this.sendMsg( ["done"] );82 } else {83 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.0"] );84 }85 }86}87//////////////////////////////////////////////////////88js3_1_1.run = function(scriptnum) {89 js3_1_1.scriptnum = scriptnum;90 js3_1_1.subscribe = {};91 js3_1_1.setup = {};92 js3_1_1.fire = {};93 js3_1_1.check = {};94 // In callback for topic X, subscribe to topic X 95 this.hubClient.subscribe("pub.other.trigger", js3_1.cbPubOther, this, function( subscriptionID, success, errCode ) {96 js3_1_1.do_setup.call(this, "_trigger");97 }, "_trigger");98 this.hubClient.subscribe("pub.other.target", js3_1.cbPubOther, this, function( subscriptionID, success, errCode ) {99 js3_1_1.do_setup.call(this, "_target");100 }, "_target");101}102js3_1.cbPubOther = function(subject, message, subscriberData) {103 if(message.step == "setup") {104 js3_1_1.do_fire.call(this, subscriberData);105 } else if(message.step == "fire") {106 js3_1_1.do_check.call(this, subscriberData);107 } else if(message.step == "check") {108 js3_1_1.do_finish.call(this, subscriberData);109 } else {110 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] );111 }112 return;113}114js3_1_1.do_setup = function(subscriberName) {115 js3_1_1.subscribe[subscriberName] = true;116 if (js3_1_1.subscribe["_trigger"] === true && js3_1_1.subscribe["_target"] === true) {117 this.hubClient.publish("pub.other.trigger", { step: "setup" }); 118 this.hubClient.publish("pub.other.target", { step: "setup" }); 119 }120}121js3_1_1.do_fire = function(data) {122 js3_1_1.setup[data] = true;123 if (js3_1_1.setup["_trigger"] === true && js3_1_1.setup["_target"] === true) {124 this.hubClient.publish("pub.other.trigger", { step: "fire" });125 }126}127js3_1_1.do_check = function(data) {128 js3_1_1.fire[data] = true;129 if (js3_1_1.fire["_trigger"] === true) {130 this.hubClient.publish("pub.other.target", { step: "check" });131 }132}133js3_1_1.do_finish = function(data) {134 js3_1_1.check[data] = true;135 if (js3_1_1.check["_target"] === true) {136 if (js3_1_1.setup["_trigger"] === true && js3_1_1.setup["_target"] === true &&137 js3_1_1.fire["_trigger"] === true && typeof js3_1_1.fire["_target"] === "undefined" &&138 typeof js3_1_1.check["_trigger"] === "undefined" && js3_1_1.check["_target"] === true) {139 this.sendMsg( ["done"] );140 } else {141 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.1"] );142 }143 }144}145//////////////////////////////////////////////////////146js3_1_2.run = function(scriptnum) {147 js3_1_2.scriptnum = scriptnum;148 js3_1_2.subscribe = {};149 js3_1_2.setup = {};150 js3_1_2.fire = {};151 js3_1_2.check = {};152 // In callback for topic X, subscribe to topic X 153 this.hubClient.subscribe("sub.same", js3_1.cbSubSame, this, function( subscriptionID, success, errCode ) {154 js3_1_2.do_setup.call(this, "_trigger");155 }, "_trigger");156}157js3_1.cbSubSame = function(subject, message, subscriberData) {158 if(message.step == "setup") {159 js3_1_2.do_fire.call(this, subscriberData);160 } else if(message.step == "fire") {161 this.hubClient.subscribe(subject, js3_1.cbSubSame, this, function( subscriptionID, success, errCode ) {162 js3_1_2.do_check.call(this, subscriberData);163 }, "_target");164 } else if(message.step == "check") {165 js3_1_2.do_finish.call(this, subscriberData);166 } else {167 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 168 }169 return;170}171js3_1_2.do_setup = function(subscriberName) {172 js3_1_2.subscribe[subscriberName] = true;173 if (js3_1_2.subscribe["_trigger"] === true) {174 this.hubClient.publish("sub.same", { step: "setup" }); 175 }176}177js3_1_2.do_fire = function(data) {178 js3_1_2.setup[data] = true;179 if (js3_1_2.setup["_trigger"] === true) {180 this.hubClient.publish("sub.same", { step: "fire" });181 }182}183js3_1_2.do_check = function(data) {184 js3_1_2.fire[data] = true;185 if (js3_1_2.fire["_trigger"] === true) {186 this.hubClient.publish("sub.same", { step: "check" });187 }188}189js3_1_2.do_finish = function(data) {190 js3_1_2.check[data] = true;191 if (js3_1_2.check["_trigger"] === true && js3_1_2.check["_target"] === true) {192 if (js3_1_2.setup["_trigger"] === true && typeof js3_1_2.setup["_target"] === "undefined" &&193 js3_1_2.fire["_trigger"] === true && typeof js3_1_2.fire["_target"] === "undefined" &&194 js3_1_2.check["_trigger"] === true && js3_1_2.check["_target"] === true) {195 this.sendMsg( ["done"] );196 } else {197 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.2"] );198 }199 }200}201//////////////////////////////////////////////////////202js3_1_3.run = function(scriptnum) {203 js3_1_3.scriptnum = scriptnum;204 js3_1_3.subscribe = {};205 js3_1_3.setup = {};206 js3_1_3.fire = {};207 js3_1_3.check = {};208 // In callback for topic X, subscribe to topic Y 209 this.hubClient.subscribe("sub.other.trigger", js3_1.cbSubOther, this, function( subscriptionID, success, errCode ) {210 js3_1_3.do_setup.call(this, "_trigger");211 }, "_trigger");212}213js3_1.cbSubOther = function(subject, message, subscriberData) {214 if(message.step == "setup") { 215 js3_1_3.do_fire.call(this, subscriberData);216 } else if(message.step == "fire") {217 this.hubClient.subscribe("sub.other.target", js3_1.cbSubOther, this, function( subscriptionID, success, errCode ) {218 js3_1_3.do_check.call(this, subscriberData);219 }, "_target");220 } else if(message.step == "check") {221 js3_1_3.do_finish.call(this, subscriberData);222 } else {223 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 224 }225 return;226}227js3_1_3.do_setup = function(subscriberName) {228 js3_1_3.subscribe[subscriberName] = true;229 if (js3_1_3.subscribe["_trigger"] === true) {230 this.hubClient.publish("sub.other.trigger", { step: "setup" }); 231 this.hubClient.publish("sub.other.target", { step: "setup" }); 232 }233}234js3_1_3.do_fire = function(data) {235 js3_1_3.setup[data] = true;236 if (js3_1_3.setup["_trigger"] === true) {237 this.hubClient.publish("sub.other.trigger", { step: "fire" });238 }239}240js3_1_3.do_check = function(data) {241 js3_1_3.fire[data] = true;242 if (js3_1_3.fire["_trigger"] === true) {243 this.hubClient.publish("sub.other.trigger", { step: "check" });244 this.hubClient.publish("sub.other.target", { step: "check" });245 }246}247js3_1_3.do_finish = function(data) {248 js3_1_3.check[data] = true;249 if (js3_1_3.check["_trigger"] === true && js3_1_3.check["_target"] === true) {250 if (js3_1_3.setup["_trigger"] === true && typeof js3_1_3.setup["_target"] === "undefined" &&251 js3_1_3.fire["_trigger"] === true && typeof js3_1_3.fire["_target"] === "undefined" &&252 js3_1_3.check["_trigger"] === true && js3_1_3.check["_target"] === true) {253 this.sendMsg( ["done"] );254 } else {255 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.3"] );256 }257 }258}259//////////////////////////////////////////////////////260js3_1_4.run = function(scriptnum) {261 js3_1_4.scriptnum = scriptnum;262 js3_1_4.subscribe = {};263 js3_1_4.setup = {};264 js3_1_4.fire = {};265 js3_1_4.check = {};266 // In callback for topic X, cancel another subscription to the same topic X267 this.hubClient.subscribe("unsub.same", js3_1.cbUnsubSame, this, function( subscriptionID, success, errCode ) {268 js3_1_4.do_setup.call(this, "_trigger");269 }, "_trigger");270 this.hubClient.subscribe("unsub.same", js3_1.cbUnsubSame, this, function( subscriptionID, success, errCode ) {271 this.subUnsubSameSubjectTarget = subscriptionID;272 js3_1_4.do_setup.call(this, "_target");273 }, "_target");274}275js3_1.cbUnsubSame = function(subject, message, subscriberData) {276 if(message.step == "setup") { 277 js3_1_4.do_fire.call(this, subscriberData);278 } else if(message.step == "fire") {279 if(subscriberData == "_trigger") {280 this.hubClient.unsubscribe(this.subUnsubSameSubjectTarget, function( subscriptionID, success, errCode ) {281 js3_1_4.do_check.call(this, subscriberData); 282 }, this);283 }284 } else if(message.step == "check") { 285 js3_1_4.do_finish.call(this, subscriberData);286 } else {287 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 288 }289 return;290}291js3_1_4.do_setup = function(subscriberName) {292 js3_1_4.subscribe[subscriberName] = true;293 if (js3_1_4.subscribe["_trigger"] === true && js3_1_4.subscribe["_target"] === true) {294 this.hubClient.publish("unsub.same", { step: "setup" }); 295 }296}297js3_1_4.do_fire = function(data) {298 js3_1_4.setup[data] = true;299 if (js3_1_4.setup["_trigger"] === true && js3_1_4.setup["_target"] === true) {300 this.hubClient.publish("unsub.same", { step: "fire" });301 }302}303js3_1_4.do_check = function(data) {304 js3_1_4.fire[data] = true;305 if (js3_1_4.fire["_trigger"] === true) {306 this.hubClient.publish("unsub.same", { step: "check" });307 }308}309js3_1_4.do_finish = function(data) {310 js3_1_4.check[data] = true;311 if (js3_1_4.check["_trigger"] === true) {312 if (js3_1_4.setup["_trigger"] === true && js3_1_4.setup["_target"] === true &&313 js3_1_4.fire["_trigger"] === true && typeof js3_1_4.fire["_target"] === "undefined" &&314 js3_1_4.check["_trigger"] === true && typeof js3_1_4.check["_target"] === "undefined") {315 this.sendMsg( ["done"] );316 } else {317 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.4"] );318 }319 }320}321//////////////////////////////////////////////////////322js3_1_5.run = function(scriptnum) {323 js3_1_5.scriptnum = scriptnum;324 js3_1_5.subscribe = {};325 js3_1_5.setup = {};326 js3_1_5.fire = {};327 js3_1_5.check = {};328 // In callback for topic X, cancel a subscription to a different topic Y329 this.hubClient.subscribe("unsub.other.trigger", js3_1.cbUnsubOther, this, function( subscriptionID, success, errCode ) {330 js3_1_5.do_setup.call(this, "unsub.other.trigger");331 }, "_trigger");332 this.hubClient.subscribe("unsub.other.target", js3_1.cbUnsubOther, this, function( subscriptionID, success, errCode ) {333 this.subUnsubOtherTarget = subscriptionID;334 js3_1_5.do_setup.call(this, "unsub.other.target");335 }, "_target");336}337js3_1.cbUnsubOther = function(subject, message, subscriberData) {338 if(message.step == "setup") {339 js3_1_5.do_fire.call(this, subject);340 } else if(message.step == "fire") {341 this.hubClient.unsubscribe(this.subUnsubOtherTarget, function( subscriptionID, success, errCode ) {342 js3_1_5.do_check.call(this, subject); 343 }, this);344 } else if(message.step == "check") {345 js3_1_5.do_finish.call(this, subject);346 } else {347 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 348 }349 return;350}351js3_1_5.do_setup = function(subscriberName) {352 js3_1_5.subscribe[subscriberName] = true;353 if (js3_1_5.subscribe["unsub.other.trigger"] === true && js3_1_5.subscribe["unsub.other.target"] === true) {354 this.hubClient.publish("unsub.other.trigger", { step: "setup" }); 355 this.hubClient.publish("unsub.other.target", { step: "setup" });356 }357}358js3_1_5.do_fire = function(data) {359 js3_1_5.setup[data] = true;360 if (js3_1_5.setup["unsub.other.trigger"] === true && js3_1_5.setup["unsub.other.target"] === true) {361 this.hubClient.publish("unsub.other.trigger", { step: "fire" });362 }363}364js3_1_5.do_check = function(data) {365 js3_1_5.fire[data] = true;366 if (js3_1_5.fire["unsub.other.trigger"] === true) {367 this.hubClient.publish("unsub.other.trigger", { step: "check" });368 this.hubClient.publish("unsub.other.target", { step: "check" });369 }370}371js3_1_5.do_finish = function(data) {372 js3_1_5.check[data] = true;373 if (js3_1_5.check["unsub.other.trigger"] === true) {374 if (js3_1_5.setup["unsub.other.trigger"] === true && js3_1_5.setup["unsub.other.target"] === true &&375 js3_1_5.fire["unsub.other.trigger"] === true && typeof js3_1_5.fire["unsub.other.target"] === "undefined" &&376 js3_1_5.check["unsub.other.trigger"] === true && typeof js3_1_5.check["unsub.other.target"] === "undefined") {377 this.sendMsg( ["done"] );378 } else {379 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.5"] );380 }381 }382}383//////////////////////////////////////////////////////384js3_1_6.run = function(scriptnum) {385 this.scriptnum = scriptnum;386 js3_1_6.subscribe = {};387 js3_1_6.setup = {};388 js3_1_6.fire = {};389 js3_1_6.check = {};390 // In callback for topic X, cancel this same subscription 391 this.hubClient.subscribe("unsub.this", js3_1.cbUnsubThis, this, function( subscriptionID, success, errCode ) {392 this.subUnsubThis = subscriptionID;393 js3_1_6.do_setup.call(this, "unsub.this");394 }, "");395}396js3_1.cbUnsubThis = function(subject, message, subscriberData) {397 if(message.step == "setup") {398 js3_1_6.do_fire.call(this, subject);399 } else if(message.step == "fire") {400 this.hubClient.unsubscribe(this.subUnsubThis, function( subscriptionID, success, errCode ) {401 js3_1_6.do_check.call(this, subject); 402 }, this);403 } else if(message.step == "check") {404 this.sendMsg( ["error", "ERROR " + message.step + " should not happen, " ] ); 405 } else {406 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 407 }408 return;409}410js3_1_6.do_setup = function(subscriberName) {411 js3_1_6.subscribe[subscriberName] = true;412 if (js3_1_6.subscribe["unsub.this"] === true) {413 this.hubClient.publish("unsub.this", { step: "setup" }); 414 }415}416js3_1_6.do_fire = function(data) {417 js3_1_6.setup[data] = true;418 if (js3_1_6.setup["unsub.this"] === true) {419 this.hubClient.publish("unsub.this", { step: "fire" });420 }421}422js3_1_6.do_check = function(data) {423 js3_1_6.fire[data] = true;424 if (js3_1_6.fire["unsub.this"] === true) {425 this.hubClient.publish("unsub.this", { step: "check" });426 js3_1_6.do_finish.call(this, null);427 }428}429js3_1_6.do_finish = function(data) {430 if (js3_1_6.setup["unsub.this"] === true && 431 js3_1_6.fire["unsub.this"] === true && 432 typeof js3_1_6.check["unsub.this"] === "undefined") {433 this.sendMsg( ["done"] );434 } else {435 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.6"] );436 }437}438//////////////////////////////////////////////////////439js3_1_7.run = function(scriptnum) {440 this.scriptnum = scriptnum;441 js3_1_7.subscribe = {};442 js3_1_7.setup = {};443 js3_1_7.fire = {};444 js3_1_7.check = {};445 // In callback for topic X, subscribe to X and publish to X446 this.hubClient.subscribe("sub.pub.same", js3_1.cbSubPubSame, this, function( subscriptionID, success, errCode ) {447 js3_1_7.do_setup.call(this, "_trigger");448 }, "_trigger");449}450js3_1.cbSubPubSame = function(subject, message, subscriberData) {451 if(message.step == "setup") 452 js3_1_7.do_fire.call(this, subscriberData);453 else if(message.step == "fire") {454 this.hubClient.subscribe(subject, js3_1.cbSubPubSame, this, function( subscriptionID, success, errCode ) {455 js3_1_7.do_check.call(this, subscriberData); 456 }, "_target");457 } else if(message.step == "check1") {458 /* message received. should be received ONCE FOR _trigger & ONCE FOR _target. */ 459 js3_1_7.do_finish.call(this, message.step+subscriberData); 460 } else if(message.step == "check2") {461 /* message received. should be received ONCE FOR _trigger & ONCE FOR _target. */462 js3_1_7.do_finish.call(this, message.step+subscriberData); 463 } else464 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 465 return;466}467js3_1_7.do_setup = function(subscriberData) {468 js3_1_7.subscribe[subscriberData] = true;469 if (js3_1_7.subscribe["_trigger"] === true) {470 this.hubClient.publish("sub.pub.same", { step: "setup" }); 471 }472}473js3_1_7.do_fire = function(data) {474 js3_1_7.setup[data] = true;475 if (js3_1_7.setup["_trigger"] === true) {476 this.hubClient.publish("sub.pub.same", { step: "fire" });477 }478}479js3_1_7.do_check = function(data) {480 js3_1_7.fire[data] = true;481 if (js3_1_7.fire["_trigger"] === true) {482 this.hubClient.publish("sub.pub.same", { step: "check1" });483 this.hubClient.publish("sub.pub.same", { step: "check2" });484 }485}486js3_1_7.do_finish = function(data) {487 js3_1_7.check[data] = true;488 if (js3_1_7.check["check1_trigger"] === true && js3_1_7.check["check1_target"] === true && 489 js3_1_7.check["check2_trigger"] === true && js3_1_7.check["check2_target"] === true) {490 if (js3_1_7.setup["_trigger"] === true && typeof js3_1_7.setup["_target"] === "undefined" &&491 js3_1_7.fire["_trigger"] === true && typeof js3_1_7.fire["_target"] === "undefined" &&492 js3_1_7.check["check1_trigger"] === true && js3_1_7.check["check1_target"] === true && 493 js3_1_7.check["check2_trigger"] === true && js3_1_7.check["check2_target"] === true) {494 this.sendMsg( ["done"] );495 } else {496 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.7"] );497 }498 }499}500//////////////////////////////////////////////////////501js3_1_8.run = function(scriptnum) {502 js3_1_8.scriptnum = scriptnum;503 js3_1_8.subscribe = {};504 js3_1_8.setup = {};505 js3_1_8.fire = {};506 js3_1_8.check = {};507 this.hubClient.subscribe("sub.pub.other.trigger", js3_1.cbSubPubOther, this, function( subscriptionID, success, errCode ) {508 js3_1_8.do_setup.call(this, "sub.pub.other.trigger");509 }, "_trigger");510}511js3_1.cbSubPubOther = function(subject, message, subscriberData) {512 var pubSubject = "sub.pub.other.target";513 if(message.step == "setup") 514 js3_1_8.do_fire.call(this, subject);515 else if(message.step == "fire") {516 this.hubClient.subscribe(pubSubject, js3_1.cbSubPubOther, this, function( subscriptionID, success, errCode ) {517 js3_1_8.do_check.call(this, subject);518 }, "_target");519 } else if(message.step == "check1") {520 /* message received. should be received ONCE FOR _target ONLY. */ 521 js3_1_8.do_finish.call(this, message.step+subscriberData); 522 } else if(message.step == "check2") {523 /* message received. should be received ONCE FOR _target ONLY. */524 js3_1_8.do_finish.call(this, message.step+subscriberData); 525 } else526 this.sendMsg( ["error", "ERROR: invalid step " + message.step + ", " ] ); 527 return;528}529js3_1_8.do_setup = function(subscriberName) {530 js3_1_8.subscribe[subscriberName] = true;531 if (js3_1_8.subscribe["sub.pub.other.trigger"] === true) {532 this.hubClient.publish("sub.pub.other.trigger", { step: "setup" }); 533 this.hubClient.publish("sub.pub.other.target", { step: "setup" }); 534 }535}536js3_1_8.do_fire = function(data) {537 js3_1_8.setup[data] = true;538 if (js3_1_8.setup["sub.pub.other.trigger"] === true) {539 this.hubClient.publish("sub.pub.other.trigger", { step: "fire" });540 }541}542js3_1_8.do_check = function(subject) {543 js3_1_8.fire[subject] = true;544 if (js3_1_8.fire["sub.pub.other.trigger"] === true) {545 this.hubClient.publish("sub.pub.other.target", { step: "check1" });546 this.hubClient.publish("sub.pub.other.trigger", { step: "check2" });547 this.hubClient.publish("sub.pub.other.target", { step: "check2" });548 }549}550js3_1_8.do_finish = function(data) {551 js3_1_8.check[data] = true;552 if (js3_1_8.check["check1_target"] === true && 553 js3_1_8.check["check2_trigger"] === true && js3_1_8.check["check2_target"] === true) {554 if (js3_1_8.setup["sub.pub.other.trigger"] === true && typeof js3_1_8.setup["sub.pub.other.target"] === "undefined" &&555 js3_1_8.fire["sub.pub.other.trigger"] === true && typeof js3_1_8.fire["sub.pub.other.target"] === "undefined" &&556 typeof js3_1_8.check["check1_trigger"] === "undefined" && js3_1_8.check["check1_target"] === true && 557 js3_1_8.check["check2_trigger"] === true && js3_1_8.check["check2_target"] === true) {558 this.sendMsg( ["done"] );559 } else {560 this.sendMsg( ["error", "Incorrect final results for pubsub 3_1.8"] );561 }562 }...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1'use strict';2const MongoBench = require('../mongoBench');3const Runner = MongoBench.Runner;4const commonHelpers = require('./common');5let BSON = require('bson');6try {7 BSON = require('bson-ext');8} catch (_) {9 // do not care10}11const { EJSON } = require('bson');12const makeClient = commonHelpers.makeClient;13const connectClient = commonHelpers.connectClient;14const disconnectClient = commonHelpers.disconnectClient;15const initDb = commonHelpers.initDb;16const dropDb = commonHelpers.dropDb;17const createCollection = commonHelpers.createCollection;18const initCollection = commonHelpers.initCollection;19const dropCollection = commonHelpers.dropCollection;20const makeLoadJSON = commonHelpers.makeLoadJSON;21const loadSpecString = commonHelpers.loadSpecString;22const loadSpecFile = commonHelpers.loadSpecFile;23const initBucket = commonHelpers.initBucket;24const dropBucket = commonHelpers.dropBucket;25function average(arr) {26 return arr.reduce((x, y) => x + y, 0) / arr.length;27}28function encodeBSON() {29 for (let i = 0; i < 10000; i += 1) {30 BSON.serialize(this.dataString);31 }32}33function decodeBSON() {34 for (let i = 0; i < 10000; i += 1) {35 BSON.deserialize(this.data);36 }37}38function makeBSONLoader(fileName) {39 return function () {40 this.dataString = EJSON.parse(loadSpecString(['extended_bson', `${fileName}.json`]));41 this.data = BSON.serialize(this.dataString);42 };43}44function loadGridFs() {45 this.bin = loadSpecFile(['single_and_multi_document', 'gridfs_large.bin']);46}47function makeTestInsertOne(numberOfOps) {48 return function (done) {49 const loop = _id => {50 if (_id > numberOfOps) {51 return done();52 }53 const doc = Object.assign({}, this.doc);54 this.collection.insertOne(doc, err => (err ? done(err) : loop(_id + 1)));55 };56 loop(1);57 };58}59function makeLoadTweets(makeId) {60 return function () {61 const doc = this.doc;62 const tweets = [];63 for (let _id = 1; _id <= 10000; _id += 1) {64 tweets.push(Object.assign({}, doc, makeId ? { _id } : {}));65 }66 return this.collection.insertMany(tweets);67 };68}69function makeLoadInsertDocs(numberOfOperations) {70 return function () {71 this.docs = [];72 for (let i = 0; i < numberOfOperations; i += 1) {73 this.docs.push(Object.assign({}, this.doc));74 }75 };76}77function findOneById(done) {78 const loop = _id => {79 if (_id > 10000) {80 return done();81 }82 return this.collection.findOne({ _id }, err => (err ? done(err) : loop(_id + 1)));83 };84 return loop(1);85}86function runCommand(done) {87 const loop = _id => {88 if (_id > 10000) {89 return done();90 }91 return this.db.command({ ismaster: true }, err => (err ? done(err) : loop(_id + 1)));92 };93 return loop(1);94}95function findManyAndEmptyCursor(done) {96 return this.collection.find({}).forEach(() => {}, done);97}98function docBulkInsert(done) {99 return this.collection.insertMany(this.docs, { ordered: true }, done);100}101function gridFsInitUploadStream() {102 this.stream = this.bucket.openUploadStream('gridfstest');103}104function writeSingleByteToUploadStream() {105 return new Promise((resolve, reject) => {106 this.stream.write('\0', null, err => (err ? reject(err) : resolve()));107 });108}109const benchmarkRunner = new Runner()110 .suite('bsonBench', suite =>111 suite112 .benchmark('flatBsonEncoding', benchmark =>113 benchmark.taskSize(75.31).setup(makeBSONLoader('flat_bson')).task(encodeBSON)114 )115 .benchmark('flatBsonDecoding', benchmark =>116 benchmark.taskSize(75.31).setup(makeBSONLoader('flat_bson')).task(decodeBSON)117 )118 .benchmark('deepBsonEncoding', benchmark =>119 benchmark.taskSize(19.64).setup(makeBSONLoader('deep_bson')).task(encodeBSON)120 )121 .benchmark('deepBsonDecoding', benchmark =>122 benchmark.taskSize(19.64).setup(makeBSONLoader('deep_bson')).task(decodeBSON)123 )124 .benchmark('fullBsonEncoding', benchmark =>125 benchmark.taskSize(57.34).setup(makeBSONLoader('full_bson')).task(encodeBSON)126 )127 .benchmark('fullBsonDecoding', benchmark =>128 benchmark.taskSize(57.34).setup(makeBSONLoader('full_bson')).task(decodeBSON)129 )130 )131 .suite('singleBench', suite =>132 suite133 .benchmark('runCommand', benchmark =>134 benchmark135 .taskSize(0.16)136 .setup(makeClient)137 .setup(connectClient)138 .setup(initDb)139 .task(runCommand)140 .teardown(disconnectClient)141 )142 .benchmark('findOne', benchmark =>143 benchmark144 .taskSize(16.22)145 .setup(makeLoadJSON('tweet.json'))146 .setup(makeClient)147 .setup(connectClient)148 .setup(initDb)149 .setup(dropDb)150 .setup(initCollection)151 .setup(makeLoadTweets(true))152 .task(findOneById)153 .teardown(dropDb)154 .teardown(disconnectClient)155 )156 .benchmark('smallDocInsertOne', benchmark =>157 benchmark158 .taskSize(2.75)159 .setup(makeLoadJSON('small_doc.json'))160 .setup(makeClient)161 .setup(connectClient)162 .setup(initDb)163 .setup(dropDb)164 .setup(initDb)165 .setup(initCollection)166 .setup(createCollection)167 .beforeTask(dropCollection)168 .beforeTask(createCollection)169 .beforeTask(initCollection)170 .task(makeTestInsertOne(10000))171 .teardown(dropDb)172 .teardown(disconnectClient)173 )174 .benchmark('largeDocInsertOne', benchmark =>175 benchmark176 .taskSize(27.31)177 .setup(makeLoadJSON('large_doc.json'))178 .setup(makeClient)179 .setup(connectClient)180 .setup(initDb)181 .setup(dropDb)182 .setup(initDb)183 .setup(initCollection)184 .setup(createCollection)185 .beforeTask(dropCollection)186 .beforeTask(createCollection)187 .beforeTask(initCollection)188 .task(makeTestInsertOne(10))189 .teardown(dropDb)190 .teardown(disconnectClient)191 )192 )193 .suite('multiBench', suite =>194 suite195 .benchmark('findManyAndEmptyCursor', benchmark =>196 benchmark197 .taskSize(16.22)198 .setup(makeLoadJSON('tweet.json'))199 .setup(makeClient)200 .setup(connectClient)201 .setup(initDb)202 .setup(dropDb)203 .setup(initCollection)204 .setup(makeLoadTweets(false))205 .task(findManyAndEmptyCursor)206 .teardown(dropDb)207 .teardown(disconnectClient)208 )209 .benchmark('smallDocBulkInsert', benchmark =>210 benchmark211 .taskSize(2.75)212 .setup(makeLoadJSON('small_doc.json'))213 .setup(makeLoadInsertDocs(10000))214 .setup(makeClient)215 .setup(connectClient)216 .setup(initDb)217 .setup(dropDb)218 .setup(initDb)219 .setup(initCollection)220 .setup(createCollection)221 .beforeTask(dropCollection)222 .beforeTask(createCollection)223 .beforeTask(initCollection)224 .task(docBulkInsert)225 .teardown(dropDb)226 .teardown(disconnectClient)227 )228 .benchmark('largeDocBulkInsert', benchmark =>229 benchmark230 .taskSize(27.31)231 .setup(makeLoadJSON('large_doc.json'))232 .setup(makeLoadInsertDocs(10))233 .setup(makeClient)234 .setup(connectClient)235 .setup(initDb)236 .setup(dropDb)237 .setup(initDb)238 .setup(initCollection)239 .setup(createCollection)240 .beforeTask(dropCollection)241 .beforeTask(createCollection)242 .beforeTask(initCollection)243 .task(docBulkInsert)244 .teardown(dropDb)245 .teardown(disconnectClient)246 )247 .benchmark('gridFsUpload', benchmark =>248 benchmark249 .taskSize(52.43)250 .setup(loadGridFs)251 .setup(makeClient)252 .setup(connectClient)253 .setup(initDb)254 .setup(dropDb)255 .setup(initDb)256 .setup(initCollection)257 .beforeTask(dropBucket)258 .beforeTask(initBucket)259 .beforeTask(gridFsInitUploadStream)260 .beforeTask(writeSingleByteToUploadStream)261 .task(function (done) {262 this.stream.on('error', done).end(this.bin, null, () => done());263 })264 .teardown(dropDb)265 .teardown(disconnectClient)266 )267 .benchmark('gridFsDownload', benchmark =>268 benchmark269 .taskSize(52.43)270 .setup(loadGridFs)271 .setup(makeClient)272 .setup(connectClient)273 .setup(initDb)274 .setup(dropDb)275 .setup(initDb)276 .setup(initCollection)277 .setup(dropBucket)278 .setup(initBucket)279 .setup(gridFsInitUploadStream)280 .setup(function () {281 return new Promise((resolve, reject) => {282 this.stream.end(this.bin, null, err => {283 if (err) {284 return reject(err);285 }286 this.id = this.stream.id;287 this.stream = undefined;288 resolve();289 });290 });291 })292 .task(function (done) {293 this.bucket.openDownloadStream(this.id).resume().on('end', done);294 })295 .teardown(dropDb)296 .teardown(disconnectClient)297 )298 );299benchmarkRunner300 .run()301 .then(microBench => {302 const bsonBench = average(Object.values(microBench.bsonBench));303 const singleBench = average([304 microBench.singleBench.findOne,305 microBench.singleBench.smallDocInsertOne,306 microBench.singleBench.largeDocInsertOne307 ]);308 const multiBench = average(Object.values(microBench.multiBench));309 // TODO: add parallelBench310 const parallelBench = NaN;311 const readBench = average([312 microBench.singleBench.findOne,313 microBench.multiBench.findManyAndEmptyCursor,314 microBench.multiBench.gridFsDownload315 // TODO: Add parallelBench read benchmarks316 ]);317 const writeBench = average([318 microBench.singleBench.smallDocInsertOne,319 microBench.singleBench.largeDocInsertOne,320 microBench.multiBench.smallDocBulkInsert,321 microBench.multiBench.largeDocBulkInsert,322 microBench.multiBench.gridFsUpload323 // TODO: Add parallelBench write benchmarks324 ]);325 const driverBench = average([readBench, writeBench]);326 return {327 microBench,328 bsonBench,329 singleBench,330 multiBench,331 parallelBench,332 readBench,333 writeBench,334 driverBench335 };336 })337 .then(data => {338 data.bsonType = BSON.serialize.toString().includes('native code') ? 'bson-ext' : 'js-bson';339 console.log(data);340 })...

Full Screen

Full Screen

testFloat32-correctness.js

Source:testFloat32-correctness.js Github

copy

Full Screen

1setJitCompilerOption("ion.warmup.trigger", 50);2var f32 = new Float32Array(10);3function test(setup, f) {4 if (f === undefined) {5 f = setup;6 setup = function(){};7 }8 setup();9 for(var n = 200; n; --n) {10 f();11 }12}13// Basic arithmetic14function setupBasicArith() {15 f32[0] = -Infinity;16 f32[1] = -1;17 f32[2] = -0;18 f32[3] = 0;19 f32[4] = 1.337;20 f32[5] = 42;21 f32[6] = Infinity;22 f32[7] = NaN;23}24function basicArith() {25 for (var i = 0; i < 7; ++i) {26 var opf = Math.fround(f32[i] + f32[i+1]);27 var opd = (1 / (1 / f32[i])) + f32[i+1];28 assertFloat32(opf, true);29 assertFloat32(opd, false);30 assertEq(opf, Math.fround(opd));31 opf = Math.fround(f32[i] - f32[i+1]);32 opd = (1 / (1 / f32[i])) - f32[i+1];33 assertFloat32(opf, true);34 assertFloat32(opd, false);35 assertEq(opf, Math.fround(opd));36 opf = Math.fround(f32[i] * f32[i+1]);37 opd = (1 / (1 / f32[i])) * f32[i+1];38 assertFloat32(opf, true);39 assertFloat32(opd, false);40 assertEq(opf, Math.fround(opd));41 opf = Math.fround(f32[i] / f32[i+1]);42 opd = (1 / (1 / f32[i])) / f32[i+1];43 assertFloat32(opf, true);44 assertFloat32(opd, false);45 assertEq(opf, Math.fround(opd));46 }47}48test(setupBasicArith, basicArith);49// MAbs50function setupAbs() {51 f32[0] = -0;52 f32[1] = 0;53 f32[2] = -3.14159;54 f32[3] = 3.14159;55 f32[4] = -Infinity;56 f32[5] = Infinity;57 f32[6] = NaN;58}59function abs() {60 for(var i = 0; i < 7; ++i) {61 assertEq( Math.fround(Math.abs(f32[i])), Math.abs(f32[i]) );62 }63}64test(setupAbs, abs);65// MSqrt66function setupSqrt() {67 f32[0] = 0;68 f32[1] = 1;69 f32[2] = 4;70 f32[3] = -1;71 f32[4] = Infinity;72 f32[5] = NaN;73 f32[6] = 13.37;74}75function sqrt() {76 for(var i = 0; i < 7; ++i) {77 var sqrtf = Math.fround(Math.sqrt(f32[i]));78 var sqrtd = 1 + Math.sqrt(f32[i]) - 1; // force no float32 by chaining arith ops79 assertEq( sqrtf, Math.fround(sqrtd) );80 }81}82test(setupSqrt, sqrt);83// MMinMax84function setupMinMax() {85 f32[0] = -0;86 f32[1] = 0;87 f32[2] = 1;88 f32[3] = 4;89 f32[4] = -1;90 f32[5] = Infinity;91 f32[6] = NaN;92 f32[7] = 13.37;93 f32[8] = -Infinity;94 f32[9] = Math.pow(2,31) - 1;95}96function minMax() {97 for(var i = 0; i < 9; ++i) {98 for(var j = 0; j < 9; j++) {99 var minf = Math.fround(Math.min(f32[i], f32[j]));100 var mind = 1 / (1 / Math.min(f32[i], f32[j])); // force no float32 by chaining arith ops101 assertFloat32(minf, true);102 assertFloat32(mind, false);103 assertEq( minf, Math.fround(mind) );104 var maxf = Math.fround(Math.max(f32[i], f32[j]));105 var maxd = 1 / (1 / Math.max(f32[i], f32[j])); // force no float32 by chaining arith ops106 assertFloat32(maxf, true);107 assertFloat32(maxd, false);108 assertEq( maxf, Math.fround(maxd) );109 }110 }111}112test(setupMinMax, minMax);113// MTruncateToInt32114// The only way to get a MTruncateToInt32 with a Float32 input is to use Math.imul115function setupTruncateToInt32() {116 f32[0] = -1;117 f32[1] = 4;118 f32[2] = 5.13;119}120function truncateToInt32() {121 assertEq( Math.imul(f32[0], f32[1]), Math.imul(-1, 4) );122 assertEq( Math.imul(f32[1], f32[2]), Math.imul(4, 5) );123}124test(setupTruncateToInt32, truncateToInt32);125// MCompare126function comp() {127 for(var i = 0; i < 9; ++i) {128 assertEq( f32[i] < f32[i+1], true );129 }130}131function setupComp() {132 f32[0] = -Infinity;133 f32[1] = -1;134 f32[2] = -0.01;135 f32[3] = 0;136 f32[4] = 0.01;137 f32[5] = 1;138 f32[6] = 10;139 f32[7] = 13.37;140 f32[8] = 42;141 f32[9] = Infinity;142}143test(setupComp, comp);144// MNot145function setupNot() {146 f32[0] = -0;147 f32[1] = 0;148 f32[2] = 1;149 f32[3] = NaN;150 f32[4] = Infinity;151 f32[5] = 42;152 f32[6] = -23;153}154function not() {155 assertEq( !f32[0], true );156 assertEq( !f32[1], true );157 assertEq( !f32[2], false );158 assertEq( !f32[3], true );159 assertEq( !f32[4], false );160 assertEq( !f32[5], false );161 assertEq( !f32[6], false );162}163test(setupNot, not);164// MToInt32165var str = "can haz cheezburger? okthxbye;";166function setupToInt32() {167 f32[0] = 0;168 f32[1] = 1;169 f32[2] = 2;170 f32[3] = 4;171 f32[4] = 5;172}173function testToInt32() {174 assertEq(str[f32[0]], 'c');175 assertEq(str[f32[1]], 'a');176 assertEq(str[f32[2]], 'n');177 assertEq(str[f32[3]], 'h');178 assertEq(str[f32[4]], 'a');179}180test(setupToInt32, testToInt32);181function setupBailoutToInt32() {182 f32[0] = .5;183}184function testBailoutToInt32() {185 assertEq(typeof str[f32[0]], 'undefined');186}187test(setupBailoutToInt32, testBailoutToInt32);188// MMath (no trigo - see also testFloat32-trigo.js189function assertNear(a, b) {190 var r = (a != a && b != b) || Math.abs(a-b) < 1e-1 || a === b;191 if (!r) {192 print('Precision error: ');193 print(new Error().stack);194 print('Got', a, ', expected near', b);195 assertEq(false, true);196 }197}198function setupOtherMath() {199 setupComp();200 f32[8] = 4.2;201}202function otherMath() {203 for (var i = 0; i < 9; ++i) {204 assertNear(Math.fround(Math.exp(f32[i])), Math.exp(f32[i]));205 assertNear(Math.fround(Math.log(f32[i])), Math.log(f32[i]));206 }207};208test(setupOtherMath, otherMath);209function setupFloor() {210 f32[0] = -5.5;211 f32[1] = -0.5;212 f32[2] = 0;213 f32[3] = 1.5;214}215function setupFloorDouble() {216 f32[4] = NaN;217 f32[5] = -0;218 f32[6] = Infinity;219 f32[7] = -Infinity;220 f32[8] = Math.pow(2,31); // too big to fit into a int221}222function testFloor() {223 for (var i = 0; i < 4; ++i) {224 var f = Math.floor(f32[i]);225 assertFloat32(f, false); // f is an int32226 var g = Math.floor(-0 + f32[i]);227 assertFloat32(g, false);228 assertEq(f, g);229 }230}231function testFloorDouble() {232 for (var i = 4; i < 9; ++i) {233 var f = Math.fround(Math.floor(f32[i]));234 assertFloat32(f, true);235 var g = Math.floor(-0 + f32[i]);236 assertFloat32(g, false);237 assertEq(f, g);238 }239}240test(setupFloor, testFloor);241test(setupFloorDouble, testFloorDouble);242function setupRound() {243 f32[0] = -5.5;244 f32[1] = -0.6;245 f32[2] = 1.5;246 f32[3] = 1;247}248function setupRoundDouble() {249 f32[4] = NaN;250 f32[5] = -0.49; // rounded to -0251 f32[6] = Infinity;252 f32[7] = -Infinity;253 f32[8] = Math.pow(2,31); // too big to fit into a int254 f32[9] = -0;255}256function testRound() {257 for (var i = 0; i < 4; ++i) {258 var r32 = Math.round(f32[i]);259 assertFloat32(r32, false); // r32 is an int32260 var r64 = Math.round(-0 + f32[i]);261 assertFloat32(r64, false);262 assertEq(r32, r64);263 }264}265function testRoundDouble() {266 for (var i = 4; i < 10; ++i) {267 var r32 = Math.fround(Math.round(f32[i]));268 assertFloat32(r32, true);269 var r64 = Math.round(-0 + f32[i]);270 assertFloat32(r64, false);271 assertEq(r32, r64);272 }273}274test(setupRound, testRound);275test(setupRoundDouble, testRoundDouble);276function setupCeil() {277 f32[0] = -5.5;278 f32[1] = -1.5;279 f32[2] = 0;280 f32[3] = 1.5;281}282function setupCeilDouble() {283 f32[4] = NaN;284 f32[5] = -0;285 f32[6] = Infinity;286 f32[7] = -Infinity;287 f32[8] = Math.pow(2,31); // too big to fit into a int288}289function testCeil() {290 for(var i = 0; i < 2; ++i) {291 var f = Math.ceil(f32[i]);292 assertFloat32(f, false);293 var g = Math.ceil(-0 + f32[i]);294 assertFloat32(g, false);295 assertEq(f, g);296 }297}298function testCeilDouble() {299 for(var i = 4; i < 9; ++i) {300 var f = Math.fround(Math.ceil(f32[i]));301 assertFloat32(f, true);302 var g = Math.ceil(-0 + f32[i]);303 assertFloat32(g, false);304 assertEq(f, g);305 }306}307test(setupCeil, testCeil);...

Full Screen

Full Screen

PairDevice.js

Source:PairDevice.js Github

copy

Full Screen

1/**2 * comma SetupEonPairing Screen3 */4import React, {useState, useEffect} from 'react';5import {View, Linking, StyleSheet, Text, Button} from 'react-native';6import {useNavigation} from '@react-navigation/native';7import Permissions from 'react-native-permissions';8import QRCodeScanner from 'react-native-qrcode-scanner';9import X from '../../theme';10import BasePage from '../Util/BasePage';11// import WideButton from '../../components/Util/WideButton';12// import {Alert, Spinner} from '../../components';13import {14 pilotPair,15 fetchDevices,16 fetchDevice,17 fetchDeviceSubscription,18} from '../../actions/Devices';19import gStyles from '../../constants/styles';20export default SetupEonPairing = () => {21 const [wantsCameraPermissions, setWantsCameraPermissions] = useState(false);22 const [hasCameraPermissions, setHasCameraPermissions] = useState(false);23 const [attemptingPair, setAttemptingPair] = useState(false);24 const navigation = useNavigation();25 useEffect(() => {26 Permissions.check('camera').then((response) => {27 if (response == 'authorized') {28 setHasCameraPermissions(true);29 }30 });31 }, []);32 const pairDevice = (imei, serial, pairToken) => {33 return pilotPair(imei, serial, pairToken)34 .then((dongleId) => {35 // dispatch(fetchDevices());36 return Promise.all([37 fetchDevice(dongleId),38 fetchDeviceSubscription(dongleId),39 ]);40 })41 .then(([device, deviceSubscription]) => {42 if (deviceSubscription && deviceSubscription.trial_claimable) {43 navigation.navigate('PrimeSignup', {dongleId: device.dongle_id});44 } else {45 navigation.navigate('AppDrawer');46 }47 });48 };49 const handleConfirmPressed = () => {50 setWantsCameraPermissions(true);51 };52 const handleDismissPressed = () => {53 navigation.navigate('Home');54 };55 const handleViewSetupGuidePressed = () => {56 Linking.openURL('https://comma.ai/setup');57 };58 const handleScannedQRCode = (e) => {59 setAttemptingPair(true);60 let imei, serial, pairToken;61 let qrDataSplit = e.data.split('--');62 if (qrDataSplit.length === 2) {63 imei = qrDataSplit[0];64 serial = qrDataSplit[1];65 } else if (qrDataSplit.length >= 3) {66 imei = qrDataSplit[0];67 serial = qrDataSplit[1];68 pairToken = qrDataSplit.slice(2).join('--');69 }70 if (imei === undefined || serial === undefined) {71 setAttemptingPair(false);72 }73 pairDevice(imei, serial, pairToken).catch((err) => {74 setAttemptingPair(false);75 console.log(err);76 });77 };78 if (attemptingPair) {79 return (80 <View style={styles.setupEonPairingContainer}>81 <Text style={{color: '#fff', fontSize: 20}}>Spinner</Text>82 {/* <Spinner spinnerMessage="Pairing Device..." /> */}83 </View>84 );85 // } else if (wantsCameraPermissions || hasCameraPermissions) {86 } else {87 return (88 <BasePage title="Pair Your Device">89 <View style={styles.setupEonPairingContainer}>90 <X.Entrance style={styles.setupEonPairingCamera}>91 <QRCodeScanner92 onRead={handleScannedQRCode}93 topContent={null}94 bottomContent={null}95 cameraProps={{captureAudio: false}}96 />97 </X.Entrance>98 <View style={styles.setupEonPairingInstruction}>99 <X.Text style={styles.setupEonPairingInstructionText}>100 Place the QR code from your device during setup within the frame.101 </X.Text>102 <Button103 onPress={handleViewSetupGuidePressed}104 title="View Setup Guide"105 color="#fff"></Button>106 </View>107 </View>108 </BasePage>109 );110 // } else {111 // return (112 // <BasePage>113 // <View style={styles.setupEonPairingContainer}>114 // <X.Entrance style={{height: '100%'}}>115 // <Text style={{color:'#fff', fontSize: 20}}>Alert</Text>116 {117 /* <Alert118 title="Camera Access"119 message="We need camera access so you can finish setting up your device"120 dismissButtonAction={handleDismissPressed}121 confirmButtonAction={handleConfirmPressed}122 dismissButtonTitle="Not now"123 confirmButtonTitle="Yes!"124 /> */125 }126 // </X.Entrance>127 // </View>128 // </BasePage>129 // );130 }131};132const styles = StyleSheet.create({133 setupDevicesContainer: {134 backgroundColor: '#080808',135 height: '100%',136 width: '100%',137 },138 setupDevicesHeader: {139 alignItems: 'center',140 paddingLeft: 30,141 paddingRight: 30,142 },143 setupDevicesOptions: {144 marginTop: '10%',145 },146 setupDeviceOptionEON: {147 backgroundColor: 'rgba(255,255,255,.1)',148 borderRadius: 8,149 height: 240,150 marginBottom: '10%',151 alignItems: 'center',152 justifyContent: 'center',153 width: '100%',154 },155 setupDeviceOptionEONImage: {156 maxHeight: 120,157 marginBottom: 20,158 width: '80%',159 },160 setupDeviceOptionPanda: {161 justifyContent: 'center',162 backgroundColor: 'rgba(255,255,255,.1)',163 borderRadius: 8,164 flexDirection: 'row',165 height: 160,166 width: '100%',167 },168 setupDeviceOptionPandaImage: {169 maxWidth: 100,170 },171 setupDeviceOptionPandaText: {172 alignSelf: 'center',173 paddingLeft: '8%',174 },175 setupDeviceOptionShopText: {176 textAlign: 'center',177 },178 setupDeviceContainer: {179 width: '100%',180 },181 setupDeviceHeader: {182 alignItems: 'center',183 height: 50,184 },185 setupDeviceBody: {186 paddingLeft: '3%',187 paddingRight: '3%',188 },189 setupDeviceBodyCentered: {190 height: '90%',191 alignItems: 'center',192 justifyContent: 'center',193 paddingBottom: '20%',194 },195 setupDeviceIntroBodyItem: {196 marginTop: '10%',197 },198 setupDeviceIntroBodyItemHeader: {199 marginBottom: '3.5%',200 },201 setupEonPairingContainer: {202 height: '100%',203 width: '100%',204 },205 setupEonPairingCamera: {206 backgroundColor: 'rgba(255,255,255,.02)',207 height: '50%',208 },209 setupEonPairingInstruction: {210 alignItems: 'center',211 height: '30%',212 justifyContent: 'center',213 padding: '15%',214 paddingBottom: '5%',215 paddingTop: 0,216 fontSize: 30,217 },218 setupEonPairingInstructionHdr: {219 textAlign: 'center',220 color: '#fff',221 fontSize: 30,222 fontWeight: '700',223 },224 setupEonPairingInstructionText: {225 marginTop: '6%',226 marginBottom: '12%',227 textAlign: 'center',228 color: '#aaa',229 fontSize: gStyles.text.small,230 },231 setupEonPairingInstructionButton: {232 backgroundColor: '#fff',233 borderRadius: 30,234 height: 60,235 width: 60,236 },237 setupDeviceInstallPrepContainer: {238 height: '100%',239 width: '100%',240 },241 setupDeviceInstallPrepHeader: {},242 setupDeviceInstallPrepBody: {243 justifyContent: 'center',244 flex: 1,245 },246 setupDeviceInstallSteps: {247 borderTopColor: 'rgba(255,255,255,.2)',248 borderTopWidth: 1,249 paddingTop: 20,250 },251 setupDeviceInstallStep: {252 flexDirection: 'row',253 paddingTop: 20,254 paddingBottom: 20,255 },256 setupDeviceInstallStepNumber: {257 alignItems: 'center',258 backgroundColor: '#fff',259 borderRadius: 15,260 height: 26,261 justifyContent: 'center',262 width: 26,263 },264 setupDeviceInstallStepCopy: {265 paddingLeft: 15,266 paddingRight: 20,267 },268 setupDeviceInstallVideo: {269 backgroundColor: '#fff',270 borderColor: '#fff',271 borderRadius: 8,272 borderWidth: 10,273 marginTop: 10,274 marginBottom: 30,275 height: 200,276 width: '100%',277 alignSelf: 'center',278 },279 setupDeviceInstallVideoCover: {280 borderRadius: 8,281 height: 148,282 },283 setupDeviceInstallVideoButton: {284 alignItems: 'center',285 backgroundColor: '#fff',286 justifyContent: 'center',287 height: 40,288 paddingTop: 10,289 },...

Full Screen

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 robotframework-appiumlibrary automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful