How to use keys method in stryker-parent

Best JavaScript code snippet using stryker-parent

keycapture_js_spec.js

Source:keycapture_js_spec.js Github

copy

Full Screen

1/**2 * @author: Steve Sutton, Ben Kennedy3 */4describe("KeyCapture JS API", function()5{6 beforeEach(function()7 {8 hardwareKeysTest.callbackFired = false;9 hardwareKeysTest.callbackFiredResult = null;10 hardwareKeysTest.callbackFiredTimeout = null;11 //getpropertiesdata = '';12 });13 14 describe("Setup", function()15 {16 it("0.1.focuses the RhoElements Window", function()17 {18 Rho.Instrumentation.simulate_touch_event(0, 5, 41);19 Rho.Instrumentation.simulate_touch_event(2, 5, 41);20 });21 });22 if (!isWindowsMobilePlatform) //putting check for WM because of issues in instumentation API for WM23 {24 if(!hardwareKeysTest.isAndroid())//Android doesnt do home key it seems25 {26 describe("HomeKey", function()27 {28 ///////////////////////////////////////////////////////////////////////29 // 1. Home key30 ///////////////////////////////////////////////////////////////////////31 it("1.1.should check default value of the Home Key", function()32 {33 expect(Rho.KeyCapture.homeKeyValue).toBe('disabled'); 34 });35 it("1.2.should set the Home Key to ENTER", function()36 {37 Rho.KeyCapture.homeKeyValue = hardwareKeysTest.enterKey.string; 38 expect(Rho.KeyCapture.homeKeyValue).toBe('' + hardwareKeysTest.enterKey.value); // ENTER 39 });40 it("1.3.should set the Home Key to disabled", function()41 {42 Rho.KeyCapture.homeKeyValue = 'disabled';43 expect(Rho.KeyCapture.homeKeyValue).toBe('disabled'); 44 });45 it("1.4.should set the Home Key to disable", function()46 {47 Rho.KeyCapture.homeKeyValue = 'disable';48 expect(Rho.KeyCapture.homeKeyValue).toBe('disabled'); 49 });50 51 it("1.5.should set the Home Key to enabled", function()52 {53 Rho.KeyCapture.homeKeyValue = 'enabled'; 54 expect(Rho.KeyCapture.homeKeyValue).toBe('' + hardwareKeysTest.f5Key.value); // F5 55 });56 57 it("1.6.should set the Home Key to enable", function()58 {59 Rho.KeyCapture.homeKeyValue = 'enable';60 expect(Rho.KeyCapture.homeKeyValue).toBe('' + hardwareKeysTest.f5Key.value); // F5 61 });62 63 //Added By ST//64 /* KeyCapture does not supported PROPERTY_BAG65 it("1.7.(VT289-049)set the Home Key to ENTER with setProperties", function()66 {67 Rho.KeyCapture.setProperties({'homeKeyValue':hardwareKeysTest.enterKey.string})68 Rho.KeyCapture.getProperties(['homeKeyValue'],function(data){getpropertiesdata = JSON.stringify(data);});69 expect(getpropertiesdata).toContain('13');70 });71 it("1.8.(VT289-050)set the Home Key to disabled with setProperty", function()72 {73 Rho.KeyCapture.setProperty('homeKeyValue','Disabled');74 Rho.KeyCapture.getProperty("homeKeyValue",function(data){getpropertiesdata = data;});75 expect(getpropertiesdata).toBe('Disabled'); 76 });*/77 78 it("1.9.(VT289-051)set the Home Key to enabled with setProperty and without callback", function()79 {80 Rho.KeyCapture.homeKeyValue = 'enabled'81 expect(Rho.KeyCapture.homeKeyValue).toBe('' + hardwareKeysTest.f5Key.value); // F5 82 });83 84 /* KeyCapture does not support PROPERTY_BAG85 it("1.10.(VT289-052)check for getallproperties", function() {86 Rho.KeyCapture.homeKeyValue = 'disabled';87 Rho.KeyCapture.getAllProperties(function(data){getpropertiesdata = JSON.stringify(data);});88 expect(getpropertiesdata).toContain('disabled');89 });90 it("1.11.(VT289-053)check for getSupportedProperties", function() {91 Rho.KeyCapture.homeKeyValue = hardwareKeysTest.enterKey.string;92 Rho.KeyCapture.getSupportedProperties(function(data){getpropertiesdata = JSON.stringify(data);});93 expect(getpropertiesdata).toContain('13');94 });*/95 });96 }97 }98 if (!isWindowsMobilePlatform) //putting check for WM because of issues in instumentation API for WM99 { 100 describe("captureKey", function()101 {102 ///////////////////////////////////////////////////////////////////////103 // 2. Key capture104 ///////////////////////////////////////////////////////////////////////105 106 it("2.1.should capture ENTER key when specified with HEX", function()107 {108 runs(function()109 {110 hardwareKeysTest.captureKey(true, hardwareKeysTest.enterKey.string); // ENTER111 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.enterKey.value); // ENTER112 }, "set capture key to ENTER & simulate ENTER key press..."); 113 114 waitsFor(function()115 {116 return hardwareKeysTest.callbackFiredResult == hardwareKeysTest.enterKey.value;117 }, "ERROR: Failed to capture ENTER key", 3000);118 119 runs(function()120 {121 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.enterKey.string);122 });123 });124 125 it("2.2.should ignore any other key than ENTER", function()126 {127 runs(function()128 {129 hardwareKeysTest.captureKey(true,hardwareKeysTest.enterKey.string); // ENTER130 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.tabKey.value);131 setTimeout(function(){hardwareKeysTest.callbackFiredResult = 'timedout'},1000);// TAB132 }, "set capture key to ENTER & simulate TAB key press..."); 133 134 waitsFor(function()135 {136 return hardwareKeysTest.callbackFiredResult == 'timedout';137 }, "ERROR: Test setup failed, timeout not occurring", 3000);138 139 runs(function()140 {141 expect(hardwareKeysTest.callbackFired).toBe(false);142 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.enterKey.string);143 }, 'expect the callback not to fire');144 });145 146 it("2.3.should capture any key using a lowercase 'all'", function()147 {148 runs(function()149 {150 hardwareKeysTest.captureKey(true,'all'); // Any Key151 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.tabKey.value); // TAB152 }, "set capture key to any key & simulate TAB key press..."); 153 154 waitsFor(function()155 {156 return hardwareKeysTest.callbackFiredResult == hardwareKeysTest.tabKey.value;157 }, "ERROR: Failed to capture any key", 3000);158 159 runs(function()160 {161 hardwareKeysTest.resetCaptureKeyCallback('all');162 });163 });164 165 it("2.4.should capture any key using an uppercase ALL", function()166 {167 runs(function()168 {169 hardwareKeysTest.captureKey(true,'ALL'); // Any Key170 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.tabKey.value); // TAB171 }, "set capture key to any key & simulate TAB key press..."); 172 173 waitsFor(function()174 {175 return hardwareKeysTest.callbackFiredResult == hardwareKeysTest.tabKey.value;176 }, "ERROR: Failed to capture any key", 3000);177 178 runs(function()179 {180 hardwareKeysTest.resetCaptureKeyCallback('ALL');181 });182 });183 184 it("2.5.should not capture any key after resetting 'all' keyValue keyCapture", function() {185 runs(function()186 {187 hardwareKeysTest.captureKey(true,'ALL'); // Any Key188 hardwareKeysTest.resetCaptureKeyCallback('ALL');189 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.tabKey.value); // TAB190 setTimeout(function(){hardwareKeysTest.callbackFiredResult = 'timedout'},1000);// TAB191 }, "set capture key to ALL, then reset then press TAB"); 192 193 waitsFor(function()194 {195 return hardwareKeysTest.callbackFiredResult == 'timedout';196 }, "ERROR: Test setup failed, timeout not occurring", 3000);197 198 runs(function()199 {200 expect(hardwareKeysTest.callbackFired).toBe(false); 201 }, 'expect the callback not to fire'); 202 });203 204 it("2.6.should not capture any key after resetting 'all' keyValue keyCapture with mixed letter case", function()205 {206 runs(function()207 {208 hardwareKeysTest.captureKey(true,'ALL'); // Any Key209 hardwareKeysTest.resetCaptureKeyCallback('aLL');210 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.tabKey.value); // TAB211 setTimeout(function(){hardwareKeysTest.callbackFiredResult = 'timedout'},1000);// TAB212 }, "set capture key to ALL, then reset then press TAB"); 213 214 waitsFor(function()215 {216 return hardwareKeysTest.callbackFiredResult == 'timedout';217 }, "ERROR: Test setup failed, timeout not occurring", 3000);218 219 runs(function()220 {221 expect(hardwareKeysTest.callbackFired).toBe(false); 222 hardwareKeysTest.resetCaptureKeyCallback('ALL');223 }, 'expect the callback not to fire'); 224 });225 226 it("2.7.should capture multiple keys", function()227 {228 runs(function()229 {230 setTimeout(function()231 {232 hardwareKeysTest.captureKey(false,hardwareKeysTest.enterKey.string); 233 hardwareKeysTest.captureKey(false,hardwareKeysTest.tabKey.string);234 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.enterKey.value);235 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.tabKey.value);236 },500);237 },'set capture key for ENTER and TAB and simulate key events');238 239 waitsFor(function()240 {241 if(hardwareKeysTest.callbackFiredResult == null) {return false;}242 if((typeof hardwareKeysTest.callbackFiredResult) != 'object') {return false;}243 if(hardwareKeysTest.callbackFiredResult.length != 2) {return false;}244 else{return true;}245 }, "ERROR: MultipleKeys NOT received", 3000);246 247 runs(function()248 {249 //console.log(hardwareKeysTest.callbackFiredResult[0] + ' = 13');250 //console.log(hardwareKeysTest.callbackFiredResult[1] + ' = 8');251 expect(hardwareKeysTest.callbackFiredResult[0]).toEqual(hardwareKeysTest.enterKey.value);252 expect(hardwareKeysTest.callbackFiredResult[1]).toEqual(hardwareKeysTest.tabKey.value);253 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.enterKey.string);254 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.tabKey.string);255 }, 'expect both callbacks to fire with each keyValues');256 });257 258 it("2.8.should not capture a key after it has been reset", function()259 {260 runs(function()261 {262 hardwareKeysTest.captureKey(true,hardwareKeysTest.tabKey.string); // Any Key263 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.tabKey.string);264 setTimeout(function(){hardwareKeysTest.simulateKeyPress(hardwareKeysTest.tabKey.value);},100); // TAB265 setTimeout(function(){hardwareKeysTest.callbackFiredResult = 'timedout'},1100);// TAB266 }, "set capture key to TAB, then reset then press TAB"); 267 268 waitsFor(function()269 {270 return hardwareKeysTest.callbackFiredResult == 'timedout';271 }, "ERROR: Test setup failed, timeout not occurring", 3000);272 273 runs(function()274 {275 expect(hardwareKeysTest.callbackFired).toBe(false);276 }, 'expect the callback not to fire'); 277 });278 279 it("2.9.should only fire 'all' callback if both 'all' and a key has been registered", function()280 {281 runs(function()282 {283 hardwareKeysTest.captureKey(true,'ALL');284 hardwareKeysTest.captureKey(true,hardwareKeysTest.tabKey.string); 285 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.tabKey.value);286 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB287 },"set all captureKey and then " + hardwareKeysTest.tabKey.string + " capture key and fire a " + hardwareKeysTest.tabKey.string + " key press");288 289 waitsFor(function()290 {291 return hardwareKeysTest.callbackFiredTimeout == 'timedout';292 }, "ERROR: Test setup failed, timeout not occurring", 3000); 293 294 runs(function()295 {296 hardwareKeysTest.resetCaptureKeyCallback('ALL');297 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.tabKey.string);298 expect(hardwareKeysTest.callbackFired).toBe(true);299 expect(typeof hardwareKeysTest.callbackFiredResult).toEqual('number');300 }, 'expect the callback to fire only once'); 301 });302 303 it("2.10.should fire 'all' callback if a key specific callback is registered after the all callback is registered (all persistence)", function()304 {305 runs(function()306 {307 hardwareKeysTest.captureKey(true,'ALL');308 hardwareKeysTest.captureKey(true,hardwareKeysTest.enterKey.string); 309 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.tabKey.value);310 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB311 },"set all captureKey and then " + hardwareKeysTest.enterKey.string + " capture key and fire a " + hardwareKeysTest.tabKey.string + " key press");312 waitsFor(function()313 {314 return hardwareKeysTest.callbackFiredTimeout == 'timedout';315 }, "ERROR: Test setup failed, timeout not occurring", 3000); 316 runs(function()317 {318 hardwareKeysTest.resetCaptureKeyCallback('ALL');319 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.enterKey.string);320 expect(hardwareKeysTest.callbackFired).toBe(true);321 expect(hardwareKeysTest.callbackFiredResult).toEqual(hardwareKeysTest.tabKey.value);322 }, 'expect the callback to fire only once'); 323 });324 325 it("2.11.should not obstruct the key event from reaching the page when dispatch is set to true", function()326 {327 runs(function()328 {329 hardwareKeysTest.captureKey(true,hardwareKeysTest.aKey.string);330 hardwareKeysTest.createTextBox();331 hardwareKeysTest.textBox.focus();332 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.aKey.value);333 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB334 }, 'Create a text box, add it to the page and focus it. Setup the ' + hardwareKeysTest.LETTER_A_CODE + ' key capture with dispatch and fire ' + hardwareKeysTest.LETTER_A_CODE + ' key');335 waitsFor(function()336 {337 return hardwareKeysTest.callbackFiredTimeout == 'timedout';338 }, "Callback didnt fire", 3000);339 runs(function()340 {341 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.aKey.string);342 textBoxValue = hardwareKeysTest.textBox.value;343 hardwareKeysTest.removeTextBox();344 expect(hardwareKeysTest.callbackFired).toBe(true);345 expect(hardwareKeysTest.callbackFiredResult).toBe(hardwareKeysTest.aKey.value);346 expect(textBoxValue).toEqual(hardwareKeysTest.aKey.description);347 },'expect the key to be input into the input box and the callback to fire');348 });349 350 it("2.12.should obstruct the key event from reaching the page when dispatch is set to false", function()351 {352 runs(function()353 {354 hardwareKeysTest.captureKey(false,hardwareKeysTest.aKey.string);355 hardwareKeysTest.createTextBox();356 hardwareKeysTest.textBox.focus();357 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.aKey.value);358 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB359 }, 'Create a text box, add it to the page and focus it. Setup the ' + hardwareKeysTest.LETTER_A_CODE + ' key capture with dispatch and fire ' + hardwareKeysTest.LETTER_A_CODE + ' key');360 361 waitsFor(function()362 {363 return hardwareKeysTest.callbackFiredTimeout == 'timedout';364 }, "Callback didnt fire", 3000);365 366 runs(function()367 {368 textBoxValue = hardwareKeysTest.textBox.value;369 hardwareKeysTest.removeTextBox();370 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.aKey.string);371 expect(hardwareKeysTest.callbackFired).toBe(true);372 expect(hardwareKeysTest.callbackFiredResult).toBe(hardwareKeysTest.aKey.value);373 expect(textBoxValue).toEqual('');374 },'expect the key not to be input into the input box and the callback to fire');375 });376 377 it("2.13.should capture ENTER key when specified with DECIMAL", function()378 {379 runs(function()380 {381 hardwareKeysTest.captureKey(true,'' + hardwareKeysTest.enterKey.value); // ENTER382 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.enterKey.value); // ENTER383 }, "set capture key to ENTER & simulate ENTER key press...");384 waitsFor(function()385 {386 return hardwareKeysTest.callbackFiredResult == hardwareKeysTest.enterKey.value;387 }, "ERROR: Failed to capture ENTER key", 3000);388 389 runs(function()390 { 391 hardwareKeysTest.resetCaptureKeyCallback('' + hardwareKeysTest.enterKey.value);392 });393 });394 395 if(hardwareKeysTest.isAndroid())396 {397 it("2.14.should capture P1 (volume down) key", function()398 {399 runs(function()400 {401 hardwareKeysTest.captureKey(false, hardwareKeysTest.volumeDown.string);402 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.volumeDown.value);403 }, 'set capture P1 key and fire P1 key event');404 405 waitsFor(function()406 {407 return hardwareKeysTest.callbackFiredResult == hardwareKeysTest.volumeDown.value;408 }, 'ERROR: couldnt catch P1 event',3000);409 runs(function()410 {411 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.volumeDown.string);412 });413 });414 415 it("2.15.should capture P2 (volume up) key", function()416 {417 runs(function()418 {419 hardwareKeysTest.captureKey(false, hardwareKeysTest.volumeUp.string);420 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.volumeUp.value);421 }, 'set capture P2 key and fire P2 key event');422 423 waitsFor(function()424 {425 return hardwareKeysTest.callbackFiredResult == hardwareKeysTest.volumeUp.value;426 }, 'ERROR: couldnt catch P2 event',3000);427 428 runs(function()429 {430 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.volumeUp.string);431 });432 });433 it("2.16.should capture P3 (search) key", function()434 {435 runs(function()436 {437 hardwareKeysTest.captureKey(false, hardwareKeysTest.searchKey.string);438 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.searchKey.value);439 }, 'set capture P3 key and fire P3 key event');440 441 waitsFor(function()442 {443 return hardwareKeysTest.callbackFiredResult == hardwareKeysTest.searchKey.value;444 }, 'ERROR: couldnt catch P3 event',3000);445 446 runs(function()447 {448 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.searchKey.string);449 });450 });451 452 it("2.17.should capture back key", function()453 {454 runs(function()455 {456 hardwareKeysTest.captureKey(false, hardwareKeysTest.backKey.string);457 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.backKey.value);458 }, 'set capture back key and fire back key event');459 460 waitsFor(function()461 {462 return hardwareKeysTest.callbackFiredResult == hardwareKeysTest.backKey.value;463 }, 'ERROR: couldnt catch back event',3000);464 465 runs(function()466 {467 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.backKey.string);468 });469 });470 471 it("2.18.should capture menu key", function()472 {473 runs(function()474 {475 hardwareKeysTest.captureKey(false, hardwareKeysTest.menuKey.string);476 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.menuKey.value);477 }, 'set capture menu key and fire menu key event');478 479 waitsFor(function()480 {481 return hardwareKeysTest.callbackFiredResult == hardwareKeysTest.menuKey.value;482 }, 'ERROR: couldnt catch menu event',3000);483 484 runs(function()485 {486 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.menuKey.string);487 });488 });489 }490 491 ///////////////////////////////////////////////////////////////////////492 // converted manual Tests493 ///////////////////////////////////////////////////////////////////////494 it("VT289-011 | call captureKey with dispatch true, keyValue for " +hardwareKeysTest.testKey11.description+" and function callback |", function()495 {496 runs(function()497 {498 //Click inside Textbox and Press numeric key " +hardwareKeysTest.testKey11.description499 hardwareKeysTest.captureKey(true,hardwareKeysTest.testKey11.string);500 hardwareKeysTest.createTextBox();501 hardwareKeysTest.textBox.focus();502 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.testKey11.value);503 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB504 });505 waitsFor(function()506 {507 return hardwareKeysTest.callbackFiredTimeout == 'timedout';508 }, "Callback didnt fire", 3000);509 510 runs(function()511 {512 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.testKey11.string);513 textBoxValue = hardwareKeysTest.textBox.value;514 hardwareKeysTest.removeTextBox();515 expect(hardwareKeysTest.callbackFired).toBe(true);516 expect(hardwareKeysTest.callbackFiredResult).toBe(hardwareKeysTest.testKey11.value);517 if(!hardwareKeysTest.isAndroid()) expect(textBoxValue).toEqual(hardwareKeysTest.testKey11.description);518 });519 });520 521 it("VT289-012 | call captureKey with dispatch false, keyValue for " +hardwareKeysTest.testKey11.description+" and function callback |", function()522 {523 runs(function()524 {525 hardwareKeysTest.captureKey(false,hardwareKeysTest.testKey11.string);526 hardwareKeysTest.createTextBox();527 hardwareKeysTest.textBox.focus();528 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.testKey11.value);529 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB530 });531 waitsFor(function()532 {533 return hardwareKeysTest.callbackFiredTimeout == 'timedout';534 }, "Callback didnt fire", 3000);535 536 runs(function()537 {538 //Callback should fire with value " +hardwareKeysTest.testKey11.string+" and number " +hardwareKeysTest.testKey11.description+" should not be dispatched inside the textbox539 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.testKey11.string);540 textBoxValue = hardwareKeysTest.textBox.value;541 hardwareKeysTest.removeTextBox();542 expect(hardwareKeysTest.callbackFired).toBe(true);543 expect(hardwareKeysTest.callbackFiredResult).toBe(hardwareKeysTest.testKey11.value);544 if(!hardwareKeysTest.isAndroid()) expect(textBoxValue).toEqual('');545 });546 });547 548 it("VT289-013 | call captureKey with dispatch true, keyValue for" +hardwareKeysTest.testKey13.description+" and no callback(Sync) |", function()549 {550 runs(function()551 {552 //Callback should fire with value " +hardwareKeysTest.testKey13.string+" and " +hardwareKeysTest.testKey13.description+" should be dispatched inside the textbox553 hardwareKeysTest.captureKey(true,hardwareKeysTest.testKey13.string);554 hardwareKeysTest.createTextBox();555 hardwareKeysTest.textBox.focus();556 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.testKey13.value);557 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB558 });559 waitsFor(function()560 {561 return hardwareKeysTest.callbackFiredTimeout == 'timedout';562 }, "Callback didnt fire", 3000);563 564 runs(function()565 {566 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.testKey13.string);567 expect(hardwareKeysTest.callbackFired).toBe(true);568 expect(hardwareKeysTest.callbackFiredResult).toBe(hardwareKeysTest.testKey13.value);569 textBoxValue = hardwareKeysTest.textBox.value;570 hardwareKeysTest.removeTextBox();571 if(!hardwareKeysTest.isAndroid()) expect(textBoxValue).toEqual(hardwareKeysTest.testKey13.description);572 });573 });574 575 it("VT289-014 | call captureKey with dispatch true, keyValue for " +hardwareKeysTest.testKey14.description+" and callback as anonymous function |", function()576 {577 runs(function()578 {579 //Click inside Textbox and Press " +hardwareKeysTest.testKey14.description580 Rho.KeyCapture.captureKey(true,hardwareKeysTest.testKey14.string,function(data){hardwareKeysTest.captureKeyCallback(data);});581 hardwareKeysTest.createTextBox();582 hardwareKeysTest.textBox.focus();583 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.testKey14.value);584 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB585 });586 waitsFor(function()587 {588 return hardwareKeysTest.callbackFiredTimeout == 'timedout';589 }, "Callback didnt fire", 3000);590 591 runs(function()592 {593 //Callback should fire with value " +hardwareKeysTest.testKey14.string+" check for Callback to fire with value and " +hardwareKeysTest.testKey14.description+" should be dispatched inside the textbox594 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.testKey14.string);595 expect(hardwareKeysTest.callbackFired).toBe(true);596 expect(hardwareKeysTest.callbackFiredResult).toBe(hardwareKeysTest.testKey14.value);597 textBoxValue = hardwareKeysTest.textBox.value;598 hardwareKeysTest.removeTextBox();599 if(!hardwareKeysTest.isAndroid()) expect(textBoxValue).toEqual(hardwareKeysTest.testKey14.description);600 });601 });602 603 it("VT289-015 | call captureKey with dispatch false, keyValue for" +hardwareKeysTest.testKey15.description+" and press "+hardwareKeysTest.testKey14.description, function()604 {605 runs(function()606 {607 //Click inside Textbox and Press "+hardwareKeysTest.testKey14.description608 hardwareKeysTest.captureKey(true,hardwareKeysTest.testKey15.string);609 hardwareKeysTest.createTextBox();610 hardwareKeysTest.textBox.focus();611 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.testKey14.value);612 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB613 });614 waitsFor(function()615 {616 return hardwareKeysTest.callbackFiredTimeout == 'timedout';617 }, "Callback didnt fire", 3000);618 619 runs(function()620 {621 //Callback should not fire and " +hardwareKeysTest.testKey14.description+ "should be dispatched inside the textbox622 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.testKey15.string);623 expect(hardwareKeysTest.callbackFired).toBe(false);624 textBoxValue = hardwareKeysTest.textBox.value;625 hardwareKeysTest.removeTextBox();626 if(!hardwareKeysTest.isAndroid()) expect(textBoxValue).toEqual(hardwareKeysTest.testKey14.description);627 });628 });629 630 it("VT289-016 | call captureKey with dispatch True, keyValue ALL and callback |", function()631 {632 runs(function()633 {634 //Press all type of key (a-z 0-9 symbol, function)635 hardwareKeysTest.captureKey(true,'ALL');636 hardwareKeysTest.createTextBox();637 hardwareKeysTest.textBox.focus();638 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.aKey.value);639 setTimeout(function(){hardwareKeysTest.simulateKeyPress(hardwareKeysTest.hashKey.value)},200);640 setTimeout(function(){hardwareKeysTest.simulateKeyPress(hardwareKeysTest.oneKey.value)},400);641 setTimeout(function(){hardwareKeysTest.simulateKeyPress(hardwareKeysTest.f1Key.value)},600);642 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},4800);// TAB643 });644 waitsFor(function()645 {646 return hardwareKeysTest.callbackFiredTimeout == 'timedout';647 }, "Callback didnt fire", 4800);648 649 runs(function()650 {651 //Callback should fire with retrun key values all pressed keys should be dispatched652 hardwareKeysTest.resetCaptureKeyCallback('ALL');653 textBoxValue = hardwareKeysTest.textBox.value;654 hardwareKeysTest.removeTextBox();655 656 expect(hardwareKeysTest.callbackFired).toBe(true);657 expect(hardwareKeysTest.callbackFiredResult.length).toBe(4);658 expect(hardwareKeysTest.callbackFiredResult[0]).toEqual(hardwareKeysTest.aKey.value);659 expect(hardwareKeysTest.callbackFiredResult[1]).toEqual(hardwareKeysTest.hashKey.value);660 expect(hardwareKeysTest.callbackFiredResult[2]).toEqual(hardwareKeysTest.oneKey.value);661 expect(hardwareKeysTest.callbackFiredResult[3]).toEqual(hardwareKeysTest.f1Key.value);662 expect(textBoxValue).toEqual(hardwareKeysTest.aKey.description + hardwareKeysTest.hashKey.description + hardwareKeysTest.oneKey.description);663 });664 });665 666 it("VT289-021 | call captureKey twice, one with callback and other without callback |", function()667 {668 runs(function()669 {670 //Press " +hardwareKeysTest.testKey15.description+", Press numeric key " +hardwareKeysTest.testKey21.description+"671 hardwareKeysTest.captureKey(true,hardwareKeysTest.testKey15.string);672 Rho.KeyCapture.captureKey(true,hardwareKeysTest.testKey21.string);673 hardwareKeysTest.createTextBox();674 hardwareKeysTest.textBox.focus();675 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.testKey15.value);676 setTimeout(function(){hardwareKeysTest.simulateKeyPress(hardwareKeysTest.testKey21.value);},200);677 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1200);// TAB678 });679 waitsFor(function()680 {681 return hardwareKeysTest.callbackFiredTimeout == 'timedout';682 }, "Callback didnt fire", 3200);683 684 runs(function()685 {686 //callback1 should fire after pressing " +hardwareKeysTest.testKey15.description+" and no callback should fire after pressing " +hardwareKeysTest.testKey21.description+" and both key should be dispatched687 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.testKey15.string);688 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.testKey21.string);689 expect(hardwareKeysTest.callbackFired).toBe(true);690 expect(hardwareKeysTest.callbackFiredResult).toBe(hardwareKeysTest.testKey15.value);691 textBoxValue = hardwareKeysTest.textBox.value;692 hardwareKeysTest.removeTextBox();693 if(!hardwareKeysTest.isAndroid()) expect(textBoxValue).toEqual(hardwareKeysTest.testKey15.description + hardwareKeysTest.testKey21.description);694 }); 695 });696 // Removed because requirements have changed.697 // it("VT289-022 | call captureKey twice, one with callback and other without callback for keyValue ALL |", function()698 // {699 // runs(function()700 // {701 // //Press " +hardwareKeysTest.testKey15.description+", Press numeric key " +hardwareKeysTest.testKey21.description+"702 // hardwareKeysTest.captureKey(true,hardwareKeysTest.testKey15.string);703 // Rho.KeyCapture.captureKey(false,'ALL');704 // hardwareKeysTest.createTextBox();705 // hardwareKeysTest.textBox.focus();706 // hardwareKeysTest.simulateKeyPress(hardwareKeysTest.testKey15.value);707 // setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB708 // });709 //710 // waitsFor(function()711 // {712 // return hardwareKeysTest.callbackFiredTimeout == 'timedout';713 // }, "Callback didnt fire", 3000);714 // 715 // runs(function()716 // {717 // //callback should fire only after pressing " +hardwareKeysTest.testKey15.description+" and allkeys should not be dispatched inside the textbox718 // hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.testKey15.string);719 // hardwareKeysTest.resetCaptureKeyCallback('ALL');720 // expect(hardwareKeysTest.callbackFired).toBe(false);721 // textBoxValue = hardwareKeysTest.textBox.value;722 // hardwareKeysTest.removeTextBox();723 // if(!hardwareKeysTest.isAndroid()) expect(textBoxValue).toEqual(hardwareKeysTest.testKey15.description);724 // }); 725 // });726 727 it("VT289-030 | call captureKey with no callback |", function()728 {729 runs(function()730 {731 //Click inside Textbox and Press key 1 and a from Hardware key, Press key 2 and b from soft key732 Rho.KeyCapture.captureKey(false,'ALL');733 Rho.KeyCapture.captureKey(true,'ALL');734 hardwareKeysTest.createTextBox();735 hardwareKeysTest.textBox.focus();736 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.aKey.value);737 setTimeout(function(){hardwareKeysTest.simulateKeyPress(hardwareKeysTest.zKey.value)},200);738 setTimeout(function(){hardwareKeysTest.simulateKeyPress(hardwareKeysTest.hashKey.value)},400);739 setTimeout(function(){hardwareKeysTest.simulateKeyPress(hardwareKeysTest.oneKey.value)},600);740 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},3800);// TAB741 });742 waitsFor(function()743 {744 return hardwareKeysTest.callbackFiredTimeout == 'timedout';745 }, "Callback didnt fire", 5800);746 747 runs(function()748 {749 //No callback should fire after pressing any hardware and soft key, all keys should be dispatched inside textbox after pressing any key750 hardwareKeysTest.resetCaptureKeyCallback('ALL');751 expect(hardwareKeysTest.callbackFired).toBe(false);752 textBoxValue = hardwareKeysTest.textBox.value;753 hardwareKeysTest.removeTextBox();754 var expectedOut = hardwareKeysTest.aKey.description + hardwareKeysTest.zKey.description + hardwareKeysTest.hashKey.description + hardwareKeysTest.oneKey.description;755 expect(textBoxValue).toEqual(expectedOut);756 });757 });758 759 it("VT289-031 | call captureKey with no callback after setting "+ hardwareKeysTest.testKey11.description, function()760 {761 runs(function()762 {763 764 //Click inside Textbox and"+ hardwareKeysTest.testKey11.description765 hardwareKeysTest.captureKey(false,hardwareKeysTest.testKey11.string);766 Rho.KeyCapture.captureKey(true,hardwareKeysTest.testKey11.string);767 hardwareKeysTest.createTextBox();768 hardwareKeysTest.textBox.focus();769 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.testKey11.value);770 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB771 });772 waitsFor(function()773 {774 return hardwareKeysTest.callbackFiredTimeout == 'timedout';775 }, "Callback didnt fire", 3000);776 777 runs(function()778 {779 //No callback should fire after pressing" +hardwareKeysTest.testKey11.description+" and" +hardwareKeysTest.testKey11.description+" should be dispatched inside text box780 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.testKey11.string);781 expect(hardwareKeysTest.callbackFired).toBe(false);782 textBoxValue = hardwareKeysTest.textBox.value;783 hardwareKeysTest.removeTextBox();784 if(!hardwareKeysTest.isAndroid()) expect(textBoxValue).toEqual(hardwareKeysTest.testKey11.description);785 });786 });787 });788 }789 if (!isWindowsMobilePlatform) //putting check for WM because of issues in instumentation API for WM790 { 791 describe("Remap", function()792 {793 ///////////////////////////////////////////////////////////////////////794 // 3. Key remap795 ///////////////////////////////////////////////////////////////////////796 it("3.1.should remap TAB key to the ENTER key", function() {797 runs(function()798 {799 hardwareKeysTest.remapKey(hardwareKeysTest.tabKey.string, hardwareKeysTest.enterKey.string); // TAB->ENTER800 hardwareKeysTest.captureKey(true,'ALL'); // Any Key801 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.tabKey.value); // TAB802 }, "remap TAB to ENTER, & simulate TAB key press...");803 804 waitsFor(function()805 {806 return hardwareKeysTest.callbackFiredResult == hardwareKeysTest.enterKey.value;807 }, "ERROR: ENTER key has not been remapped", 3000);808 809 runs(function()810 {811 hardwareKeysTest.resetCaptureKeyCallback('ALL');812 hardwareKeysTest.clearRemap(hardwareKeysTest.tabKey.string);813 });814 });815 816 it("3.2.should clear a remap using null value", function() {817 runs(function()818 {819 hardwareKeysTest.remapKey(hardwareKeysTest.tabKey.string, hardwareKeysTest.enterKey.string); // TAB->ENTER820 hardwareKeysTest.remapKey(hardwareKeysTest.tabKey.string, null);821 hardwareKeysTest.captureKey(false, hardwareKeysTest.enterKey.string);822 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.tabKey.value); // TAB823 setTimeout(function(){hardwareKeysTest.callbackFiredResult = 'timedout'},1000);// TAB824 }, "remap TAB to ENTER, then reset and simulate TAB key press..."); 825 826 waitsFor(function()827 {828 return hardwareKeysTest.callbackFiredResult == 'timedout';829 }, "ERROR: Test setup failed, timeout not occurring", 3000);830 831 runs(function()832 {833 expect(hardwareKeysTest.callbackFired).toBe(false);834 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.enterKey.string);835 hardwareKeysTest.clearRemap(hardwareKeysTest.tabKey.string);836 }, 'expect the callback not to fire'); 837 });838 839 it("3.3.should clear a remap using empty string", function()840 {841 runs(function()842 {843 hardwareKeysTest.remapKey(hardwareKeysTest.tabKey.string, hardwareKeysTest.enterKey.string); // TAB->ENTER844 Rho.KeyCapture.remapKey(hardwareKeysTest.tabKey.string, '');845 hardwareKeysTest.captureKey(false, hardwareKeysTest.enterKey.string);846 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.tabKey.value); // TAB847 setTimeout(function(){hardwareKeysTest.callbackFiredResult = 'timedout'},1000);// TAB848 }, "remap TAB to ENTER, then reset and simulate TAB key press..."); 849 850 waitsFor(function()851 {852 return hardwareKeysTest.callbackFiredResult == 'timedout';853 }, "ERROR: Test setup failed, timeout not occurring", 3000);854 855 runs(function()856 {857 expect(hardwareKeysTest.callbackFired).toBe(false);858 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.enterKey.string);859 hardwareKeysTest.clearRemap(hardwareKeysTest.tabKey.string);860 }, 'expect the callback not to fire'); 861 });862 863 ///////////////////////////////////////////////////////////////////////864 // From Manual ReMap key Tests865 ///////////////////////////////////////////////////////////////////////866 it("VT289-039 | call remapKey with enter and numeric key 1 |", function()867 {868 runs(function()869 {870 hardwareKeysTest.remapKey(hardwareKeysTest.enterKey.string, hardwareKeysTest.oneKey.string);871 hardwareKeysTest.createTextBox();872 hardwareKeysTest.textBox.focus();873 874 //Press enter key and press numeric key 1875 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.enterKey.value);876 setTimeout(function(){hardwareKeysTest.simulateKeyPress(hardwareKeysTest.oneKey.value);},200);877 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1200);// TAB878 });879 880 waitsFor(function()881 {882 return hardwareKeysTest.callbackFiredTimeout == 'timedout';883 }, "Error in delay", 3200);884 runs(function()885 {886 //Both key should be dispatched as 1887 expect(hardwareKeysTest.textBox.value).toEqual(hardwareKeysTest.oneKey.description + hardwareKeysTest.oneKey.description);888 889 //Tear down890 hardwareKeysTest.clearRemap(hardwareKeysTest.enterKey.string);891 hardwareKeysTest.removeTextBox();892 });893 });894 it("VT289-040 | call remapKey with functionkey F1 and numeric key 9 |", function()895 {896 runs(function()897 {898 hardwareKeysTest.remapKey(hardwareKeysTest.f1Key.string, hardwareKeysTest.nineKey.string);899 hardwareKeysTest.createTextBox();900 hardwareKeysTest.textBox.focus();901 902 //Press functionkey F1 and numeric key 9903 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.f1Key.value);904 setTimeout(function(){hardwareKeysTest.simulateKeyPress(hardwareKeysTest.nineKey.value);},200);905 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB906 });907 908 waitsFor(function()909 {910 return hardwareKeysTest.callbackFiredTimeout == 'timedout';911 }, "Error in delay", 3000);912 runs(function()913 {914 //Both key should be dispatched as 9915 expect(hardwareKeysTest.textBox.value).toEqual(hardwareKeysTest.nineKey.description + hardwareKeysTest.nineKey.description);916 917 //Tear down918 hardwareKeysTest.clearRemap(hardwareKeysTest.f1Key.string);919 hardwareKeysTest.removeTextBox();920 });921 });922 it("VT289-041 | call remapKey with numeric key 5 and null |", function() {923 runs(function()924 {925 //click inside the textbox, .Press numeric key 5 and 2926 hardwareKeysTest.remapKey(hardwareKeysTest.fiveKey.string,hardwareKeysTest.twoKey.string);927 hardwareKeysTest.remapKey(hardwareKeysTest.fiveKey.string, null);928 hardwareKeysTest.createTextBox();929 hardwareKeysTest.textBox.focus();930 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.fiveKey.value);931 setTimeout(function(){hardwareKeysTest.simulateKeyPress(hardwareKeysTest.twoKey.value);},200);932 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB933 });934 935 waitsFor(function()936 {937 return hardwareKeysTest.callbackFiredTimeout == 'timedout';938 }, "Error in delay", 3000);939 runs(function()940 {941 //5 should be dispatched after pressing 5 and 2 should be dispatched after pressing 2, No Remap942 expect(hardwareKeysTest.textBox.value).toEqual(hardwareKeysTest.fiveKey.description + hardwareKeysTest.twoKey.description);943 //Tear down944 hardwareKeysTest.removeTextBox();945 });946 });947 it("VT289-044 | call capturekey after remapKey |", function() {948 runs(function()949 {950 hardwareKeysTest.remapKey(hardwareKeysTest.aKey.string, hardwareKeysTest.bKey.string);951 hardwareKeysTest.captureKey(true, hardwareKeysTest.aKey.string);952 hardwareKeysTest.createTextBox();953 hardwareKeysTest.textBox.focus();954 955 //Press keys a and b956 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.aKey.value);957 setTimeout(function(){hardwareKeysTest.simulateKeyPress(hardwareKeysTest.bKey.value);},200);958 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB959 });960 961 waitsFor(function()962 {963 return hardwareKeysTest.callbackFiredTimeout == 'timedout';964 }, "Error in delay", 3000);965 runs(function()966 { 967 //Callback should not fire after pressing key a, Both key should be dispatched as b after pressing a and b968 hardwareKeysTest.clearRemap(hardwareKeysTest.aKey.string);969 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.aKey.string);970 expect(hardwareKeysTest.textBox.value).toEqual(hardwareKeysTest.bKey.description + hardwareKeysTest.bKey.description);971 expect(hardwareKeysTest.callbackFired).toBe(false);972 hardwareKeysTest.removeTextBox();973 });974 });975 it("VT289-045 | call capturekey after remapKey and callback to fire |", function()976 {977 runs(function()978 {979 hardwareKeysTest.remapKey(hardwareKeysTest.zKey.string,hardwareKeysTest.yKey.string);980 hardwareKeysTest.captureKey(true,hardwareKeysTest.yKey.string);981 hardwareKeysTest.createTextBox();982 hardwareKeysTest.textBox.focus();983 984 //Press keys y and z985 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.zKey.value);986 setTimeout(function(){hardwareKeysTest.simulateKeyPress(hardwareKeysTest.yKey.value);},200);987 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB988 });989 990 waitsFor(function()991 {992 return hardwareKeysTest.callbackFiredTimeout == 'timedout';993 }, "Error in delay", 3000);994 runs(function()995 { 996 hardwareKeysTest.clearRemap(hardwareKeysTest.zKey.string);997 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.yKey.string);998 //Callback should fire after pressing key z and y, Both key should be dispatched as y after pressing z and y999 expect(hardwareKeysTest.textBox.value).toEqual(hardwareKeysTest.yKey.description + hardwareKeysTest.yKey.description);1000 expect(hardwareKeysTest.callbackFired).toBe(true);1001 expect(hardwareKeysTest.callbackFiredResult.length).toBe(2);1002 expect(hardwareKeysTest.callbackFiredResult[0]).toEqual(hardwareKeysTest.yKey.value);1003 expect(hardwareKeysTest.callbackFiredResult[1]).toEqual(hardwareKeysTest.yKey.value);1004 hardwareKeysTest.removeTextBox();1005 });1006 });1007 it("VT289-046 | call remapKey after capturekey and callback to fire |", function()1008 {1009 runs(function()1010 {1011 hardwareKeysTest.captureKey(true,hardwareKeysTest.hashKey.string);1012 hardwareKeysTest.remapKey(hardwareKeysTest.starKey.string, hardwareKeysTest.hashKey.string);1013 hardwareKeysTest.createTextBox();1014 hardwareKeysTest.textBox.focus();1015 1016 //Press numeric key * and #1017 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.starKey.value);1018 setTimeout(function(){hardwareKeysTest.simulateKeyPress(hardwareKeysTest.hashKey.value);},200);1019 setTimeout(function(){hardwareKeysTest.callbackFiredTimeout = 'timedout'},1000);// TAB1020 });1021 1022 waitsFor(function()1023 {1024 return hardwareKeysTest.callbackFiredTimeout == 'timedout';1025 }, "Error in delay", 3000);1026 runs(function()1027 { 1028 hardwareKeysTest.clearRemap(hardwareKeysTest.starKey.string);1029 hardwareKeysTest.resetCaptureKeyCallback(hardwareKeysTest.hashKey.string);1030 //Callback should fire after pressing key * and #, Both key should be dispatched as # after pressing * and #1031 expect(hardwareKeysTest.textBox.value).toEqual(hardwareKeysTest.hashKey.description + hardwareKeysTest.hashKey.description);1032 expect(hardwareKeysTest.callbackFired).toBe(true);1033 expect(hardwareKeysTest.callbackFiredResult.length).toBe(2);1034 expect(hardwareKeysTest.callbackFiredResult[0]).toEqual(hardwareKeysTest.hashKey.value);1035 expect(hardwareKeysTest.callbackFiredResult[1]).toEqual(hardwareKeysTest.hashKey.value);1036 hardwareKeysTest.removeTextBox();1037 });1038 });1039 });1040 }1041 if (!isWindowsMobilePlatform) //putting check for WM because of issues in instumentation API for WM1042 {1043 if (isWindowsMobileOrAndroidPlatform() && Rho.System.isSymbolDevice == true) 1044 {1045 describe("Trigger", function()1046 {1047 ///////////////////////////////////////////////////////////////////////1048 // 4. Trigger1049 ///////////////////////////////////////////////////////////////////////1050 it("4.1.should capture the trigger press", function()1051 {1052 runs(function()1053 {1054 hardwareKeysTest.setTrigger();1055 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.TRIGGER); // TRIGGER1056 }, "enable Trigger and simulate trigger press..."); 1057 1058 waitsFor(function()1059 {1060 if(hardwareKeysTest.callbackFiredResult == null){return false;}1061 if((typeof hardwareKeysTest.callbackFiredResult) != 'object'){return false;}1062 if(hardwareKeysTest.callbackFiredResult.length != 2){return false;}1063 else{return true;}1064 }, "ERROR: Trigger NOT received", 3000);1065 1066 runs(function()1067 {1068 expect(hardwareKeysTest.callbackFiredResult[0]).toEqual(hardwareKeysTest.TRIGGER);1069 expect(hardwareKeysTest.callbackFiredResult[1]).toEqual(0);1070 hardwareKeysTest.resetTrigger();1071 },'expect both trigger down and trigger up events are fired');1072 });1073 1074 it("4.2.should NOT capture the trigger when other key pressed", function()1075 {1076 runs(function()1077 {1078 hardwareKeysTest.setTrigger();1079 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.tabKey.value); // TAB1080 setTimeout(function(){hardwareKeysTest.callbackFiredResult = 'timedout'},1000);1081 }, "enable Trigger and simulate tab key..."); 1082 1083 waitsFor(function()1084 {1085 return hardwareKeysTest.callbackFiredResult == 'timedout';1086 }, "ERROR: Test setup failed, timeout not occurring", 3000);1087 1088 runs(function()1089 {1090 expect(hardwareKeysTest.callbackFired).toBe(false);1091 hardwareKeysTest.resetTrigger();1092 }, 'expect the callback not to fire');1093 });1094 1095 it("4.3.should NOT capture the trigger after the trigger callback is cleared", function()1096 {1097 runs(function()1098 {1099 hardwareKeysTest.setTrigger();1100 hardwareKeysTest.resetTrigger();1101 hardwareKeysTest.simulateKeyPress(hardwareKeysTest.TRIGGER); // TRIGGER1102 setTimeout(function(){hardwareKeysTest.callbackFiredResult = 'timedout'},1000);// TAB1103 }, "reset trigger callback and fire trigger.");1104 1105 waitsFor(function()1106 {1107 return hardwareKeysTest.callbackFiredResult == 'timedout';1108 }, "ERROR: Test setup failed, timeout not occurring", 3000);1109 runs(function()1110 {1111 expect(hardwareKeysTest.callbackFired).toBe(false);1112 }, 'expect the callback not to fire');1113 });1114 });1115 }1116 }...

Full Screen

Full Screen

autocomplete-list-keys-coverage.js

Source:autocomplete-list-keys-coverage.js Github

copy

Full Screen

1/*2YUI 3.7.3 (build 5687)3Copyright 2012 Yahoo! Inc. All rights reserved.4Licensed under the BSD License.5http://yuilibrary.com/license/6*/7if (typeof _yuitest_coverage == "undefined"){8 _yuitest_coverage = {};9 _yuitest_coverline = function(src, line){10 var coverage = _yuitest_coverage[src];11 if (!coverage.lines[line]){12 coverage.calledLines++;13 }14 coverage.lines[line]++;15 };16 _yuitest_coverfunc = function(src, name, line){17 var coverage = _yuitest_coverage[src],18 funcId = name + ":" + line;19 if (!coverage.functions[funcId]){20 coverage.calledFunctions++;21 }22 coverage.functions[funcId]++;23 };24}25_yuitest_coverage["build/autocomplete-list-keys/autocomplete-list-keys.js"] = {26 lines: {},27 functions: {},28 coveredLines: 0,29 calledLines: 0,30 coveredFunctions: 0,31 calledFunctions: 0,32 path: "build/autocomplete-list-keys/autocomplete-list-keys.js",33 code: []34};35_yuitest_coverage["build/autocomplete-list-keys/autocomplete-list-keys.js"].code=["YUI.add('autocomplete-list-keys', function (Y, NAME) {","","/**","Mixes keyboard support into AutoCompleteList. By default, this module is not","loaded for iOS and Android devices.","","@module autocomplete","@submodule autocomplete-list-keys","**/",""," // keyCode constants.","var KEY_DOWN = 40,"," KEY_ENTER = 13,"," KEY_ESC = 27,"," KEY_TAB = 9,"," KEY_UP = 38;","","function ListKeys() {"," Y.before(this._bindKeys, this, 'bindUI');"," this._initKeys();","}","","ListKeys.prototype = {"," // -- Lifecycle Methods ----------------------------------------------------",""," /**"," Initializes keyboard command mappings.",""," @method _initKeys"," @protected"," @for AutoCompleteList"," **/"," _initKeys: function () {"," var keys = {},"," keysVisible = {};",""," // Register keyboard command handlers. _keys contains handlers that will"," // always be called; _keysVisible contains handlers that will only be"," // called when the list is visible."," keys[KEY_DOWN] = this._keyDown;",""," keysVisible[KEY_ENTER] = this._keyEnter;"," keysVisible[KEY_ESC] = this._keyEsc;"," keysVisible[KEY_TAB] = this._keyTab;"," keysVisible[KEY_UP] = this._keyUp;",""," this._keys = keys;"," this._keysVisible = keysVisible;"," },",""," destructor: function () {"," this._unbindKeys();"," },",""," /**"," Binds keyboard events.",""," @method _bindKeys"," @protected"," **/"," _bindKeys: function () {"," this._keyEvents = this._inputNode.on('keydown', this._onInputKey, this);"," },",""," /**"," Unbinds keyboard events.",""," @method _unbindKeys"," @protected"," **/"," _unbindKeys: function () {"," this._keyEvents && this._keyEvents.detach();"," this._keyEvents = null;"," },",""," // -- Protected Methods ----------------------------------------------------",""," /**"," Called when the down arrow key is pressed.",""," @method _keyDown"," @protected"," **/"," _keyDown: function () {"," if (this.get('visible')) {"," this._activateNextItem();"," } else {"," this.show();"," }"," },",""," /**"," Called when the enter key is pressed.",""," @method _keyEnter"," @protected"," **/"," _keyEnter: function (e) {"," var item = this.get('activeItem');",""," if (item) {"," this.selectItem(item, e);"," } else {"," // Don't prevent form submission when there's no active item."," return false;"," }"," },",""," /**"," Called when the escape key is pressed.",""," @method _keyEsc"," @protected"," **/"," _keyEsc: function () {"," this.hide();"," },",""," /**"," Called when the tab key is pressed.",""," @method _keyTab"," @protected"," **/"," _keyTab: function (e) {"," var item;",""," if (this.get('tabSelect')) {"," item = this.get('activeItem');",""," if (item) {"," this.selectItem(item, e);"," return true;"," }"," }",""," return false;"," },",""," /**"," Called when the up arrow key is pressed.",""," @method _keyUp"," @protected"," **/"," _keyUp: function () {"," this._activatePrevItem();"," },",""," // -- Protected Event Handlers ---------------------------------------------",""," /**"," Handles `inputNode` key events.",""," @method _onInputKey"," @param {EventTarget} e"," @protected"," **/"," _onInputKey: function (e) {"," var handler,"," keyCode = e.keyCode;",""," this._lastInputKey = keyCode;",""," if (this.get('results').length) {"," handler = this._keys[keyCode];",""," if (!handler && this.get('visible')) {"," handler = this._keysVisible[keyCode];"," }",""," if (handler) {"," // A handler may return false to indicate that it doesn't wish"," // to prevent the default key behavior."," if (handler.call(this, e) !== false) {"," e.preventDefault();"," }"," }"," }"," }","};","","Y.Base.mix(Y.AutoCompleteList, [ListKeys]);","","","}, '3.7.3', {\"requires\": [\"autocomplete-list\", \"base-build\"]});"];36_yuitest_coverage["build/autocomplete-list-keys/autocomplete-list-keys.js"].lines = {"1":0,"12":0,"18":0,"19":0,"20":0,"23":0,"34":0,"40":0,"42":0,"43":0,"44":0,"45":0,"47":0,"48":0,"52":0,"62":0,"72":0,"73":0,"85":0,"86":0,"88":0,"99":0,"101":0,"102":0,"105":0,"116":0,"126":0,"128":0,"129":0,"131":0,"132":0,"133":0,"137":0,"147":0,"160":0,"163":0,"165":0,"166":0,"168":0,"169":0,"172":0,"175":0,"176":0,"183":0};37_yuitest_coverage["build/autocomplete-list-keys/autocomplete-list-keys.js"].functions = {"ListKeys:18":0,"_initKeys:33":0,"destructor:51":0,"_bindKeys:61":0,"_unbindKeys:71":0,"_keyDown:84":0,"_keyEnter:98":0,"_keyEsc:115":0,"_keyTab:125":0,"_keyUp:146":0,"_onInputKey:159":0,"(anonymous 1):1":0};38_yuitest_coverage["build/autocomplete-list-keys/autocomplete-list-keys.js"].coveredLines = 44;39_yuitest_coverage["build/autocomplete-list-keys/autocomplete-list-keys.js"].coveredFunctions = 12;40_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 1);41YUI.add('autocomplete-list-keys', function (Y, NAME) {42/**43Mixes keyboard support into AutoCompleteList. By default, this module is not44loaded for iOS and Android devices.45@module autocomplete46@submodule autocomplete-list-keys47**/48 // keyCode constants.49_yuitest_coverfunc("build/autocomplete-list-keys/autocomplete-list-keys.js", "(anonymous 1)", 1);50_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 12);51var KEY_DOWN = 40,52 KEY_ENTER = 13,53 KEY_ESC = 27,54 KEY_TAB = 9,55 KEY_UP = 38;56_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 18);57function ListKeys() {58 _yuitest_coverfunc("build/autocomplete-list-keys/autocomplete-list-keys.js", "ListKeys", 18);59_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 19);60Y.before(this._bindKeys, this, 'bindUI');61 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 20);62this._initKeys();63}64_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 23);65ListKeys.prototype = {66 // -- Lifecycle Methods ----------------------------------------------------67 /**68 Initializes keyboard command mappings.69 @method _initKeys70 @protected71 @for AutoCompleteList72 **/73 _initKeys: function () {74 _yuitest_coverfunc("build/autocomplete-list-keys/autocomplete-list-keys.js", "_initKeys", 33);75_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 34);76var keys = {},77 keysVisible = {};78 // Register keyboard command handlers. _keys contains handlers that will79 // always be called; _keysVisible contains handlers that will only be80 // called when the list is visible.81 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 40);82keys[KEY_DOWN] = this._keyDown;83 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 42);84keysVisible[KEY_ENTER] = this._keyEnter;85 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 43);86keysVisible[KEY_ESC] = this._keyEsc;87 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 44);88keysVisible[KEY_TAB] = this._keyTab;89 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 45);90keysVisible[KEY_UP] = this._keyUp;91 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 47);92this._keys = keys;93 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 48);94this._keysVisible = keysVisible;95 },96 destructor: function () {97 _yuitest_coverfunc("build/autocomplete-list-keys/autocomplete-list-keys.js", "destructor", 51);98_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 52);99this._unbindKeys();100 },101 /**102 Binds keyboard events.103 @method _bindKeys104 @protected105 **/106 _bindKeys: function () {107 _yuitest_coverfunc("build/autocomplete-list-keys/autocomplete-list-keys.js", "_bindKeys", 61);108_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 62);109this._keyEvents = this._inputNode.on('keydown', this._onInputKey, this);110 },111 /**112 Unbinds keyboard events.113 @method _unbindKeys114 @protected115 **/116 _unbindKeys: function () {117 _yuitest_coverfunc("build/autocomplete-list-keys/autocomplete-list-keys.js", "_unbindKeys", 71);118_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 72);119this._keyEvents && this._keyEvents.detach();120 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 73);121this._keyEvents = null;122 },123 // -- Protected Methods ----------------------------------------------------124 /**125 Called when the down arrow key is pressed.126 @method _keyDown127 @protected128 **/129 _keyDown: function () {130 _yuitest_coverfunc("build/autocomplete-list-keys/autocomplete-list-keys.js", "_keyDown", 84);131_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 85);132if (this.get('visible')) {133 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 86);134this._activateNextItem();135 } else {136 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 88);137this.show();138 }139 },140 /**141 Called when the enter key is pressed.142 @method _keyEnter143 @protected144 **/145 _keyEnter: function (e) {146 _yuitest_coverfunc("build/autocomplete-list-keys/autocomplete-list-keys.js", "_keyEnter", 98);147_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 99);148var item = this.get('activeItem');149 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 101);150if (item) {151 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 102);152this.selectItem(item, e);153 } else {154 // Don't prevent form submission when there's no active item.155 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 105);156return false;157 }158 },159 /**160 Called when the escape key is pressed.161 @method _keyEsc162 @protected163 **/164 _keyEsc: function () {165 _yuitest_coverfunc("build/autocomplete-list-keys/autocomplete-list-keys.js", "_keyEsc", 115);166_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 116);167this.hide();168 },169 /**170 Called when the tab key is pressed.171 @method _keyTab172 @protected173 **/174 _keyTab: function (e) {175 _yuitest_coverfunc("build/autocomplete-list-keys/autocomplete-list-keys.js", "_keyTab", 125);176_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 126);177var item;178 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 128);179if (this.get('tabSelect')) {180 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 129);181item = this.get('activeItem');182 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 131);183if (item) {184 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 132);185this.selectItem(item, e);186 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 133);187return true;188 }189 }190 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 137);191return false;192 },193 /**194 Called when the up arrow key is pressed.195 @method _keyUp196 @protected197 **/198 _keyUp: function () {199 _yuitest_coverfunc("build/autocomplete-list-keys/autocomplete-list-keys.js", "_keyUp", 146);200_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 147);201this._activatePrevItem();202 },203 // -- Protected Event Handlers ---------------------------------------------204 /**205 Handles `inputNode` key events.206 @method _onInputKey207 @param {EventTarget} e208 @protected209 **/210 _onInputKey: function (e) {211 _yuitest_coverfunc("build/autocomplete-list-keys/autocomplete-list-keys.js", "_onInputKey", 159);212_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 160);213var handler,214 keyCode = e.keyCode;215 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 163);216this._lastInputKey = keyCode;217 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 165);218if (this.get('results').length) {219 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 166);220handler = this._keys[keyCode];221 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 168);222if (!handler && this.get('visible')) {223 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 169);224handler = this._keysVisible[keyCode];225 }226 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 172);227if (handler) {228 // A handler may return false to indicate that it doesn't wish229 // to prevent the default key behavior.230 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 175);231if (handler.call(this, e) !== false) {232 _yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 176);233e.preventDefault();234 }235 }236 }237 }238};239_yuitest_coverline("build/autocomplete-list-keys/autocomplete-list-keys.js", 183);240Y.Base.mix(Y.AutoCompleteList, [ListKeys]);...

Full Screen

Full Screen

boundedcollectablestorage.js

Source:boundedcollectablestorage.js Github

copy

Full Screen

1// Copyright 2013 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.14/**15 * @fileoverview Provides a convenient API for data persistence with data16 * expiration and number of items limit.17 *18 * Setting and removing values keeps a max number of items invariant.19 * Collecting values can be user initiated. If oversize, first removes20 * expired items, if still oversize than removes the oldest items until a size21 * constraint is fulfilled.22 *23 */24goog.provide('goog.labs.storage.BoundedCollectableStorage');25goog.require('goog.array');26goog.require('goog.asserts');27goog.require('goog.iter');28goog.require('goog.storage.CollectableStorage');29goog.require('goog.storage.ErrorCode');30goog.require('goog.storage.ExpiringStorage');31/**32 * Provides a storage with bounded number of elements, expiring keys and33 * a collection method.34 *35 * @param {!goog.storage.mechanism.IterableMechanism} mechanism The underlying36 * storage mechanism.37 * @param {number} maxItems Maximum number of items in storage.38 * @constructor39 * @struct40 * @extends {goog.storage.CollectableStorage}41 * @final42 */43goog.labs.storage.BoundedCollectableStorage = function(mechanism, maxItems) {44 goog.labs.storage.BoundedCollectableStorage.base(45 this, 'constructor', mechanism);46 /**47 * A maximum number of items that should be stored.48 * @private {number}49 */50 this.maxItems_ = maxItems;51};52goog.inherits(53 goog.labs.storage.BoundedCollectableStorage,54 goog.storage.CollectableStorage);55/**56 * An item key used to store a list of keys.57 * @const58 * @private59 */60goog.labs.storage.BoundedCollectableStorage.KEY_LIST_KEY_ =61 'bounded-collectable-storage';62/**63 * Recreates a list of keys in order of creation.64 *65 * @return {!Array<string>} a list of unexpired keys.66 * @private67 */68goog.labs.storage.BoundedCollectableStorage.prototype.rebuildIndex_ =69 function() {70 var keys = [];71 goog.iter.forEach(72 /** @type {goog.storage.mechanism.IterableMechanism} */ (this.mechanism)73 .__iterator__(true),74 function(key) {75 if (goog.labs.storage.BoundedCollectableStorage.KEY_LIST_KEY_ == key) {76 return;77 }78 var wrapper;79 try {80 wrapper = this.getWrapper(key, true);81 } catch (ex) {82 if (ex == goog.storage.ErrorCode.INVALID_VALUE) {83 // Skip over bad wrappers and continue.84 return;85 }86 // Unknown error, escalate.87 throw ex;88 }89 goog.asserts.assert(wrapper);90 var creationTime =91 goog.storage.ExpiringStorage.getCreationTime(wrapper);92 keys.push({key: key, created: creationTime});93 },94 this);95 goog.array.sort(keys, function(a, b) { return a.created - b.created; });96 return goog.array.map(keys, function(v) { return v.key; });97};98/**99 * Gets key list from a local storage. If an item does not exist,100 * may recreate it.101 *102 * @param {boolean} rebuild Whether to rebuild a index if no index item exists.103 * @return {!Array<string>} a list of keys if index exist, otherwise undefined.104 * @private105 */106goog.labs.storage.BoundedCollectableStorage.prototype.getKeys_ = function(107 rebuild) {108 var keys =109 goog.labs.storage.BoundedCollectableStorage.superClass_.get.call(110 this, goog.labs.storage.BoundedCollectableStorage.KEY_LIST_KEY_) ||111 null;112 if (!keys || !goog.isArray(keys)) {113 if (rebuild) {114 keys = this.rebuildIndex_();115 } else {116 keys = [];117 }118 }119 return /** @type {!Array<string>} */ (keys);120};121/**122 * Saves a list of keys in a local storage.123 *124 * @param {Array<string>} keys a list of keys to save.125 * @private126 */127goog.labs.storage.BoundedCollectableStorage.prototype.setKeys_ = function(128 keys) {129 goog.labs.storage.BoundedCollectableStorage.superClass_.set.call(130 this, goog.labs.storage.BoundedCollectableStorage.KEY_LIST_KEY_, keys);131};132/**133 * Remove subsequence from a sequence.134 *135 * @param {!Array<string>} keys is a sequence.136 * @param {!Array<string>} keysToRemove subsequence of keys, the order must137 * be kept.138 * @return {!Array<string>} a keys sequence after removing keysToRemove.139 * @private140 */141goog.labs.storage.BoundedCollectableStorage.removeSubsequence_ = function(142 keys, keysToRemove) {143 if (keysToRemove.length == 0) {144 return goog.array.clone(keys);145 }146 var keysToKeep = [];147 var keysIdx = 0;148 var keysToRemoveIdx = 0;149 while (keysToRemoveIdx < keysToRemove.length && keysIdx < keys.length) {150 var key = keysToRemove[keysToRemoveIdx];151 while (keysIdx < keys.length && keys[keysIdx] != key) {152 keysToKeep.push(keys[keysIdx]);153 ++keysIdx;154 }155 ++keysToRemoveIdx;156 }157 goog.asserts.assert(keysToRemoveIdx == keysToRemove.length);158 goog.asserts.assert(keysIdx < keys.length);159 return goog.array.concat(keysToKeep, goog.array.slice(keys, keysIdx + 1));160};161/**162 * Keeps the number of items in storage under maxItems. Removes elements in the163 * order of creation.164 *165 * @param {!Array<string>} keys a list of keys in order of creation.166 * @param {number} maxSize a number of items to keep.167 * @return {!Array<string>} keys left after removing oversize data.168 * @private169 */170goog.labs.storage.BoundedCollectableStorage.prototype.collectOversize_ =171 function(keys, maxSize) {172 if (keys.length <= maxSize) {173 return goog.array.clone(keys);174 }175 var keysToRemove = goog.array.slice(keys, 0, keys.length - maxSize);176 goog.array.forEach(keysToRemove, function(key) {177 goog.labs.storage.BoundedCollectableStorage.superClass_.remove.call(178 this, key);179 }, this);180 return goog.labs.storage.BoundedCollectableStorage.removeSubsequence_(181 keys, keysToRemove);182};183/**184 * Cleans up the storage by removing expired keys.185 *186 * @param {boolean=} opt_strict Also remove invalid keys.187 * @override188 */189goog.labs.storage.BoundedCollectableStorage.prototype.collect = function(190 opt_strict) {191 var keys = this.getKeys_(true);192 var keysToRemove = this.collectInternal(keys, opt_strict);193 keys = goog.labs.storage.BoundedCollectableStorage.removeSubsequence_(194 keys, keysToRemove);195 this.setKeys_(keys);196};197/**198 * Ensures that we keep only maxItems number of items in a local storage.199 * @param {boolean=} opt_skipExpired skip removing expired items first.200 * @param {boolean=} opt_strict Also remove invalid keys.201 */202goog.labs.storage.BoundedCollectableStorage.prototype.collectOversize =203 function(opt_skipExpired, opt_strict) {204 var keys = this.getKeys_(true);205 if (!opt_skipExpired) {206 var keysToRemove = this.collectInternal(keys, opt_strict);207 keys = goog.labs.storage.BoundedCollectableStorage.removeSubsequence_(208 keys, keysToRemove);209 }210 keys = this.collectOversize_(keys, this.maxItems_);211 this.setKeys_(keys);212};213/**214 * Set an item in the storage.215 *216 * @param {string} key The key to set.217 * @param {*} value The value to serialize to a string and save.218 * @param {number=} opt_expiration The number of miliseconds since epoch219 * (as in goog.now()) when the value is to expire. If the expiration220 * time is not provided, the value will persist as long as possible.221 * @override222 */223goog.labs.storage.BoundedCollectableStorage.prototype.set = function(224 key, value, opt_expiration) {225 goog.labs.storage.BoundedCollectableStorage.base(226 this, 'set', key, value, opt_expiration);227 var keys = this.getKeys_(true);228 goog.array.remove(keys, key);229 if (goog.isDef(value)) {230 keys.push(key);231 if (keys.length >= this.maxItems_) {232 var keysToRemove = this.collectInternal(keys);233 keys = goog.labs.storage.BoundedCollectableStorage.removeSubsequence_(234 keys, keysToRemove);235 keys = this.collectOversize_(keys, this.maxItems_);236 }237 }238 this.setKeys_(keys);239};240/**241 * Remove an item from the data storage.242 *243 * @param {string} key The key to remove.244 * @override245 */246goog.labs.storage.BoundedCollectableStorage.prototype.remove = function(key) {247 goog.labs.storage.BoundedCollectableStorage.base(this, 'remove', key);248 var keys = this.getKeys_(false);249 if (goog.isDef(keys)) {250 goog.array.remove(keys, key);251 this.setKeys_(keys);252 }...

Full Screen

Full Screen

keycode.js

Source:keycode.js Github

copy

Full Screen

1/**2 * Enumerates the supported keys.3 * NOTE: The maps represents physical keys on the keyboard, not chars.4 * @readonly5 * @enum {string}6 */7export const KEYS = {8 BACKSPACE: 'backspace',9 DELETE: 'delete',10 RETURN: 'enter',11 TAB: 'tab',12 ESCAPE: 'escape',13 UP: 'up',14 DOWN: 'down',15 RIGHT: 'right',16 LEFT: 'left',17 HOME: 'home',18 END: 'end',19 PAGEUP: 'pageup',20 PAGEDOWN: 'pagedown',21 F1: 'f1',22 F2: 'f2',23 F3: 'f3',24 F4: 'f4',25 F5: 'f5',26 F6: 'f6',27 F7: 'f7',28 F8: 'f8',29 F9: 'f9',30 F10: 'f10',31 F11: 'f11',32 F12: 'f12',33 META: 'command',34 CMD_L: 'command',35 CMD_R: 'command',36 ALT: 'alt',37 CONTROL: 'control',38 SHIFT: 'shift',39 CAPS_LOCK: 'caps_lock', // not supported by robotjs40 SPACE: 'space',41 PRINTSCREEN: 'printscreen',42 INSERT: 'insert',43 NUMPAD_0: 'numpad_0',44 NUMPAD_1: 'numpad_1',45 NUMPAD_2: 'numpad_2',46 NUMPAD_3: 'numpad_3',47 NUMPAD_4: 'numpad_4',48 NUMPAD_5: 'numpad_5',49 NUMPAD_6: 'numpad_6',50 NUMPAD_7: 'numpad_7',51 NUMPAD_8: 'numpad_8',52 NUMPAD_9: 'numpad_9',53 COMMA: ',',54 PERIOD: '.',55 SEMICOLON: ';',56 QUOTE: '\'',57 BRACKET_LEFT: '[',58 BRACKET_RIGHT: ']',59 BACKQUOTE: '`',60 BACKSLASH: '\\',61 MINUS: '-',62 EQUAL: '=',63 SLASH: '/'64};65/* eslint-disable max-len */66/**67 * Mapping between the key codes and keys deined in KEYS.68 * The mappings are based on69 * https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode#Specifications70 */71/* eslint-enable max-len */72const keyCodeToKey = {73 8: KEYS.BACKSPACE,74 9: KEYS.TAB,75 13: KEYS.RETURN,76 16: KEYS.SHIFT,77 17: KEYS.CONTROL,78 18: KEYS.ALT,79 20: KEYS.CAPS_LOCK,80 27: KEYS.ESCAPE,81 32: KEYS.SPACE,82 33: KEYS.PAGEUP,83 34: KEYS.PAGEDOWN,84 35: KEYS.END,85 36: KEYS.HOME,86 37: KEYS.LEFT,87 38: KEYS.UP,88 39: KEYS.RIGHT,89 40: KEYS.DOWN,90 42: KEYS.PRINTSCREEN,91 44: KEYS.PRINTSCREEN,92 45: KEYS.INSERT,93 46: KEYS.DELETE,94 59: KEYS.SEMICOLON,95 61: KEYS.EQUAL,96 91: KEYS.CMD_L,97 92: KEYS.CMD_R,98 93: KEYS.CMD_R,99 96: KEYS.NUMPAD_0,100 97: KEYS.NUMPAD_1,101 98: KEYS.NUMPAD_2,102 99: KEYS.NUMPAD_3,103 100: KEYS.NUMPAD_4,104 101: KEYS.NUMPAD_5,105 102: KEYS.NUMPAD_6,106 103: KEYS.NUMPAD_7,107 104: KEYS.NUMPAD_8,108 105: KEYS.NUMPAD_9,109 112: KEYS.F1,110 113: KEYS.F2,111 114: KEYS.F3,112 115: KEYS.F4,113 116: KEYS.F5,114 117: KEYS.F6,115 118: KEYS.F7,116 119: KEYS.F8,117 120: KEYS.F9,118 121: KEYS.F10,119 122: KEYS.F11,120 123: KEYS.F12,121 124: KEYS.PRINTSCREEN,122 173: KEYS.MINUS,123 186: KEYS.SEMICOLON,124 187: KEYS.EQUAL,125 188: KEYS.COMMA,126 189: KEYS.MINUS,127 190: KEYS.PERIOD,128 191: KEYS.SLASH,129 192: KEYS.BACKQUOTE,130 219: KEYS.BRACKET_LEFT,131 220: KEYS.BACKSLASH,132 221: KEYS.BRACKET_RIGHT,133 222: KEYS.QUOTE,134 224: KEYS.META,135 229: KEYS.SEMICOLON136};137/**138 * Generate codes for digit keys (0-9)139 */140for (let i = 0; i < 10; i++) {141 keyCodeToKey[i + 48] = `${i}`;142}143/**144 * Generate codes for letter keys (a-z)145 */146for (let i = 0; i < 26; i++) {147 const keyCode = i + 65;148 keyCodeToKey[keyCode] = String.fromCharCode(keyCode).toLowerCase();149}150/**151 * Returns key associated with the keyCode from the passed event.152 * @param {KeyboardEvent} event the event153 * @returns {KEYS} the key on the keyboard.154 */155export function keyboardEventToKey(event) {156 return keyCodeToKey[event.which];...

Full Screen

Full Screen

own-property-keys-sort.js

Source:own-property-keys-sort.js Github

copy

Full Screen

1// |reftest| module2// Copyright (C) 2016 the V8 project authors. All rights reserved.3// This code is governed by the BSD license found in the LICENSE file.4/*---5esid: sec-module-namespace-exotic-objects-ownpropertykeys6description: >7 The [[OwnPropertyKeys]] internal method reflects the sorted order8info: |9 1. Let exports be a copy of the value of O's [[Exports]] internal slot.10 2. Let symbolKeys be ! OrdinaryOwnPropertyKeys(O).11 3. Append all the entries of symbolKeys to the end of exports.12 4. Return exports.13flags: [module]14features: [Reflect, Symbol.toStringTag]15---*/16var x;17export { x as π }; // u03c018export { x as az };19export { x as __ };20export { x as za };21export { x as Z };22export { x as \u03bc };23export { x as z };24export { x as zz };25export { x as a };26export { x as A };27export { x as aa };28export { x as λ }; // u03bb29export { x as _ };30export { x as $$ };31export { x as $ };32export default null;33import * as ns from './own-property-keys-sort.js';34var stringKeys = Object.getOwnPropertyNames(ns);35assert.sameValue(stringKeys.length, 16);36assert.sameValue(stringKeys[0], '$', 'stringKeys[0] === "$"');37assert.sameValue(stringKeys[1], '$$', 'stringKeys[1] === "$$"');38assert.sameValue(stringKeys[2], 'A', 'stringKeys[2] === "A"');39assert.sameValue(stringKeys[3], 'Z', 'stringKeys[3] === "Z"');40assert.sameValue(stringKeys[4], '_', 'stringKeys[4] === "_"');41assert.sameValue(stringKeys[5], '__', 'stringKeys[5] === "__"');42assert.sameValue(stringKeys[6], 'a', 'stringKeys[6] === "a"');43assert.sameValue(stringKeys[7], 'aa', 'stringKeys[7] === "aa"');44assert.sameValue(stringKeys[8], 'az', 'stringKeys[8] === "az"');45assert.sameValue(stringKeys[9], 'default', 'stringKeys[9] === "default"');46assert.sameValue(stringKeys[10], 'z', 'stringKeys[10] === "z"');47assert.sameValue(stringKeys[11], 'za', 'stringKeys[11] === "za"');48assert.sameValue(stringKeys[12], 'zz', 'stringKeys[12] === "zz"');49assert.sameValue(stringKeys[13], '\u03bb', 'stringKeys[13] === "\u03bb"');50assert.sameValue(stringKeys[14], '\u03bc', 'stringKeys[14] === "\u03bc"');51assert.sameValue(stringKeys[15], '\u03c0', 'stringKeys[15] === "\u03c0"');52var allKeys = Reflect.ownKeys(ns);53assert(54 allKeys.length >= 17,55 'at least as many keys as defined by the module and the specification'56);57assert.sameValue(allKeys[0], '$', 'allKeys[0] === "$"');58assert.sameValue(allKeys[1], '$$', 'allKeys[1] === "$$"');59assert.sameValue(allKeys[2], 'A', 'allKeys[2] === "A"');60assert.sameValue(allKeys[3], 'Z', 'allKeys[3] === "Z"');61assert.sameValue(allKeys[4], '_', 'allKeys[4] === "_"');62assert.sameValue(allKeys[5], '__', 'allKeys[5] === "__"');63assert.sameValue(allKeys[6], 'a', 'allKeys[6] === "a"');64assert.sameValue(allKeys[7], 'aa', 'allKeys[7] === "aa"');65assert.sameValue(allKeys[8], 'az', 'allKeys[8] === "az"');66assert.sameValue(allKeys[9], 'default', 'allKeys[9] === "default"');67assert.sameValue(allKeys[10], 'z', 'allKeys[10] === "z"');68assert.sameValue(allKeys[11], 'za', 'allKeys[11] === "za"');69assert.sameValue(allKeys[12], 'zz', 'allKeys[12] === "zz"');70assert.sameValue(allKeys[13], '\u03bb', 'allKeys[13] === "\u03bb"');71assert.sameValue(allKeys[14], '\u03bc', 'allKeys[14] === "\u03bc"');72assert.sameValue(allKeys[15], '\u03c0', 'allKeys[15] === "\u03c0"');73assert(74 allKeys.indexOf(Symbol.toStringTag) > 15,75 'keys array includes Symbol.toStringTag'76);...

Full Screen

Full Screen

keyboard.js

Source:keyboard.js Github

copy

Full Screen

1(function () {2horde.Keyboard = function () {3 this.history = [];4 this.keyStates = {};5 this.lastKeyStates = {};6 horde.on("keydown", this.handleKeyDown, window, this);7 horde.on("keyup", this.handleKeyUp, window, this);8};9var Keyboard = horde.Keyboard;10var proto = Keyboard.prototype;11var Keys = {12 ESCAPE: 27,13 ENTER: 13,14 SPACE: 32,15 LEFT: 37,16 UP: 38,17 RIGHT: 39,18 DOWN: 40,19 A: 65,20 B: 66,21 D: 68,22 E: 69,23 F: 70,24 G: 71,25 K: 75,26 L: 76,27 M: 77,28 O: 79,29 P: 80,30 Q: 81,31 R: 82,32 S: 83,33 T: 84,34 U: 85,35 W: 87,36 X: 88,37 Z: 9038};39Keyboard.Keys = Keys;40Keyboard.konamiCode = [41 Keys.UP,42 Keys.UP,43 Keys.DOWN,44 Keys.DOWN,45 Keys.LEFT,46 Keys.RIGHT,47 Keys.LEFT,48 Keys.RIGHT,49 Keys.B,50 Keys.A51];52Keyboard.debugCode = [53 Keys.L,54 Keys.D,55 Keys.D,56 Keys.E,57 Keys.B,58 Keys.U,59 Keys.G60];61Keyboard.resetCode = [62 Keys.L,63 Keys.D,64 Keys.R,65 Keys.E,66 Keys.S,67 Keys.E,68 Keys.T69];70Keyboard.godModeCode = [71 Keys.L,72 Keys.D,73 Keys.D,74 Keys.Q,75 Keys.D76];77Keyboard.allWeaponsCode = [78 Keys.L,79 Keys.D,80 Keys.K,81 Keys.F,82 Keys.A83];84Keyboard.awesmCode = [85 Keys.A,86 Keys.W,87 Keys.E,88 Keys.S,89 Keys.M90];91Keyboard.bombCode = [92 Keys.L,93 Keys.D,94 Keys.B,95 Keys.O,96 Keys.M,97 Keys.B98];99Keyboard.cyclopsCode = [100 67, // C101 89, // Y102 67, // C103 Keys.L,104 Keys.O,105 Keys.P,106 Keys.S107];108Keyboard.html5Code = [109 72,110 84,111 77,112 76,113 53114];115Keyboard.meatboyCode = [116 Keys.M,117 Keys.E,118 Keys.A,119 Keys.T120];121proto.supressKeys = function (e) {122 switch (e.keyCode) {123 // Note: intentional fallthroughs.124 case Keys.ENTER:125 case Keys.LEFT:126 case Keys.UP:127 case Keys.RIGHT:128 case Keys.DOWN:129 case Keys.B:130 case Keys.A:131 case Keys.M:132 case Keys.Z:133 case Keys.X:134 case Keys.P:135 case Keys.SPACE:136 case Keys.W:137 case Keys.S:138 case Keys.D:139 case 191: // The "/" key to prevent searching in Firefox (#125)140 horde.stopEvent(e);141 break;142 }143};144proto.handleKeyDown = function (e) {145 this.history.push(e.keyCode);146 this.keyStates[e.keyCode] = true;147 this.supressKeys(e);148};149proto.handleKeyUp = function (e) {150 this.keyStates[e.keyCode] = false;151 this.supressKeys(e);152};153proto.isKeyDown = function (keyCode) {154 return (this.keyStates[keyCode] === true);155};156proto.isKeyPressed = function (keyCode) {157 return (this.isKeyDown(keyCode) && this.lastKeyStates[keyCode] !== true);158};159proto.isAnyKeyPressed = function (keyCode) {160 for (var keyCode in this.keyStates) {161 if (this.isKeyDown(keyCode) && this.lastKeyStates[keyCode] !== true) {162 return true;163 }164 }165 return false;166};167proto.clearKey = function (keyCode) {168 this.keyStates[keyCode] = false;169};170proto.clearKeys = function (keyCode) {171 this.keyStates = {};172};173proto.clearHistory = function () {174 this.history = [];175};176proto.historyMatch = function (keys) {177 var len = keys.length;178 var toCheck = this.history.slice(-len);179 if (toCheck.length !== len) {180 return false;181 }182 for (var x = 0; x < len; x++) {183 if (keys[x] !== toCheck[x]) {184 return false; 185 }186 }187 return true;188};189proto.storeKeyStates = function () {190 for (var keyCode in this.keyStates) {191 this.lastKeyStates[keyCode] = this.keyStates[keyCode];192 }193};194 ...

Full Screen

Full Screen

Keys.js

Source:Keys.js Github

copy

Full Screen

1import React, { useContext, useEffect, useState } from 'react';2import { useHistory } from 'react-router';3import Add from '@material-ui/icons/Add';4import LanguageContext from '../../context/LanguageContext';5import { getKeys, getUserKeys } from '../../utils/api/get';6import KeyList from '../components/lists/KeyList';7import KeyFilter from '../components/inputs/KeyFilter';8import UserContext from '../../context/UserContext';9import MissingPermission from '../components/MissingPermission';10import isPermitted from '../../utils/is-permitted';11import ActionButton from '../components/buttons/ActionButton';12/**13 * Render keys page14 */15const Keys = ({ onSetTitle }) => {16 const { language } = useContext(LanguageContext);17 const { user } = useContext(UserContext);18 const history = useHistory();19 const [keys, setKeys] = useState(undefined);20 const [filterKeys, setFilterKeys] = useState({ keys: 'ALLKEYS', language: language.language.split('_')[0] });21 const [error, setError] = useState(undefined);22 /**23 * Respond to filter changes24 */25 useEffect(() => {26 if (!keys) {27 onSetTitle(language.dictionary.keys);28 getKeys(filterKeys.language !== 'all' ? filterKeys.language : undefined).then((keyList) => {29 setKeys(keyList);30 setError(undefined);31 }).catch(() => setError(language.dictionary.internalAPIError));32 } else if (filterKeys.keys === 'ALLKEYS') {33 getKeys(filterKeys.language !== 'all' ? filterKeys.language : undefined).then((keyList) => {34 setKeys(keyList);35 setError(undefined);36 }).catch(() => setError(language.dictionary.internalAPIError));37 } else {38 getUserKeys(filterKeys.language !== 'all' ? filterKeys.language : undefined).then((userKeys) => {39 setKeys(userKeys);40 setError(undefined);41 }).catch(() => setError(language.dictionary.internalAPIError));42 }43 }, [filterKeys, language]);44 return (45 <div className="py-14 md:w-10/12 m-auto pb-28">46 <p className="px-2 mt-20 lg:mt-6">{language.dictionary.sectionKeys}</p>47 <ActionButton48 label={language.dictionary.btnNewKey}49 icon={<Add />}50 onClick={() => history.push('/create')}51 disabled={!isPermitted(user, ['CREATE_KEY'])}52 />53 <MissingPermission54 show={!isPermitted(user, ['CREATE_KEY'])}55 label={language.dictionary.notCreateKey}56 />57 <KeyFilter58 filter={filterKeys}59 onChangeFilter={(val) => setFilterKeys(val)}60 />61 {keys && keys.length > 062 && (63 <KeyList64 keys={keys}65 onClickListItem={(key) => history.push(`keys/${key.id}`)}66 error={error}67 />68 )}69 </div>70 );71};...

Full Screen

Full Screen

15.2.3.14-01.js

Source:15.2.3.14-01.js Github

copy

Full Screen

...3 * http://creativecommons.org/licenses/publicdomain/4 */5//-----------------------------------------------------------------------------6var BUGNUMBER = 307791;7var summary = 'ES5 Object.keys(O)';8var actual = '';9var expect = '';10printBugNumber(BUGNUMBER);11printStatus(summary);12function arraysEqual(a1, a2)13{14 return a1.length === a2.length &&15 a1.every(function(v, i) { return v === a2[i]; });16}17/**************18 * BEGIN TEST *19 **************/20assertEq(Object.keys.length, 1);21var o, keys;22o = { a: 3, b: 2 };23keys = Object.keys(o);24assertEq(arraysEqual(keys, ["a", "b"]), true,25 "" + keys);26o = { get a() { return 17; }, b: 2 };27keys = Object.keys(o),28assertEq(arraysEqual(keys, ["a", "b"]), true,29 "" + keys);30o = { __iterator__: function() { return Iterator({a: 2, b: 3}); } };31keys = Object.keys(o);32assertEq(arraysEqual(keys, ["__iterator__"]), true,33 "" + keys);34o = { a: 1, b: 2 };35delete o.a;36o.a = 3;37keys = Object.keys(o);38assertEq(arraysEqual(keys, ["b", "a"]), true,39 "" + keys);40o = [0, 1, 2];41keys = Object.keys(o);42assertEq(arraysEqual(keys, ["0", "1", "2"]), true,43 "" + keys);44o = /./.exec("abc");45keys = Object.keys(o);46assertEq(arraysEqual(keys, ["0", "index", "input"]), true,47 "" + keys);48o = { a: 1, b: 2, c: 3 };49delete o.b;50o.b = 5;51keys = Object.keys(o);52assertEq(arraysEqual(keys, ["a", "c", "b"]), true,53 "" + keys);54function f() { }55f.prototype.p = 1;56o = new f();57o.g = 1;58keys = Object.keys(o);59assertEq(arraysEqual(keys, ["g"]), true,60 "" + keys);61if (typeof Namespace !== "undefined" && typeof QName !== "undefined")62{63 var o2 = {};64 var qn = new QName(new Namespace("foo"), "v");65 o2.f = 1;66 o2[qn] = 3;67 o2.baz = 4;68 var keys2 = Object.keys(o2);69 assertEq(arraysEqual(keys2, ["f", "foo::v", "baz"]), true,70 "" + keys2);71}72/******************************************************************************/73reportCompare(expect, actual, "Object.keys");...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParent = require('stryker-parent');2console.log(strykerParent.keys);3const strykerParent = require('stryker-parent');4console.log(strykerParent.keys);5const strykerParent = require('stryker-parent');6console.log(strykerParent.keys);7const strykerParent = require('stryker-parent');8console.log(strykerParent.keys);9const strykerParent = require('stryker-parent');10console.log(strykerParent.keys);11const strykerParent = require('stryker-parent');12console.log(strykerParent.keys);13const strykerParent = require('stryker-parent');14console.log(strykerParent.keys);15const strykerParent = require('stryker-parent');16console.log(strykerParent.keys);17const strykerParent = require('stryker-parent');18console.log(strykerParent.keys);19const strykerParent = require('stryker-parent');20console.log(strykerParent.keys);21const strykerParent = require('stryker-parent');22console.log(strykerParent.keys);23const strykerParent = require('stryker-parent');24console.log(strykerParent.keys);25const strykerParent = require('stryker-parent');26console.log(strykerParent.keys);

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParent = require('stryker-parent');2console.log(strykerParent.keys);3const strykerParent = require('stryker-parent');4console.log(strykerParent.keys);5const strykerParent = require('stryker-parent');6console.log(strykerParent.keys);7const strykerParent = require('stryker-parent');8console.log(strykerParent.keys);9const strykerParent = require('stryker-parent');10console.log(strykerParent.keys);11const strykerParent = require('stryker-parent');12console.log(strykerParent.keys);13const strykerParent = require('stryker-parent');14console.log(strykerParent.keys);15const strykerParent = require('stryker-parent');16console.log(strykerParent.keys);17const strykerParent = require('stryker-parent');18console.log(strykerParent.keys);19const strykerParent = require('stryker-parent');20console.log(strykerParent.keys);21const strykerParent = require('stryker-parent');22console.log(strykerParent.keys);23const strykerParent = require('stryker-parent');24console.log(strykerParent.keys);25const strykerParent = require('stryker-parent');26console.log(strykerParent.keys);27const strykerParent = require('stryker-parent');28console.log(strykerParent.keys);29const strykerParent = require('stry

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParent = require('stryker-parent');2const strykerParentKeys = strykerParent.keys;3const strykerParentKeysResult = strykerParentKeys();4console.log("strykerParentKeysResult: ", strykerParentKeysResult);5const strykerParent = require('stryker-parent');6const strykerParentKeys = strykerParent.keys;7const strykerParentKeysResult = strykerParentKeys();8console.log("strykerParentKeysResult: ", strykerParentKeysResult);9const strykerParent = require('stryker-parent');10const strykerParentKeys = strykerParent.keys;11const strykerParentKeysResult = strykerParentKeys();12console.log("strykerParentKeysResult: ", strykerParentKeysResult);13const strykerParent = require('stryker-parent');14const strykerParentKeys = strykerParent.keys;15const strykerParentKeysResult = strykerParentKeys();16console.log("strykerParentKeysResult: ", strykerParentKeysResult);17const strykerParent = require('stryker-parent');18const strykerParentKeys = strykerParent.keys;19const strykerParentKeysResult = strykerParentKeys();20console.log("strykerParentKeysResult: ", strykerParentKeysResult);21const strykerParent = require('stryker-parent');22const strykerParentKeys = strykerParent.keys;23const strykerParentKeysResult = strykerParentKeys();24console.log("strykerParentKeysResult: ", strykerParentKeysResult);25const strykerParent = require('stryker-parent');26const strykerParentKeys = strykerParent.keys;27const strykerParentKeysResult = strykerParentKeys();28console.log("strykerParentKeysResult: ", strykerParentKeysResult);29const strykerParent = require('stryker-parent');

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2console.log(Object.keys(strykerParent));3function getLocation() {4 if (navigator.geolocation) {5 navigator.geolocation.getCurrentPosition(showPosition);6 } else { 7 x.innerHTML = "Geolocation is not supported by this browser.";8 }9}10function showPosition(position) {11 "<br>Longitude: " + position.coords.longitude;12}13When I run this code on my localhost, I get the expected result. However, when I run it on my server (using the same code), I get the following error:14navigator.geolocation.watchPosition(function(position) {15 console.log(position);16});17navigator.geolocation.getCurrentPosition(function(position) {18 console.log(position);19});20navigator.geolocation.getCurrentPosition(function(position) {21 console.log(position);22}, function(error) {23 console.log(error);24});25navigator.geolocation.getCurrentPosition(function(position) {26 console.log(position);27}, function(error) {28 console.log(error);29}, {timeout: 60000});30navigator.geolocation.getCurrentPosition(function(position) {31 console.log(position);32}, function(error)

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 stryker-parent 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