Show More
@@ -96,11 +96,6 b' define([' | |||||
96 | // Make sure the view creation is not out of order with |
|
96 | // Make sure the view creation is not out of order with | |
97 | // any state updates. |
|
97 | // any state updates. | |
98 | model.state_change = model.state_change.then(function() { |
|
98 | model.state_change = model.state_change.then(function() { | |
99 | try { |
|
|||
100 | console.log('create_view ' + model.id); |
|
|||
101 | console.log(' _view_name ' + model.get('_view_name')); |
|
|||
102 | console.log(' _view_module ' + model.get('_view_module')); |
|
|||
103 | } catch (e) { } |
|
|||
104 |
|
99 | |||
105 | return utils.load_class(model.get('_view_name'), model.get('_view_module'), |
|
100 | return utils.load_class(model.get('_view_name'), model.get('_view_module'), | |
106 | WidgetManager._view_types).then(function(ViewType) { |
|
101 | WidgetManager._view_types).then(function(ViewType) { |
@@ -69,7 +69,6 b' define(["widgets/js/manager",' | |||||
69 | _handle_comm_msg: function (msg) { |
|
69 | _handle_comm_msg: function (msg) { | |
70 | // Handle incoming comm msg. |
|
70 | // Handle incoming comm msg. | |
71 | var method = msg.content.data.method; |
|
71 | var method = msg.content.data.method; | |
72 | console.log(method); |
|
|||
73 | var that = this; |
|
72 | var that = this; | |
74 | switch (method) { |
|
73 | switch (method) { | |
75 | case 'update': |
|
74 | case 'update': | |
@@ -81,9 +80,7 b' define(["widgets/js/manager",' | |||||
81 | this.trigger('msg:custom', msg.content.data.content); |
|
80 | this.trigger('msg:custom', msg.content.data.content); | |
82 | break; |
|
81 | break; | |
83 | case 'display': |
|
82 | case 'display': | |
84 | this.state_change = this.state_change.then(function() { |
|
83 | return that.widget_manager.display_view(msg, that); | |
85 | return that.widget_manager.display_view(msg, that); |
|
|||
86 | }).catch(utils.reject("Couldn't process display msg for model id '" + String(that.id) + "'", true)); |
|
|||
87 | break; |
|
84 | break; | |
88 | } |
|
85 | } | |
89 | }, |
|
86 | }, | |
@@ -94,8 +91,6 b' define(["widgets/js/manager",' | |||||
94 | return this._unpack_models(state).then(function(state) { |
|
91 | return this._unpack_models(state).then(function(state) { | |
95 | that.state_lock = state; |
|
92 | that.state_lock = state; | |
96 | try { |
|
93 | try { | |
97 | console.log('set_state ' + that.id); |
|
|||
98 | console.log(state); |
|
|||
99 | WidgetModel.__super__.set.call(that, state); |
|
94 | WidgetModel.__super__.set.call(that, state); | |
100 | } finally { |
|
95 | } finally { | |
101 | that.state_lock = null; |
|
96 | that.state_lock = null; |
@@ -314,6 +314,15 b' casper.execute_cell_then = function(index, then_callback, expect_failure) {' | |||||
314 | return return_val; |
|
314 | return return_val; | |
315 | }; |
|
315 | }; | |
316 |
|
316 | |||
|
317 | casper.waitfor_cell_element = function(index, selector){ | |||
|
318 | // Utility function that allows us to easily wait for an element | |||
|
319 | // within a cell. Uses JQuery selector to look for the element. | |||
|
320 | var that = this; | |||
|
321 | this.waitFor(function() { | |||
|
322 | return that.cell_element_exists(index, selector); | |||
|
323 | }, function() { console.log('FOUND!'); }); | |||
|
324 | }; | |||
|
325 | ||||
317 | casper.cell_element_exists = function(index, selector){ |
|
326 | casper.cell_element_exists = function(index, selector){ | |
318 | // Utility function that allows us to easily check if an element exists |
|
327 | // Utility function that allows us to easily check if an element exists | |
319 | // within a cell. Uses JQuery selector to look for the element. |
|
328 | // within a cell. Uses JQuery selector to look for the element. |
@@ -1,12 +1,12 b'' | |||||
1 | // Test widget bool class |
|
1 | // Test widget bool class | |
2 | casper.notebook_test(function () { |
|
2 | casper.notebook_test(function () { | |
3 | index = this.append_cell( |
|
3 | // index = this.append_cell( | |
4 | 'from IPython.html import widgets\n' + |
|
4 | // 'print("Success")'); | |
5 | 'from IPython.display import display, clear_output\n' + |
|
5 | // this.execute_cell_then(index); | |
6 | 'print("Success")'); |
|
|||
7 | this.execute_cell_then(index); |
|
|||
8 |
|
6 | |||
9 | var bool_index = this.append_cell( |
|
7 | var bool_index = this.append_cell( | |
|
8 | 'from IPython.html import widgets\n' + | |||
|
9 | 'from IPython.display import display, clear_output\n' + | |||
10 | 'bool_widgets = [widgets.Checkbox(description="Title", value=True),\n' + |
|
10 | 'bool_widgets = [widgets.Checkbox(description="Title", value=True),\n' + | |
11 | ' widgets.ToggleButton(description="Title", value=True)]\n' + |
|
11 | ' widgets.ToggleButton(description="Title", value=True)]\n' + | |
12 | 'display(bool_widgets[0])\n' + |
|
12 | 'display(bool_widgets[0])\n' + | |
@@ -15,36 +15,41 b' casper.notebook_test(function () {' | |||||
15 | this.execute_cell_then(bool_index, function(index){ |
|
15 | this.execute_cell_then(bool_index, function(index){ | |
16 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', |
|
16 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', | |
17 | 'Create bool widget cell executed with correct output.'); |
|
17 | 'Create bool widget cell executed with correct output.'); | |
|
18 | }); | |||
18 |
|
19 | |||
19 | this.test.assert(this.cell_element_exists(index, |
|
20 | this.waitfor_cell_element(bool_index, '.widget-area .widget-subarea .widget-hbox input'); | |
|
21 | this.waitfor_cell_element(bool_index, '.widget-area .widget-subarea button'); | |||
|
22 | ||||
|
23 | this.then(function() { | |||
|
24 | this.test.assert(this.cell_element_exists(bool_index, | |||
20 | '.widget-area .widget-subarea'), |
|
25 | '.widget-area .widget-subarea'), | |
21 | 'Widget subarea exists.'); |
|
26 | 'Widget subarea exists.'); | |
22 |
|
27 | |||
23 | this.test.assert(this.cell_element_exists(index, |
|
28 | this.test.assert(this.cell_element_exists(bool_index, | |
24 | '.widget-area .widget-subarea .widget-hbox input'), |
|
29 | '.widget-area .widget-subarea .widget-hbox input'), | |
25 | 'Checkbox exists.'); |
|
30 | 'Checkbox exists.'); | |
26 |
|
31 | |||
27 | this.test.assert(this.cell_element_function(index, |
|
32 | this.test.assert(this.cell_element_function(bool_index, | |
28 | '.widget-area .widget-subarea .widget-hbox input', 'prop', ['checked']), |
|
33 | '.widget-area .widget-subarea .widget-hbox input', 'prop', ['checked']), | |
29 | 'Checkbox is checked.'); |
|
34 | 'Checkbox is checked.'); | |
30 |
|
35 | |||
31 | this.test.assert(this.cell_element_exists(index, |
|
36 | this.test.assert(this.cell_element_exists(bool_index, | |
32 | '.widget-area .widget-subarea .widget-hbox .widget-label'), |
|
37 | '.widget-area .widget-subarea .widget-hbox .widget-label'), | |
33 | 'Checkbox label exists.'); |
|
38 | 'Checkbox label exists.'); | |
34 |
|
39 | |||
35 | this.test.assert(this.cell_element_function(index, |
|
40 | this.test.assert(this.cell_element_function(bool_index, | |
36 | '.widget-area .widget-subarea .widget-hbox .widget-label', 'html')=="Title", |
|
41 | '.widget-area .widget-subarea .widget-hbox .widget-label', 'html')=="Title", | |
37 | 'Checkbox labeled correctly.'); |
|
42 | 'Checkbox labeled correctly.'); | |
38 |
|
43 | |||
39 | this.test.assert(this.cell_element_exists(index, |
|
44 | this.test.assert(this.cell_element_exists(bool_index, | |
40 | '.widget-area .widget-subarea button'), |
|
45 | '.widget-area .widget-subarea button'), | |
41 | 'Toggle button exists.'); |
|
46 | 'Toggle button exists.'); | |
42 |
|
47 | |||
43 | this.test.assert(this.cell_element_function(index, |
|
48 | this.test.assert(this.cell_element_function(bool_index, | |
44 | '.widget-area .widget-subarea button', 'html')=="Title", |
|
49 | '.widget-area .widget-subarea button', 'html')=="Title", | |
45 | 'Toggle button labeled correctly.'); |
|
50 | 'Toggle button labeled correctly.'); | |
46 |
|
51 | |||
47 | this.test.assert(this.cell_element_function(index, |
|
52 | this.test.assert(this.cell_element_function(bool_index, | |
48 | '.widget-area .widget-subarea button', 'hasClass', ['active']), |
|
53 | '.widget-area .widget-subarea button', 'hasClass', ['active']), | |
49 | 'Toggle button is toggled.'); |
|
54 | 'Toggle button is toggled.'); | |
50 | }); |
|
55 | }); | |
@@ -54,9 +59,6 b' casper.notebook_test(function () {' | |||||
54 | 'bool_widgets[1].value = False\n' + |
|
59 | 'bool_widgets[1].value = False\n' + | |
55 | 'print("Success")'); |
|
60 | 'print("Success")'); | |
56 | this.execute_cell_then(index, function(index){ |
|
61 | this.execute_cell_then(index, function(index){ | |
57 |
|
||||
58 | this.interact(); |
|
|||
59 |
|
||||
60 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', |
|
62 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', | |
61 | 'Change bool widget value cell executed with correct output.'); |
|
63 | 'Change bool widget value cell executed with correct output.'); | |
62 |
|
64 |
General Comments 0
You need to be logged in to leave comments.
Login now