##// END OF EJS Templates
Added throttling test
Jonathan Frederic -
Show More
@@ -77,7 +77,6 b' casper.notebook_test(function () {'
77 }
77 }
78 });
78 });
79
79
80
81 // Test bool widget ////////////////////////////////////////////////////////
80 // Test bool widget ////////////////////////////////////////////////////////
82 var bool_index = this.append_cell(
81 var bool_index = this.append_cell(
83 'bool_widget = widgets.BoolWidget(description="Title", value=True)\n' +
82 'bool_widget = widgets.BoolWidget(description="Title", value=True)\n' +
@@ -882,4 +881,54 b' casper.notebook_test(function () {'
882 '.widget-area .widget-subarea div span.MathJax_Preview'),
881 '.widget-area .widget-subarea div span.MathJax_Preview'),
883 'MathJax parsed the LaTeX successfully.');
882 'MathJax parsed the LaTeX successfully.');
884 });
883 });
884
885 // Test throttling /////////////////////////////////////////////////////////
886 throttle_index = this.append_cell(
887 'import time\n' +
888 'textbox = widgets.StringWidget()\n' +
889 'display(textbox)\n'+
890 'textbox.add_class("my-throttle-textbox")\n' +
891 'def handle_change(name, old, new):\n' +
892 ' print(len(new))\n' +
893 ' time.sleep(0.5)\n' +
894 'textbox.on_trait_change(handle_change)\n' +
895 'print("Success")');
896 this.execute_cell_then(throttle_index, function(index){
897 this.test.assert(this.get_output_cell(index).text == 'Success\n',
898 'Test throttling cell executed with correct output');
899
900 this.test.assert(this.cell_element_exists(index,
901 '.widget-area .widget-subarea'),
902 'Widget subarea exists.');
903
904 this.test.assert(this.cell_element_exists(index,
905 '.my-throttle-textbox'), 'Textbox exists.');
906
907 // Send 20 characters
908 this.sendKeys('.my-throttle-textbox', '....................');
909 });
910
911 this.wait(2000); // Wait for clicks to execute in kernel
912
913 this.then(function(){
914 var resume = true;
915 var i = 0;
916 while (resume) {
917 i++;
918 var output = this.get_output_cell(throttle_index, i);
919 if (output === undefined || output === null) {
920 resume = false;
921 i--;
922 }
923 }
924
925 // Only 4 outputs should have printed, but because of timing, sometimes
926 // 5 outputs will print. All we need to do is verify num outputs <= 5
927 // because that is much less than 20.
928 this.test.assert(i <= 5, 'Messages throttled.');
929
930 // We also need to verify that the last state sent was correct.
931 var last_state = this.get_output_cell(throttle_index, i).text;
932 this.test.assert(last_state == "20\n", "Last state sent when throttling.");
933 })
885 });
934 });
General Comments 0
You need to be logged in to leave comments. Login now