Show More
@@ -475,6 +475,140 b' casper.notebook_test(function () {' | |||||
475 | this.test.assert(test_results==captured, "Red image data displayed correctly."); |
|
475 | this.test.assert(test_results==captured, "Red image data displayed correctly."); | |
476 | }); |
|
476 | }); | |
477 |
|
477 | |||
|
478 | // Test int range widget ///////////////////////////////////////////////// | |||
|
479 | var int_text_query = '.widget-area .widget-subarea .widget-hbox-single .my-second-num-test-text'; | |||
|
480 | ||||
|
481 | var intrange_index = this.append_cell( | |||
|
482 | 'intrange = widgets.IntRangeWidget()\n' + | |||
|
483 | 'display(intrange, view_name="IntTextView")\n' + | |||
|
484 | 'intrange.add_class("my-second-num-test-text")\n' + | |||
|
485 | 'display(intrange)\n' + | |||
|
486 | 'print("Success")\n'); | |||
|
487 | this.execute_cell_then(intrange_index, function(index){ | |||
|
488 | ||||
|
489 | this.test.assert(this.get_output_cell(index).text == 'Success\n', | |||
|
490 | 'Create int range cell executed with correct output.'); | |||
|
491 | ||||
|
492 | this.test.assert(this.cell_element_exists(index, | |||
|
493 | '.widget-area .widget-subarea'), | |||
|
494 | 'Widget subarea exists.'); | |||
|
495 | ||||
|
496 | this.test.assert(this.cell_element_exists(index, slider_query), | |||
|
497 | 'Widget slider exists.'); | |||
|
498 | ||||
|
499 | this.test.assert(this.cell_element_exists(index, int_text_query), | |||
|
500 | 'Widget int textbox exists.'); | |||
|
501 | }); | |||
|
502 | ||||
|
503 | index = this.append_cell( | |||
|
504 | 'intrange.max = 50\n' + | |||
|
505 | 'intrange.min = -50\n' + | |||
|
506 | 'intrange.value = 25\n' + | |||
|
507 | 'print("Success")\n'); | |||
|
508 | this.execute_cell_then(index, function(index){ | |||
|
509 | ||||
|
510 | this.test.assert(this.get_output_cell(index).text == 'Success\n', | |||
|
511 | 'Int range properties cell executed with correct output.'); | |||
|
512 | ||||
|
513 | this.test.assert(this.cell_element_exists(intrange_index, slider_query), | |||
|
514 | 'Widget slider exists.'); | |||
|
515 | ||||
|
516 | this.test.assert(this.cell_element_function(intrange_index, slider_query, | |||
|
517 | 'slider', ['value']) == 25, | |||
|
518 | 'Slider set to Python value.'); | |||
|
519 | ||||
|
520 | this.test.assert(this.cell_element_function(intrange_index, int_text_query, | |||
|
521 | 'val') == 25, 'Int textbox set to Python value.'); | |||
|
522 | ||||
|
523 | // Clear the int textbox value and then set it to 1 by emulating | |||
|
524 | // keyboard presses. | |||
|
525 | this.cell_element_function(intrange_index, int_text_query, 'val', ['']); | |||
|
526 | this.sendKeys(int_text_query, '1'); | |||
|
527 | }); | |||
|
528 | ||||
|
529 | this.wait(500); // Wait for change to execute in kernel | |||
|
530 | ||||
|
531 | index = this.append_cell('print(intrange.value)\n'); | |||
|
532 | this.execute_cell_then(index, function(index){ | |||
|
533 | this.test.assert(this.get_output_cell(index).text == '1\n', | |||
|
534 | 'Int textbox set int range value'); | |||
|
535 | ||||
|
536 | // Clear the int textbox value and then set it to 120 by emulating | |||
|
537 | // keyboard presses. | |||
|
538 | this.cell_element_function(intrange_index, int_text_query, 'val', ['']); | |||
|
539 | this.sendKeys(int_text_query, '120'); | |||
|
540 | }); | |||
|
541 | ||||
|
542 | this.wait(500); // Wait for change to execute in kernel | |||
|
543 | ||||
|
544 | index = this.append_cell('print(intrange.value)\n'); | |||
|
545 | this.execute_cell_then(index, function(index){ | |||
|
546 | this.test.assert(this.get_output_cell(index).text == '50\n', | |||
|
547 | 'Int textbox value bound'); | |||
|
548 | ||||
|
549 | // Clear the int textbox value and then set it to 'hello world' by | |||
|
550 | // emulating keyboard presses. 'hello world' should get filtered... | |||
|
551 | this.cell_element_function(intrange_index, int_text_query, 'val', ['']); | |||
|
552 | this.sendKeys(int_text_query, 'hello world'); | |||
|
553 | }); | |||
|
554 | ||||
|
555 | this.wait(500); // Wait for change to execute in kernel | |||
|
556 | ||||
|
557 | index = this.append_cell('print(intrange.value)\n'); | |||
|
558 | this.execute_cell_then(index, function(index){ | |||
|
559 | this.test.assert(this.get_output_cell(index).text == '50\n', | |||
|
560 | 'Invalid int textbox characters ignored'); | |||
478 | }); |
|
561 | }); | |
479 |
|
562 | |||
|
563 | // Test int widget /////////////////////////////////////////////////////// | |||
|
564 | var int_text_query_2 = '.widget-area .widget-subarea .widget-hbox-single .my-second-int-text'; | |||
|
565 | ||||
|
566 | var int_index = this.append_cell( | |||
|
567 | 'int_widget = widgets.IntWidget()\n' + | |||
|
568 | 'display(int_widget)\n' + | |||
|
569 | 'int_widget.add_class("my-second-int-text")\n' + | |||
|
570 | 'print("Success")\n'); | |||
|
571 | this.execute_cell_then(int_index, function(index){ | |||
|
572 | ||||
|
573 | this.test.assert(this.get_output_cell(index).text == 'Success\n', | |||
|
574 | 'Create int cell executed with correct output.'); | |||
|
575 | ||||
|
576 | this.test.assert(this.cell_element_exists(index, | |||
|
577 | '.widget-area .widget-subarea'), | |||
|
578 | 'Widget subarea exists.'); | |||
|
579 | ||||
|
580 | this.test.assert(this.cell_element_exists(index, int_text_query_2), | |||
|
581 | 'Widget int textbox exists.'); | |||
480 |
|
582 | |||
|
583 | this.cell_element_function(int_index, int_text_query_2, 'val', ['']); | |||
|
584 | this.sendKeys(int_text_query_2, '1.05'); | |||
|
585 | }); | |||
|
586 | ||||
|
587 | this.wait(500); // Wait for change to execute in kernel | |||
|
588 | ||||
|
589 | index = this.append_cell('print(int_widget.value)\n'); | |||
|
590 | this.execute_cell_then(index, function(index){ | |||
|
591 | this.test.assert(this.get_output_cell(index).text == '1\n', | |||
|
592 | 'Int textbox value set.'); | |||
|
593 | this.cell_element_function(int_index, int_text_query_2, 'val', ['']); | |||
|
594 | this.sendKeys(int_text_query_2, '123456789'); | |||
|
595 | }); | |||
|
596 | ||||
|
597 | this.wait(500); // Wait for change to execute in kernel | |||
|
598 | ||||
|
599 | index = this.append_cell('print(int_widget.value)\n'); | |||
|
600 | this.execute_cell_then(index, function(index){ | |||
|
601 | this.test.assert(this.get_output_cell(index).text == '123456789\n', | |||
|
602 | 'Long int textbox value set (probably triggers throttling).'); | |||
|
603 | this.cell_element_function(int_index, int_text_query_2, 'val', ['']); | |||
|
604 | this.sendKeys(int_text_query_2, '12hello'); | |||
|
605 | }); | |||
|
606 | ||||
|
607 | this.wait(500); // Wait for change to execute in kernel | |||
|
608 | ||||
|
609 | index = this.append_cell('print(int_widget.value)\n'); | |||
|
610 | this.execute_cell_then(index, function(index){ | |||
|
611 | this.test.assert(this.get_output_cell(index).text == '12\n', | |||
|
612 | 'Invald int textbox value caught and filtered.'); | |||
|
613 | }); | |||
|
614 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now