From cc21fe32f604aaa07632b662f1dd0d2b699a123e 2014-01-16 10:57:07 From: Jonathan Frederic Date: 2014-01-16 10:57:07 Subject: [PATCH] Added float widget tests --- diff --git a/IPython/html/tests/casperjs/test_cases/widgets.js b/IPython/html/tests/casperjs/test_cases/widgets.js index 2d8aa4a..e9aabc7 100644 --- a/IPython/html/tests/casperjs/test_cases/widgets.js +++ b/IPython/html/tests/casperjs/test_cases/widgets.js @@ -200,14 +200,13 @@ casper.notebook_test(function () { 'Button click event fires.'); }); - index = this.append_cell( - 'button.close()\n'+ - 'print("Success")'); - this.execute_cell_then(index, function(index){ + // Close the button widget asynchronisly. + index = this.append_cell('button.close()\n'); + this.execute_cell(index); - this.test.assert(this.get_output_cell(index).text == 'Success\n', - 'Close button cell executed with correct output.'); + this.wait(500); // Wait for the button to close. + this.then(function(){ this.test.assert(! this.cell_element_exists(button_index, '.widget-area .widget-subarea button'), 'Widget button doesn\'t exists.'); @@ -336,7 +335,7 @@ casper.notebook_test(function () { this.sendKeys(float_text_query, '1'); }); - this.wait(500); // Wait for slide to execute in kernel + this.wait(500); // Wait for change to execute in kernel index = this.append_cell('print(floatrange.value)\n'); this.execute_cell_then(index, function(index){ @@ -349,7 +348,7 @@ casper.notebook_test(function () { this.sendKeys(float_text_query, '120'); }); - this.wait(500); // Wait for slide to execute in kernel + this.wait(500); // Wait for change to execute in kernel index = this.append_cell('print(floatrange.value)\n'); this.execute_cell_then(index, function(index){ @@ -362,7 +361,7 @@ casper.notebook_test(function () { this.sendKeys(float_text_query, 'hello world'); }); - this.wait(500); // Wait for slide to execute in kernel + this.wait(500); // Wait for change to execute in kernel index = this.append_cell('print(floatrange.value)\n'); this.execute_cell_then(index, function(index){ @@ -370,5 +369,56 @@ casper.notebook_test(function () { 'Invalid float textbox characters ignored'); }); + // Test float widget /////////////////////////////////////////////////////// + var float_text_query_2 = '.widget-area .widget-subarea .widget-hbox-single .my-second-float-text'; + + var float_index = this.append_cell( + 'float_widget = widgets.FloatWidget()\n' + + 'display(float_widget)\n' + + 'float_widget.add_class("my-second-float-text")\n' + + 'print("Success")\n'); + this.execute_cell_then(float_index, function(index){ + + this.test.assert(this.get_output_cell(index).text == 'Success\n', + 'Create float cell executed with correct output.'); + + this.test.assert(this.cell_element_exists(index, + '.widget-area .widget-subarea'), + 'Widget subarea exists.'); + + this.test.assert(this.cell_element_exists(index, float_text_query_2), + 'Widget float textbox exists.'); + + this.cell_element_function(float_index, float_text_query_2, 'val', ['']); + this.sendKeys(float_text_query_2, '1.05'); + }); + + this.wait(500); // Wait for change to execute in kernel + + index = this.append_cell('print(float_widget.value)\n'); + this.execute_cell_then(index, function(index){ + this.test.assert(this.get_output_cell(index).text == '1.05\n', + 'Float textbox value set.'); + this.cell_element_function(float_index, float_text_query_2, 'val', ['']); + this.sendKeys(float_text_query_2, '123456789.0'); + }); + + this.wait(500); // Wait for change to execute in kernel + + index = this.append_cell('print(float_widget.value)\n'); + this.execute_cell_then(index, function(index){ + this.test.assert(this.get_output_cell(index).text == '123456789.0\n', + 'Long float textbox value set (probably triggers throttling).'); + this.cell_element_function(float_index, float_text_query_2, 'val', ['']); + this.sendKeys(float_text_query_2, '12hello'); + }); + + this.wait(500); // Wait for change to execute in kernel + + index = this.append_cell('print(float_widget.value)\n'); + this.execute_cell_then(index, function(index){ + this.test.assert(this.get_output_cell(index).text == '12.0\n', + 'Float textbox value set.'); + }); });