Fixed *almost* all of the test-detected bugs

Jonathan Frederic 12 years ago
parent c085593e2a
commit 4017c7b27a

@ -36,7 +36,7 @@ function(widget_manager, underscore, backbone){
// comm : Comm instance (optional)
this.widget_manager = widget_manager;
this.pending_msgs = 0;
this.msg_throttle = 3;
this.msg_throttle = 2;
this.msg_buffer = null;
this.key_value_lock = null;
this.id = model_id;
@ -108,18 +108,18 @@ function(widget_manager, underscore, backbone){
_handle_status: function (msg, callbacks) {
//execution_state : ('busy', 'idle', 'starting')
if (this.comm !== undefined && msg.content.execution_state ==='idle') {
// Send buffer if this message caused another message to be
// throttled.
if (this.msg_buffer !== null &&
this.msg_throttle === this.pending_msgs) {
var data = {method: 'backbone', sync_method: 'update', sync_data: this.msg_buffer};
this.comm.send(data, callbacks);
this.msg_buffer = null;
} else {
// Only decrease the pending message count if the buffer
// doesn't get flushed (sent).
--this.pending_msgs;
if (this.comm !== undefined) {
if (msg.content.execution_state ==='idle') {
// Send buffer if this message caused another message to be
// throttled.
if (this.msg_buffer !== null &&
this.msg_throttle === this.pending_msgs) {
var data = {method: 'backbone', sync_method: 'update', sync_data: this.msg_buffer};
this.comm.send(data, callbacks);
this.msg_buffer = null;
} else {
--this.pending_msgs;
}
}
}
},
@ -142,7 +142,7 @@ function(widget_manager, underscore, backbone){
}
for (attr in options.attrs) {
var value = this._pack_models(options.attrs[attr]);
if (this.key_value_lock === null || attr != this.key_value_lock[0] || value != this.key_value_lock[1]) {
if (this.key_value_lock === null || attr !== this.key_value_lock[0] || value !== this.key_value_lock[1]) {
this.msg_buffer[attr] = value;
}
}
@ -155,14 +155,18 @@ function(widget_manager, underscore, backbone){
send_json = {};
for (attr in options.attrs) {
var value = this._pack_models(options.attrs[attr]);
if (this.key_value_lock === null || attr != this.key_value_lock[0] || value != this.key_value_lock[1]) {
if (this.key_value_lock === null || attr !== this.key_value_lock[0] || value !== this.key_value_lock[1]) {
send_json[attr] = value;
}
}
var data = {method: 'backbone', sync_data: send_json};
this.comm.send(data, options.callbacks);
this.pending_msgs++;
var is_empty = true;
for (var prop in send_json) if (send_json.hasOwnProperty(prop)) is_empty = false;
if (!is_empty) {
++this.pending_msgs;
var data = {method: 'backbone', sync_data: send_json};
this.comm.send(data, options.callbacks);
}
}
}

@ -9,7 +9,7 @@ casper.notebook_test(function () {
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' +
'float_widget = widgets.FloatTextWidget()\n' +
'display(float_widget)\n' +
'float_widget.add_class("my-second-float-text")\n' +
'print("Success")\n');

@ -20,7 +20,7 @@ casper.notebook_test(function () {
'import base64\n' +
'data = base64.b64decode("' + test_jpg + '")\n' +
'image = widgets.ImageWidget()\n' +
'image.image_format = "jpeg"\n' +
'image.format = "jpeg"\n' +
'image.value = data\n' +
'image.width = "50px"\n' +
'image.height = "50px"\n' +

@ -9,7 +9,7 @@ casper.notebook_test(function () {
var int_text_query_2 = '.widget-area .widget-subarea .widget-hbox-single .my-second-int-text';
var int_index = this.append_cell(
'int_widget = widgets.IntWidget()\n' +
'int_widget = widgets.IntTextWidget()\n' +
'display(int_widget)\n' +
'int_widget.add_class("my-second-int-text")\n' +
'print("Success")\n');

@ -9,10 +9,10 @@ casper.notebook_test(function () {
// Test tab view
var multicontainer1_query = '.widget-area .widget-subarea div div.nav-tabs';
var multicontainer1_index = this.append_cell(
'multicontainer = widgets.MulticontainerWidget()\n' +
'page1 = widgets.StringWidget()\n' +
'page2 = widgets.StringWidget()\n' +
'page3 = widgets.StringWidget()\n' +
'multicontainer = widgets.TabWidget()\n' +
'page1 = widgets.TextBoxWidget()\n' +
'page2 = widgets.TextBoxWidget()\n' +
'page3 = widgets.TextBoxWidget()\n' +
'multicontainer.children = [page1, page2, page3]\n' +
'display(multicontainer)\n' +
'multicontainer.selected_index = 0\n' +
@ -64,13 +64,13 @@ casper.notebook_test(function () {
// Test accordion view
var multicontainer2_query = '.widget-area .widget-subarea .accordion';
var multicontainer2_index = this.append_cell(
'multicontainer = widgets.MulticontainerWidget()\n' +
'page1 = widgets.StringWidget()\n' +
'page2 = widgets.StringWidget()\n' +
'page3 = widgets.StringWidget()\n' +
'multicontainer = widgets.AccordionWidget()\n' +
'page1 = widgets.TextBoxWidget()\n' +
'page2 = widgets.TextBoxWidget()\n' +
'page3 = widgets.TextBoxWidget()\n' +
'multicontainer.children = [page1, page2, page3]\n' +
'multicontainer.set_title(2, "good")\n' +
'display(multicontainer, view_name="AccordionView")\n' +
'display(multicontainer)\n' +
'multicontainer.selected_index = 0\n' +
'print("Success")\n');
this.execute_cell_then(multicontainer2_index, function(index){

@ -41,11 +41,13 @@ casper.notebook_test(function () {
return true;
}
//values=["' + selection_values + '"[i] for i in range(4)]
selection_index = this.append_cell(
'selection = [widgets.SelectionWidget(values=["' + selection_values + '"[i] for i in range(4)]) for j in range(4)]\n' +
'selection[1].view_name="ToggleButtonsView"\n' +
'selection[2].view_name="RadioButtonsView"\n' +
'selection[3].view_name="ListBoxView"\n' +
'values=["' + selection_values + '"[i] for i in range(4)]\n' +
'selection = [widgets.DropdownWidget(values=values),\n' +
' widgets.ToggleButtonsWidget(values=values),\n' +
' widgets.RadioButtonsWidget(values=values),\n' +
' widgets.ListBoxWidget(values=values)]\n' +
'[display(selection[i]) for i in range(4)]\n' +
'for widget in selection:\n' +
' def handle_change(name,old,new):\n' +
@ -90,18 +92,30 @@ casper.notebook_test(function () {
// Verify that selecting a radio button updates all of the others.
this.cell_element_function(selection_index, radio_selector + ' .radio:nth-child(2) input', 'click');
});
this.wait(500);
this.then(function () {
this.test.assert(verify_selection(this, 1), 'Radio button selection updated view states correctly.');
// Verify that selecting a list option updates all of the others.
this.cell_element_function(selection_index, list_selector + ' option:nth-child(3)', 'click');
});
this.wait(500);
this.then(function () {
this.test.assert(verify_selection(this, 2), 'List selection updated view states correctly.');
// Verify that selecting a multibutton option updates all of the others.
this.cell_element_function(selection_index, multibtn_selector + ' .btn:nth-child(4)', 'click');
});
this.wait(500);
this.then(function () {
this.test.assert(verify_selection(this, 3), 'Multibutton selection updated view states correctly.');
// Verify that selecting a combobox option updates all of the others.
this.cell_element_function(selection_index, '.widget-area .widget-subarea .widget-hbox-single .btn-group ul.dropdown-menu li:nth-child(3) a', 'click');
});
this.wait(500);
this.then(function () {
this.test.assert(verify_selection(this, 2), 'Combobox selection updated view states correctly.');
});
@ -109,9 +123,10 @@ casper.notebook_test(function () {
index = this.append_cell(
'print(selection.value)\n' +
'selection.values.append("z")\n' +
'selection.send_state()\n' +
'selection.value = "z"');
'for widget in selection:\n' +
' widget.values.append("z")\n' +
' widget.send_state()\n' +
' widget.value = "z"');
this.execute_cell_then(index, function(index){
// Verify that selecting a combobox option updates all of the others.

@ -7,14 +7,10 @@ casper.notebook_test(function () {
this.execute_cell_then(index);
var string_index = this.append_cell(
'string_widget = [widgets.StringWidget(), widgets.StringWidget(), widgets.StringWidget(), widgets.StringWidget()]\n' +
'string_widget[0].value = "xyz"\n' +
'string_widget[1].view_name = "TextAreaView"\n' +
'string_widget[1].value = "xyz"\n' +
'string_widget[2].view_name = "HTMLView"\n' +
'string_widget[2].value = "xyz"\n' +
'string_widget[3].view_name = "LatexView"\n' +
'string_widget[3].value = "$\\\\LaTeX{}$"\n' +
'string_widget = [widgets.TextBoxWidget(value = "xyz"),\n' +
' widgets.TextAreaWidget(value = "xyz"),\n' +
' widgets.HTMLWidget(value = "xyz"),\n' +
' widgets.LatexWidget(value = "$\\\\LaTeX{}$")]\n' +
'[display(widget) for widget in string_widget]\n'+
'print("Success")');
this.execute_cell_then(string_index, function(index){

@ -377,7 +377,9 @@ class DOMWidget(Widget):
`$el_to_style` in the Javascript code).
"""
selector = kwargs.get('selector', '')
if not selector in self._css:
self._css[selector] = {}
# Signature 1: set_css(css_dict, selector='')
if len(args) == 1:
if isinstance(args[0], dict):

Loading…
Cancel
Save