##// END OF EJS Templates
Fixed *almost* all of the test-detected bugs
Jonathan Frederic -
Show More
@@ -36,7 +36,7 b' function(widget_manager, underscore, backbone){'
36 // comm : Comm instance (optional)
36 // comm : Comm instance (optional)
37 this.widget_manager = widget_manager;
37 this.widget_manager = widget_manager;
38 this.pending_msgs = 0;
38 this.pending_msgs = 0;
39 this.msg_throttle = 3;
39 this.msg_throttle = 2;
40 this.msg_buffer = null;
40 this.msg_buffer = null;
41 this.key_value_lock = null;
41 this.key_value_lock = null;
42 this.id = model_id;
42 this.id = model_id;
@@ -108,18 +108,18 b' function(widget_manager, underscore, backbone){'
108
108
109 _handle_status: function (msg, callbacks) {
109 _handle_status: function (msg, callbacks) {
110 //execution_state : ('busy', 'idle', 'starting')
110 //execution_state : ('busy', 'idle', 'starting')
111 if (this.comm !== undefined && msg.content.execution_state ==='idle') {
111 if (this.comm !== undefined) {
112 // Send buffer if this message caused another message to be
112 if (msg.content.execution_state ==='idle') {
113 // throttled.
113 // Send buffer if this message caused another message to be
114 if (this.msg_buffer !== null &&
114 // throttled.
115 this.msg_throttle === this.pending_msgs) {
115 if (this.msg_buffer !== null &&
116 var data = {method: 'backbone', sync_method: 'update', sync_data: this.msg_buffer};
116 this.msg_throttle === this.pending_msgs) {
117 this.comm.send(data, callbacks);
117 var data = {method: 'backbone', sync_method: 'update', sync_data: this.msg_buffer};
118 this.msg_buffer = null;
118 this.comm.send(data, callbacks);
119 } else {
119 this.msg_buffer = null;
120 // Only decrease the pending message count if the buffer
120 } else {
121 // doesn't get flushed (sent).
121 --this.pending_msgs;
122 --this.pending_msgs;
122 }
123 }
123 }
124 }
124 }
125 },
125 },
@@ -142,7 +142,7 b' function(widget_manager, underscore, backbone){'
142 }
142 }
143 for (attr in options.attrs) {
143 for (attr in options.attrs) {
144 var value = this._pack_models(options.attrs[attr]);
144 var value = this._pack_models(options.attrs[attr]);
145 if (this.key_value_lock === null || attr != this.key_value_lock[0] || value != this.key_value_lock[1]) {
145 if (this.key_value_lock === null || attr !== this.key_value_lock[0] || value !== this.key_value_lock[1]) {
146 this.msg_buffer[attr] = value;
146 this.msg_buffer[attr] = value;
147 }
147 }
148 }
148 }
@@ -155,14 +155,18 b' function(widget_manager, underscore, backbone){'
155 send_json = {};
155 send_json = {};
156 for (attr in options.attrs) {
156 for (attr in options.attrs) {
157 var value = this._pack_models(options.attrs[attr]);
157 var value = this._pack_models(options.attrs[attr]);
158 if (this.key_value_lock === null || attr != this.key_value_lock[0] || value != this.key_value_lock[1]) {
158 if (this.key_value_lock === null || attr !== this.key_value_lock[0] || value !== this.key_value_lock[1]) {
159 send_json[attr] = value;
159 send_json[attr] = value;
160 }
160 }
161 }
161 }
162
162
163 var data = {method: 'backbone', sync_data: send_json};
163 var is_empty = true;
164 this.comm.send(data, options.callbacks);
164 for (var prop in send_json) if (send_json.hasOwnProperty(prop)) is_empty = false;
165 this.pending_msgs++;
165 if (!is_empty) {
166 ++this.pending_msgs;
167 var data = {method: 'backbone', sync_data: send_json};
168 this.comm.send(data, options.callbacks);
169 }
166 }
170 }
167 }
171 }
168
172
@@ -9,7 +9,7 b' casper.notebook_test(function () {'
9 var float_text_query_2 = '.widget-area .widget-subarea .widget-hbox-single .my-second-float-text';
9 var float_text_query_2 = '.widget-area .widget-subarea .widget-hbox-single .my-second-float-text';
10
10
11 var float_index = this.append_cell(
11 var float_index = this.append_cell(
12 'float_widget = widgets.FloatWidget()\n' +
12 'float_widget = widgets.FloatTextWidget()\n' +
13 'display(float_widget)\n' +
13 'display(float_widget)\n' +
14 'float_widget.add_class("my-second-float-text")\n' +
14 'float_widget.add_class("my-second-float-text")\n' +
15 'print("Success")\n');
15 'print("Success")\n');
@@ -10,10 +10,9 b' casper.notebook_test(function () {'
10 var float_text_query = '.widget-area .widget-subarea .widget-hbox-single .widget-numeric-text';
10 var float_text_query = '.widget-area .widget-subarea .widget-hbox-single .widget-numeric-text';
11
11
12 var floatrange_index = this.append_cell(
12 var floatrange_index = this.append_cell(
13 'floatrange = widgets.FloatRangeWidget()\n' +
13 'floatrange = [widgets.BoundedFloatTextWidget(), \n' +
14 'floatrange2 = widgets.FloatRangeWidget()\n' +
14 ' widgets.FloatSliderWidget()]\n' +
15 'display(floatrange)\n' +
15 '[display(floatrange[i]) for i in range(2)]\n' +
16 'display(floatrange2)\n' +
17 'print("Success")\n');
16 'print("Success")\n');
18 this.execute_cell_then(floatrange_index, function(index){
17 this.execute_cell_then(floatrange_index, function(index){
19
18
@@ -32,9 +31,10 b' casper.notebook_test(function () {'
32 });
31 });
33
32
34 index = this.append_cell(
33 index = this.append_cell(
35 'floatrange.max = 50.0\n' +
34 'for widget in floatrange:\n' +
36 'floatrange.min = -50.0\n' +
35 ' widget.max = 50.0\n' +
37 'floatrange.value = 25.0\n' +
36 ' widget.min = -50.0\n' +
37 ' widget.value = 20.0\n' +
38 'print("Success")\n');
38 'print("Success")\n');
39 this.execute_cell_then(index, function(index){
39 this.execute_cell_then(index, function(index){
40
40
@@ -45,23 +45,20 b' casper.notebook_test(function () {'
45 'Widget slider exists.');
45 'Widget slider exists.');
46
46
47 this.test.assert(this.cell_element_function(floatrange_index, slider_query,
47 this.test.assert(this.cell_element_function(floatrange_index, slider_query,
48 'slider', ['value']) == 25.0,
48 'slider', ['value']) == 20.0,
49 'Slider set to Python value.');
49 'Slider set to Python value.');
50
50
51 this.test.assert(this.cell_element_function(floatrange_index, float_text_query,
52 'val') == 25.0, 'Float textbox set to Python value.');
53
54 // Clear the float textbox value and then set it to 1 by emulating
51 // Clear the float textbox value and then set it to 1 by emulating
55 // keyboard presses.
52 // keyboard presses.
56 this.cell_element_function(floatrange_index, float_text_query, 'val', ['']);
53 this.cell_element_function(floatrange_index, float_text_query, 'val', ['']);
57 this.sendKeys(float_text_query, '1');
54 this.sendKeys(float_text_query, '1');
58 });
55 });
59
56
60 this.wait(500); // Wait for change to execute in kernel
57 this.wait(1500); // Wait for change to execute in kernel
61
58
62 index = this.append_cell('print(floatrange.value)\n');
59 index = this.append_cell('for widget in floatrange:\n print(widget.value)\n');
63 this.execute_cell_then(index, function(index){
60 this.execute_cell_then(index, function(index){
64 this.test.assert(this.get_output_cell(index).text == '1.0\n',
61 this.test.assert(this.get_output_cell(index).text == '1.0\n20.0\n',
65 'Float textbox set float range value');
62 'Float textbox set float range value');
66
63
67 // Clear the float textbox value and then set it to 120 by emulating
64 // Clear the float textbox value and then set it to 120 by emulating
@@ -72,7 +69,7 b' casper.notebook_test(function () {'
72
69
73 this.wait(500); // Wait for change to execute in kernel
70 this.wait(500); // Wait for change to execute in kernel
74
71
75 index = this.append_cell('print(floatrange.value)\n');
72 index = this.append_cell('print(floatrange[0].value)\n');
76 this.execute_cell_then(index, function(index){
73 this.execute_cell_then(index, function(index){
77 this.test.assert(this.get_output_cell(index).text == '50.0\n',
74 this.test.assert(this.get_output_cell(index).text == '50.0\n',
78 'Float textbox value bound');
75 'Float textbox value bound');
@@ -85,7 +82,7 b' casper.notebook_test(function () {'
85
82
86 this.wait(500); // Wait for change to execute in kernel
83 this.wait(500); // Wait for change to execute in kernel
87
84
88 index = this.append_cell('print(floatrange.value)\n');
85 index = this.append_cell('print(floatrange[0].value)\n');
89 this.execute_cell_then(index, function(index){
86 this.execute_cell_then(index, function(index){
90 this.test.assert(this.get_output_cell(index).text == '50.0\n',
87 this.test.assert(this.get_output_cell(index).text == '50.0\n',
91 'Invalid float textbox characters ignored');
88 'Invalid float textbox characters ignored');
@@ -20,7 +20,7 b' casper.notebook_test(function () {'
20 'import base64\n' +
20 'import base64\n' +
21 'data = base64.b64decode("' + test_jpg + '")\n' +
21 'data = base64.b64decode("' + test_jpg + '")\n' +
22 'image = widgets.ImageWidget()\n' +
22 'image = widgets.ImageWidget()\n' +
23 'image.image_format = "jpeg"\n' +
23 'image.format = "jpeg"\n' +
24 'image.value = data\n' +
24 'image.value = data\n' +
25 'image.width = "50px"\n' +
25 'image.width = "50px"\n' +
26 'image.height = "50px"\n' +
26 'image.height = "50px"\n' +
@@ -9,7 +9,7 b' casper.notebook_test(function () {'
9 var int_text_query_2 = '.widget-area .widget-subarea .widget-hbox-single .my-second-int-text';
9 var int_text_query_2 = '.widget-area .widget-subarea .widget-hbox-single .my-second-int-text';
10
10
11 var int_index = this.append_cell(
11 var int_index = this.append_cell(
12 'int_widget = widgets.IntWidget()\n' +
12 'int_widget = widgets.IntTextWidget()\n' +
13 'display(int_widget)\n' +
13 'display(int_widget)\n' +
14 'int_widget.add_class("my-second-int-text")\n' +
14 'int_widget.add_class("my-second-int-text")\n' +
15 'print("Success")\n');
15 'print("Success")\n');
@@ -10,10 +10,10 b' casper.notebook_test(function () {'
10 var int_text_query = '.widget-area .widget-subarea .widget-hbox-single .my-second-num-test-text';
10 var int_text_query = '.widget-area .widget-subarea .widget-hbox-single .my-second-num-test-text';
11
11
12 var intrange_index = this.append_cell(
12 var intrange_index = this.append_cell(
13 'intrange = widgets.IntRangeWidget()\n' +
13 'intrange = [widgets.BoundedIntTextWidget(),\n' +
14 'display(intrange, view_name="IntTextView")\n' +
14 ' widgets.IntSliderWidget()]\n' +
15 'intrange.add_class("my-second-num-test-text")\n' +
15 '[display(intrange[i]) for i in range(2)]\n' +
16 'display(intrange)\n' +
16 'intrange[0].add_class("my-second-num-test-text")\n' +
17 'print("Success")\n');
17 'print("Success")\n');
18 this.execute_cell_then(intrange_index, function(index){
18 this.execute_cell_then(intrange_index, function(index){
19
19
@@ -32,9 +32,10 b' casper.notebook_test(function () {'
32 });
32 });
33
33
34 index = this.append_cell(
34 index = this.append_cell(
35 'intrange.max = 50\n' +
35 'for widget in intrange:\n' +
36 'intrange.min = -50\n' +
36 ' widget.max = 50\n' +
37 'intrange.value = 25\n' +
37 ' widget.min = -50\n' +
38 ' widget.value = 25\n' +
38 'print("Success")\n');
39 'print("Success")\n');
39 this.execute_cell_then(index, function(index){
40 this.execute_cell_then(index, function(index){
40
41
@@ -59,7 +60,7 b' casper.notebook_test(function () {'
59
60
60 this.wait(500); // Wait for change to execute in kernel
61 this.wait(500); // Wait for change to execute in kernel
61
62
62 index = this.append_cell('print(intrange.value)\n');
63 index = this.append_cell('print(intrange[0].value)\n');
63 this.execute_cell_then(index, function(index){
64 this.execute_cell_then(index, function(index){
64 this.test.assert(this.get_output_cell(index).text == '1\n',
65 this.test.assert(this.get_output_cell(index).text == '1\n',
65 'Int textbox set int range value');
66 'Int textbox set int range value');
@@ -72,7 +73,7 b' casper.notebook_test(function () {'
72
73
73 this.wait(500); // Wait for change to execute in kernel
74 this.wait(500); // Wait for change to execute in kernel
74
75
75 index = this.append_cell('print(intrange.value)\n');
76 index = this.append_cell('print(intrange[0].value)\n');
76 this.execute_cell_then(index, function(index){
77 this.execute_cell_then(index, function(index){
77 this.test.assert(this.get_output_cell(index).text == '50\n',
78 this.test.assert(this.get_output_cell(index).text == '50\n',
78 'Int textbox value bound');
79 'Int textbox value bound');
@@ -85,7 +86,7 b' casper.notebook_test(function () {'
85
86
86 this.wait(500); // Wait for change to execute in kernel
87 this.wait(500); // Wait for change to execute in kernel
87
88
88 index = this.append_cell('print(intrange.value)\n');
89 index = this.append_cell('print(intrange[0].value)\n');
89 this.execute_cell_then(index, function(index){
90 this.execute_cell_then(index, function(index){
90 this.test.assert(this.get_output_cell(index).text == '50\n',
91 this.test.assert(this.get_output_cell(index).text == '50\n',
91 'Invalid int textbox characters ignored');
92 'Invalid int textbox characters ignored');
@@ -9,10 +9,10 b' casper.notebook_test(function () {'
9 // Test tab view
9 // Test tab view
10 var multicontainer1_query = '.widget-area .widget-subarea div div.nav-tabs';
10 var multicontainer1_query = '.widget-area .widget-subarea div div.nav-tabs';
11 var multicontainer1_index = this.append_cell(
11 var multicontainer1_index = this.append_cell(
12 'multicontainer = widgets.MulticontainerWidget()\n' +
12 'multicontainer = widgets.TabWidget()\n' +
13 'page1 = widgets.StringWidget()\n' +
13 'page1 = widgets.TextBoxWidget()\n' +
14 'page2 = widgets.StringWidget()\n' +
14 'page2 = widgets.TextBoxWidget()\n' +
15 'page3 = widgets.StringWidget()\n' +
15 'page3 = widgets.TextBoxWidget()\n' +
16 'multicontainer.children = [page1, page2, page3]\n' +
16 'multicontainer.children = [page1, page2, page3]\n' +
17 'display(multicontainer)\n' +
17 'display(multicontainer)\n' +
18 'multicontainer.selected_index = 0\n' +
18 'multicontainer.selected_index = 0\n' +
@@ -64,13 +64,13 b' casper.notebook_test(function () {'
64 // Test accordion view
64 // Test accordion view
65 var multicontainer2_query = '.widget-area .widget-subarea .accordion';
65 var multicontainer2_query = '.widget-area .widget-subarea .accordion';
66 var multicontainer2_index = this.append_cell(
66 var multicontainer2_index = this.append_cell(
67 'multicontainer = widgets.MulticontainerWidget()\n' +
67 'multicontainer = widgets.AccordionWidget()\n' +
68 'page1 = widgets.StringWidget()\n' +
68 'page1 = widgets.TextBoxWidget()\n' +
69 'page2 = widgets.StringWidget()\n' +
69 'page2 = widgets.TextBoxWidget()\n' +
70 'page3 = widgets.StringWidget()\n' +
70 'page3 = widgets.TextBoxWidget()\n' +
71 'multicontainer.children = [page1, page2, page3]\n' +
71 'multicontainer.children = [page1, page2, page3]\n' +
72 'multicontainer.set_title(2, "good")\n' +
72 'multicontainer.set_title(2, "good")\n' +
73 'display(multicontainer, view_name="AccordionView")\n' +
73 'display(multicontainer)\n' +
74 'multicontainer.selected_index = 0\n' +
74 'multicontainer.selected_index = 0\n' +
75 'print("Success")\n');
75 'print("Success")\n');
76 this.execute_cell_then(multicontainer2_index, function(index){
76 this.execute_cell_then(multicontainer2_index, function(index){
@@ -41,11 +41,13 b' casper.notebook_test(function () {'
41 return true;
41 return true;
42 }
42 }
43
43
44 //values=["' + selection_values + '"[i] for i in range(4)]
44 selection_index = this.append_cell(
45 selection_index = this.append_cell(
45 'selection = [widgets.SelectionWidget(values=["' + selection_values + '"[i] for i in range(4)]) for j in range(4)]\n' +
46 'values=["' + selection_values + '"[i] for i in range(4)]\n' +
46 'selection[1].view_name="ToggleButtonsView"\n' +
47 'selection = [widgets.DropdownWidget(values=values),\n' +
47 'selection[2].view_name="RadioButtonsView"\n' +
48 ' widgets.ToggleButtonsWidget(values=values),\n' +
48 'selection[3].view_name="ListBoxView"\n' +
49 ' widgets.RadioButtonsWidget(values=values),\n' +
50 ' widgets.ListBoxWidget(values=values)]\n' +
49 '[display(selection[i]) for i in range(4)]\n' +
51 '[display(selection[i]) for i in range(4)]\n' +
50 'for widget in selection:\n' +
52 'for widget in selection:\n' +
51 ' def handle_change(name,old,new):\n' +
53 ' def handle_change(name,old,new):\n' +
@@ -90,18 +92,30 b' casper.notebook_test(function () {'
90
92
91 // Verify that selecting a radio button updates all of the others.
93 // Verify that selecting a radio button updates all of the others.
92 this.cell_element_function(selection_index, radio_selector + ' .radio:nth-child(2) input', 'click');
94 this.cell_element_function(selection_index, radio_selector + ' .radio:nth-child(2) input', 'click');
95 });
96 this.wait(500);
97 this.then(function () {
93 this.test.assert(verify_selection(this, 1), 'Radio button selection updated view states correctly.');
98 this.test.assert(verify_selection(this, 1), 'Radio button selection updated view states correctly.');
94
99
95 // Verify that selecting a list option updates all of the others.
100 // Verify that selecting a list option updates all of the others.
96 this.cell_element_function(selection_index, list_selector + ' option:nth-child(3)', 'click');
101 this.cell_element_function(selection_index, list_selector + ' option:nth-child(3)', 'click');
102 });
103 this.wait(500);
104 this.then(function () {
97 this.test.assert(verify_selection(this, 2), 'List selection updated view states correctly.');
105 this.test.assert(verify_selection(this, 2), 'List selection updated view states correctly.');
98
106
99 // Verify that selecting a multibutton option updates all of the others.
107 // Verify that selecting a multibutton option updates all of the others.
100 this.cell_element_function(selection_index, multibtn_selector + ' .btn:nth-child(4)', 'click');
108 this.cell_element_function(selection_index, multibtn_selector + ' .btn:nth-child(4)', 'click');
109 });
110 this.wait(500);
111 this.then(function () {
101 this.test.assert(verify_selection(this, 3), 'Multibutton selection updated view states correctly.');
112 this.test.assert(verify_selection(this, 3), 'Multibutton selection updated view states correctly.');
102
113
103 // Verify that selecting a combobox option updates all of the others.
114 // Verify that selecting a combobox option updates all of the others.
104 this.cell_element_function(selection_index, '.widget-area .widget-subarea .widget-hbox-single .btn-group ul.dropdown-menu li:nth-child(3) a', 'click');
115 this.cell_element_function(selection_index, '.widget-area .widget-subarea .widget-hbox-single .btn-group ul.dropdown-menu li:nth-child(3) a', 'click');
116 });
117 this.wait(500);
118 this.then(function () {
105 this.test.assert(verify_selection(this, 2), 'Combobox selection updated view states correctly.');
119 this.test.assert(verify_selection(this, 2), 'Combobox selection updated view states correctly.');
106 });
120 });
107
121
@@ -109,9 +123,10 b' casper.notebook_test(function () {'
109
123
110 index = this.append_cell(
124 index = this.append_cell(
111 'print(selection.value)\n' +
125 'print(selection.value)\n' +
112 'selection.values.append("z")\n' +
126 'for widget in selection:\n' +
113 'selection.send_state()\n' +
127 ' widget.values.append("z")\n' +
114 'selection.value = "z"');
128 ' widget.send_state()\n' +
129 ' widget.value = "z"');
115 this.execute_cell_then(index, function(index){
130 this.execute_cell_then(index, function(index){
116
131
117 // Verify that selecting a combobox option updates all of the others.
132 // Verify that selecting a combobox option updates all of the others.
@@ -7,14 +7,10 b' casper.notebook_test(function () {'
7 this.execute_cell_then(index);
7 this.execute_cell_then(index);
8
8
9 var string_index = this.append_cell(
9 var string_index = this.append_cell(
10 'string_widget = [widgets.StringWidget(), widgets.StringWidget(), widgets.StringWidget(), widgets.StringWidget()]\n' +
10 'string_widget = [widgets.TextBoxWidget(value = "xyz"),\n' +
11 'string_widget[0].value = "xyz"\n' +
11 ' widgets.TextAreaWidget(value = "xyz"),\n' +
12 'string_widget[1].view_name = "TextAreaView"\n' +
12 ' widgets.HTMLWidget(value = "xyz"),\n' +
13 'string_widget[1].value = "xyz"\n' +
13 ' widgets.LatexWidget(value = "$\\\\LaTeX{}$")]\n' +
14 'string_widget[2].view_name = "HTMLView"\n' +
15 'string_widget[2].value = "xyz"\n' +
16 'string_widget[3].view_name = "LatexView"\n' +
17 'string_widget[3].value = "$\\\\LaTeX{}$"\n' +
18 '[display(widget) for widget in string_widget]\n'+
14 '[display(widget) for widget in string_widget]\n'+
19 'print("Success")');
15 'print("Success")');
20 this.execute_cell_then(string_index, function(index){
16 this.execute_cell_then(string_index, function(index){
@@ -377,7 +377,9 b' class DOMWidget(Widget):'
377 `$el_to_style` in the Javascript code).
377 `$el_to_style` in the Javascript code).
378 """
378 """
379 selector = kwargs.get('selector', '')
379 selector = kwargs.get('selector', '')
380
380 if not selector in self._css:
381 self._css[selector] = {}
382
381 # Signature 1: set_css(css_dict, selector='')
383 # Signature 1: set_css(css_dict, selector='')
382 if len(args) == 1:
384 if len(args) == 1:
383 if isinstance(args[0], dict):
385 if isinstance(args[0], dict):
General Comments 0
You need to be logged in to leave comments. Login now