Show More
@@ -1,7 +1,7 b'' | |||
|
1 | 1 | // Test the widget framework. |
|
2 | 2 | casper.notebook_test(function () { |
|
3 | 3 | var index; |
|
4 | ||
|
4 | ||
|
5 | 5 | // Test widget dependencies //////////////////////////////////////////////// |
|
6 | 6 | this.then(function () { |
|
7 | 7 | |
@@ -11,11 +11,11 b' casper.notebook_test(function () {' | |||
|
11 | 11 | }), 'WidgetManager class is defined'); |
|
12 | 12 | }); |
|
13 | 13 | |
|
14 | index = append_cell( | |
|
14 | index = this.append_cell( | |
|
15 | 15 | 'from IPython.html import widgets\n' + |
|
16 | 16 | 'from IPython.display import display, clear_output\n' + |
|
17 | 17 | 'print("Success")'); |
|
18 | execute_cell_then(index); | |
|
18 | this.execute_cell_then(index); | |
|
19 | 19 | |
|
20 | 20 | this.wait(500); // Wait for require.js async callbacks to load dependencies. |
|
21 | 21 | |
@@ -28,12 +28,12 b' casper.notebook_test(function () {' | |||
|
28 | 28 | |
|
29 | 29 | |
|
30 | 30 | // Check widget mapping //////////////////////////////////////////////////// |
|
31 | index = append_cell( | |
|
31 | index = this.append_cell( | |
|
32 | 32 | 'names = [name for name in dir(widgets)' + |
|
33 | 33 | ' if name.endswith("Widget") and name!= "Widget"]\n' + |
|
34 | 34 | 'for name in names:\n' + |
|
35 | 35 | ' print(name)\n'); |
|
36 | execute_cell_then(index, function(index){ | |
|
36 | this.execute_cell_then(index, function(index){ | |
|
37 | 37 | |
|
38 | 38 | // Get the widget names that are registered with the widget manager. Assume |
|
39 | 39 | // a 1 to 1 mapping of model and widgets names (model names just have 'model' |
@@ -80,52 +80,52 b' casper.notebook_test(function () {' | |||
|
80 | 80 | |
|
81 | 81 | |
|
82 | 82 | // Test button widget ////////////////////////////////////////////////////// |
|
83 |
var button_ |
|
|
83 | var button_index = this.append_cell( | |
|
84 | 84 | 'button = widgets.ButtonWidget(description="Title")\n' + |
|
85 | 85 | 'display(button)\n'+ |
|
86 | 86 | 'print("Success")\n' + |
|
87 | 87 | 'def handle_click(sender):\n' + |
|
88 | 88 | ' print("Clicked")\n' + |
|
89 | 89 | 'button.on_click(handle_click)'); |
|
90 |
execute_cell_then(button_ |
|
|
90 | this.execute_cell_then(button_index, function(index){ | |
|
91 | 91 | |
|
92 | 92 | var button_output = this.get_output_cell(index).text; |
|
93 | 93 | this.test.assert(button_output == 'Success\n', |
|
94 | 94 | 'Create button widget, cell executed with correct output.'); |
|
95 | 95 | |
|
96 | this.test.assert(cell_element_exists(index, | |
|
96 | this.test.assert(this.cell_element_exists(index, | |
|
97 | 97 | '.widget-area .widget-subarea'), |
|
98 | 98 | 'Create button widget, widget subarea exist.'); |
|
99 | 99 | |
|
100 | this.test.assert(cell_element_exists(index, | |
|
100 | this.test.assert(this.cell_element_exists(index, | |
|
101 | 101 | '.widget-area .widget-subarea button'), |
|
102 | 102 | 'Create button widget, widget button exist.'); |
|
103 | 103 | |
|
104 | this.test.assert(cell_element_function(index, | |
|
104 | this.test.assert(this.cell_element_function(index, | |
|
105 | 105 | '.widget-area .widget-subarea button', 'html')=='Title', |
|
106 | 106 | 'Set button description.'); |
|
107 | 107 | |
|
108 | cell_element_function(index, | |
|
108 | this.cell_element_function(index, | |
|
109 | 109 | '.widget-area .widget-subarea button', 'click'); |
|
110 | 110 | }); |
|
111 | 111 | |
|
112 | 112 | this.wait(500); // Wait for click to execute in kernel and write output |
|
113 | 113 | |
|
114 | 114 | this.then(function () { |
|
115 |
this.test.assert(this.get_output_cell(button_ |
|
|
115 | this.test.assert(this.get_output_cell(button_index, 1).text == 'Clicked\n', | |
|
116 | 116 | 'Button click event fires.'); |
|
117 | 117 | }); |
|
118 | 118 | |
|
119 | index = append_cell( | |
|
119 | index = this.append_cell( | |
|
120 | 120 | 'button.close()\n'+ |
|
121 | 121 | 'print("Success")\n'); |
|
122 | execute_cell_then(index, function(index){ | |
|
122 | this.execute_cell_then(index, function(index){ | |
|
123 | 123 | |
|
124 | 124 | var button_output = this.get_output_cell(index).text; |
|
125 | 125 | this.test.assert(button_output == 'Success\n', |
|
126 | 126 | 'Close button, cell executed with correct output.'); |
|
127 | 127 | |
|
128 |
this.test.assert(! cell_element_exists(button_ |
|
|
128 | this.test.assert(! this.cell_element_exists(button_index, | |
|
129 | 129 | '.widget-area .widget-subarea button'), |
|
130 | 130 | 'Remove button, widget button doesn\'t exist.'); |
|
131 | 131 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now