Show More
@@ -45,15 +45,15 b' casper.notebook_test(function () {' | |||
|
45 | 45 | '.my-throttle-textbox'), 'Textbox exists.'); |
|
46 | 46 | |
|
47 | 47 | // Send 20 characters |
|
48 |
this.sendKeys('.my-throttle-textbox', '................... |
|
|
48 | this.sendKeys('.my-throttle-textbox', '....................'); | |
|
49 | 49 | }); |
|
50 | 50 | |
|
51 | 51 | this.waitFor(function check() { |
|
52 | 52 | var outputs = this.evaluate(function(i) { |
|
53 | 53 | return IPython.notebook.get_cell(i).output_area.outputs; |
|
54 | 54 | }, {i : throttle_index}); |
|
55 | var output = outputs[outputs.length-1].text; | |
|
56 |
return (output |
|
|
55 | var output = outputs[outputs.length-1].text.trim(); | |
|
56 | return (output == '20'); | |
|
57 | 57 | |
|
58 | 58 | }, function then() { |
|
59 | 59 | var outputs = this.evaluate(function(i) { |
@@ -34,11 +34,10 b' casper.notebook_test(function () {' | |||
|
34 | 34 | '.widget-area .widget-subarea button', 'click'); |
|
35 | 35 | }); |
|
36 | 36 | |
|
37 | this.waitFor(function check() { | |
|
38 | return (this.get_output_cell(button_index, 1).text == 'Clicked\n'); | |
|
39 |
|
|
|
40 | this.test.assert(true, 'Button click event fires.'); | |
|
41 | }), function timeout() { | |
|
42 | this.test.assert(false, 'Button click event fires.'); | |
|
37 | this.wait_for_output(button_index, 1); | |
|
38 | ||
|
39 | this.then(function () { | |
|
40 | this.test.assertEquals(this.get_output_cell(button_index, 1).text, 'Clicked\n', | |
|
41 | 'Button click event fires.'); | |
|
43 | 42 | }); |
|
44 | 43 | }); No newline at end of file |
@@ -6,72 +6,64 b' casper.notebook_test(function () {' | |||
|
6 | 6 | 'print("Success")'); |
|
7 | 7 | this.execute_cell_then(index); |
|
8 | 8 | |
|
9 | var float_text_query_2 = '.widget-area .widget-subarea .widget-hbox-single .my-second-float-text'; | |
|
10 | ||
|
11 |
|
|
|
9 | var float_text = {}; | |
|
10 | float_text.query = '.widget-area .widget-subarea .widget-hbox-single .my-second-float-text'; | |
|
11 | float_text.index = this.append_cell( | |
|
12 | 12 | 'float_widget = widgets.FloatTextWidget()\n' + |
|
13 | 13 | 'display(float_widget)\n' + |
|
14 | 14 | 'float_widget.add_class("my-second-float-text")\n' + |
|
15 |
'print( |
|
|
16 | this.execute_cell_then(float_index, function(index){ | |
|
17 | ||
|
18 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', | |
|
19 | 'Create float cell executed with correct output.'); | |
|
20 | ||
|
15 | 'print(float_widget.model_id)\n'); | |
|
16 | this.execute_cell_then(float_text.index, function(index){ | |
|
17 | float_text.model_id = this.get_output_cell(index).text.trim(); | |
|
18 | ||
|
21 | 19 | this.test.assert(this.cell_element_exists(index, |
|
22 | 20 | '.widget-area .widget-subarea'), |
|
23 | 21 | 'Widget subarea exists.'); |
|
24 | 22 | |
|
25 |
this.test.assert(this.cell_element_exists(index, float_text |
|
|
23 | this.test.assert(this.cell_element_exists(index, float_text.query), | |
|
26 | 24 | 'Widget float textbox exists.'); |
|
27 | 25 | |
|
28 |
this.cell_element_function(float_index, float_text |
|
|
29 |
this.sendKeys(float_text |
|
|
26 | this.cell_element_function(float_text.index, float_text.query, 'val', ['']); | |
|
27 | this.sendKeys(float_text.query, '1.05'); | |
|
30 | 28 | }); |
|
31 | 29 | |
|
32 | this.wait(500); // Wait for change to execute in kernel | |
|
30 | this.wait_for_widget(float_text); | |
|
33 | 31 | |
|
34 | 32 | index = this.append_cell('print(float_widget.value)\n'); |
|
35 | 33 | this.execute_cell_then(index, function(index){ |
|
36 | 34 | this.test.assertEquals(this.get_output_cell(index).text, '1.05\n', |
|
37 | 35 | 'Float textbox value set.'); |
|
38 |
this.cell_element_function(float_index, float_text |
|
|
39 |
this.sendKeys(float_text |
|
|
36 | this.cell_element_function(float_text.index, float_text.query, 'val', ['']); | |
|
37 | this.sendKeys(float_text.query, '123456789.0'); | |
|
40 | 38 | }); |
|
41 | 39 | |
|
42 | this.wait(500); // Wait for change to execute in kernel | |
|
43 | ||
|
40 | this.wait_for_widget(float_text); | |
|
41 | ||
|
44 | 42 | index = this.append_cell('print(float_widget.value)\n'); |
|
45 | 43 | this.execute_cell_then(index, function(index){ |
|
46 | 44 | this.test.assertEquals(this.get_output_cell(index).text, '123456789.0\n', |
|
47 | 45 | 'Long float textbox value set (probably triggers throttling).'); |
|
48 |
this.cell_element_function(float_index, float_text |
|
|
49 |
this.sendKeys(float_text |
|
|
46 | this.cell_element_function(float_text.index, float_text.query, 'val', ['']); | |
|
47 | this.sendKeys(float_text.query, '12hello'); | |
|
50 | 48 | }); |
|
51 | 49 | |
|
52 | this.wait(500); // Wait for change to execute in kernel | |
|
50 | this.wait_for_widget(float_text); | |
|
53 | 51 | |
|
54 | 52 | index = this.append_cell('print(float_widget.value)\n'); |
|
55 | 53 | this.execute_cell_then(index, function(index){ |
|
56 | 54 | this.test.assertEquals(this.get_output_cell(index).text, '12.0\n', |
|
57 | 55 | 'Invald float textbox value caught and filtered.'); |
|
58 | 56 | }); |
|
59 | ||
|
60 | index = this.append_cell( | |
|
61 | 'from IPython.html import widgets\n' + | |
|
62 | 'from IPython.display import display, clear_output\n' + | |
|
63 | 'print("Success")'); | |
|
64 | this.execute_cell_then(index); | |
|
65 | 57 | |
|
66 | var slider_query = '.widget-area .widget-subarea .widget-hbox-single .slider'; | |
|
67 | 58 | var float_text_query = '.widget-area .widget-subarea .widget-hbox-single .widget-numeric-text'; |
|
68 | ||
|
69 | var floatrange_index = this.append_cell( | |
|
59 | var slider = {}; | |
|
60 | slider.query = '.widget-area .widget-subarea .widget-hbox-single .slider'; | |
|
61 | slider.index = this.append_cell( | |
|
70 | 62 | 'floatrange = [widgets.BoundedFloatTextWidget(), \n' + |
|
71 | 63 | ' widgets.FloatSliderWidget()]\n' + |
|
72 | 64 | '[display(floatrange[i]) for i in range(2)]\n' + |
|
73 | 65 | 'print("Success")\n'); |
|
74 |
this.execute_cell_then( |
|
|
66 | this.execute_cell_then(slider.index, function(index){ | |
|
75 | 67 | |
|
76 | 68 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', |
|
77 | 69 | 'Create float range cell executed with correct output.'); |
@@ -80,7 +72,7 b' casper.notebook_test(function () {' | |||
|
80 | 72 | '.widget-area .widget-subarea'), |
|
81 | 73 | 'Widget subarea exists.'); |
|
82 | 74 | |
|
83 |
this.test.assert(this.cell_element_exists(index, slider |
|
|
75 | this.test.assert(this.cell_element_exists(index, slider.query), | |
|
84 | 76 | 'Widget slider exists.'); |
|
85 | 77 | |
|
86 | 78 | this.test.assert(this.cell_element_exists(index, float_text_query), |
@@ -98,10 +90,10 b' casper.notebook_test(function () {' | |||
|
98 | 90 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', |
|
99 | 91 | 'Float range properties cell executed with correct output.'); |
|
100 | 92 | |
|
101 |
this.test.assert(this.cell_element_exists( |
|
|
93 | this.test.assert(this.cell_element_exists(slider.index, slider.query), | |
|
102 | 94 | 'Widget slider exists.'); |
|
103 | 95 | |
|
104 |
this.test.assert(this.cell_element_function( |
|
|
96 | this.test.assert(this.cell_element_function(slider.index, slider.query, | |
|
105 | 97 | 'slider', ['value']) == 25.0, |
|
106 | 98 | 'Slider set to Python value.'); |
|
107 | 99 | }); |
@@ -6,50 +6,48 b' casper.notebook_test(function () {' | |||
|
6 | 6 | 'print("Success")'); |
|
7 | 7 | this.execute_cell_then(index); |
|
8 | 8 | |
|
9 | var int_text_query_2 = '.widget-area .widget-subarea .widget-hbox-single .my-second-int-text'; | |
|
10 | ||
|
11 |
|
|
|
9 | var int_text = {} | |
|
10 | int_text.query = '.widget-area .widget-subarea .widget-hbox-single .my-second-int-text'; | |
|
11 | int_text.index = this.append_cell( | |
|
12 | 12 | 'int_widget = widgets.IntTextWidget()\n' + |
|
13 | 13 | 'display(int_widget)\n' + |
|
14 | 14 | 'int_widget.add_class("my-second-int-text")\n' + |
|
15 |
'print( |
|
|
16 | this.execute_cell_then(int_index, function(index){ | |
|
17 | ||
|
18 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', | |
|
19 | 'Create int cell executed with correct output.'); | |
|
20 | ||
|
15 | 'print(int_widget.model_id)\n'); | |
|
16 | this.execute_cell_then(int_text.index, function(index){ | |
|
17 | int_text.model_id = this.get_output_cell(index).text.trim(); | |
|
18 | ||
|
21 | 19 | this.test.assert(this.cell_element_exists(index, |
|
22 | 20 | '.widget-area .widget-subarea'), |
|
23 | 21 | 'Widget subarea exists.'); |
|
24 | 22 | |
|
25 |
this.test.assert(this.cell_element_exists(index, int_text |
|
|
23 | this.test.assert(this.cell_element_exists(index, int_text.query), | |
|
26 | 24 | 'Widget int textbox exists.'); |
|
27 | 25 | |
|
28 |
this.cell_element_function(int_index, int_text |
|
|
29 |
this.sendKeys(int_text |
|
|
26 | this.cell_element_function(int_text.index, int_text.query, 'val', ['']); | |
|
27 | this.sendKeys(int_text.query, '1.05'); | |
|
30 | 28 | }); |
|
31 | 29 | |
|
32 | this.wait(500); // Wait for change to execute in kernel | |
|
30 | this.wait_for_widget(int_text); | |
|
33 | 31 | |
|
34 | 32 | index = this.append_cell('print(int_widget.value)\n'); |
|
35 | 33 | this.execute_cell_then(index, function(index){ |
|
36 | 34 | this.test.assertEquals(this.get_output_cell(index).text, '1\n', |
|
37 | 35 | 'Int textbox value set.'); |
|
38 |
this.cell_element_function(int_index, int_text |
|
|
39 |
this.sendKeys(int_text |
|
|
36 | this.cell_element_function(int_text.index, int_text.query, 'val', ['']); | |
|
37 | this.sendKeys(int_text.query, '123456789'); | |
|
40 | 38 | }); |
|
41 | 39 | |
|
42 | this.wait(500); // Wait for change to execute in kernel | |
|
40 | this.wait_for_widget(int_text); | |
|
43 | 41 | |
|
44 | 42 | index = this.append_cell('print(int_widget.value)\n'); |
|
45 | 43 | this.execute_cell_then(index, function(index){ |
|
46 | 44 | this.test.assertEquals(this.get_output_cell(index).text, '123456789\n', |
|
47 | 45 | 'Long int textbox value set (probably triggers throttling).'); |
|
48 |
this.cell_element_function(int_index, int_text |
|
|
49 |
this.sendKeys(int_text |
|
|
46 | this.cell_element_function(int_text.index, int_text.query, 'val', ['']); | |
|
47 | this.sendKeys(int_text.query, '12hello'); | |
|
50 | 48 | }); |
|
51 | 49 | |
|
52 | this.wait(500); // Wait for change to execute in kernel | |
|
50 | this.wait_for_widget(int_text); | |
|
53 | 51 | |
|
54 | 52 | index = this.append_cell('print(int_widget.value)\n'); |
|
55 | 53 | this.execute_cell_then(index, function(index){ |
@@ -63,19 +61,18 b' casper.notebook_test(function () {' | |||
|
63 | 61 | 'print("Success")'); |
|
64 | 62 | this.execute_cell_then(index); |
|
65 | 63 | |
|
66 | var slider_query = '.widget-area .widget-subarea .widget-hbox-single .slider'; | |
|
67 | var int_text_query = '.widget-area .widget-subarea .widget-hbox-single .my-second-num-test-text'; | |
|
68 | 64 | |
|
69 | var intrange_index = this.append_cell( | |
|
65 | var slider_query = '.widget-area .widget-subarea .widget-hbox-single .slider'; | |
|
66 | var int_text2 = {}; | |
|
67 | int_text2.query = '.widget-area .widget-subarea .widget-hbox-single .my-second-num-test-text'; | |
|
68 | int_text2.index = this.append_cell( | |
|
70 | 69 | 'intrange = [widgets.BoundedIntTextWidget(),\n' + |
|
71 | 70 | ' widgets.IntSliderWidget()]\n' + |
|
72 | 71 | '[display(intrange[i]) for i in range(2)]\n' + |
|
73 | 72 | 'intrange[0].add_class("my-second-num-test-text")\n' + |
|
74 |
'print( |
|
|
75 |
this.execute_cell_then(int |
|
|
76 | ||
|
77 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', | |
|
78 | 'Create int range cell executed with correct output.'); | |
|
73 | 'print(intrange[0].model_id)\n'); | |
|
74 | this.execute_cell_then(int_text2.index, function(index){ | |
|
75 | int_text2.model_id = this.get_output_cell(index).text.trim(); | |
|
79 | 76 | |
|
80 | 77 | this.test.assert(this.cell_element_exists(index, |
|
81 | 78 | '.widget-area .widget-subarea'), |
@@ -84,7 +81,7 b' casper.notebook_test(function () {' | |||
|
84 | 81 | this.test.assert(this.cell_element_exists(index, slider_query), |
|
85 | 82 | 'Widget slider exists.'); |
|
86 | 83 | |
|
87 |
this.test.assert(this.cell_element_exists(index, int_text |
|
|
84 | this.test.assert(this.cell_element_exists(index, int_text2.query), | |
|
88 | 85 | 'Widget int textbox exists.'); |
|
89 | 86 | }); |
|
90 | 87 | |
@@ -99,23 +96,23 b' casper.notebook_test(function () {' | |||
|
99 | 96 | this.test.assertEquals(this.get_output_cell(index).text, 'Success\n', |
|
100 | 97 | 'Int range properties cell executed with correct output.'); |
|
101 | 98 | |
|
102 |
this.test.assert(this.cell_element_exists(int |
|
|
99 | this.test.assert(this.cell_element_exists(int_text2.index, slider_query), | |
|
103 | 100 | 'Widget slider exists.'); |
|
104 | 101 | |
|
105 |
this.test.assert(this.cell_element_function(int |
|
|
102 | this.test.assert(this.cell_element_function(int_text2.index, slider_query, | |
|
106 | 103 | 'slider', ['value']) == 25, |
|
107 | 104 | 'Slider set to Python value.'); |
|
108 | 105 | |
|
109 |
this.test.assert(this.cell_element_function(int |
|
|
106 | this.test.assert(this.cell_element_function(int_text2.index, int_text2.query, | |
|
110 | 107 | 'val') == 25, 'Int textbox set to Python value.'); |
|
111 | 108 | |
|
112 | 109 | // Clear the int textbox value and then set it to 1 by emulating |
|
113 | 110 | // keyboard presses. |
|
114 |
this.cell_element_function(int |
|
|
115 |
this.sendKeys(int_text |
|
|
111 | this.cell_element_function(int_text2.index, int_text2.query, 'val', ['']); | |
|
112 | this.sendKeys(int_text2.query, '1'); | |
|
116 | 113 | }); |
|
117 | 114 | |
|
118 | this.wait(500); // Wait for change to execute in kernel | |
|
115 | this.wait_for_widget(int_text2); | |
|
119 | 116 | |
|
120 | 117 | index = this.append_cell('print(intrange[0].value)\n'); |
|
121 | 118 | this.execute_cell_then(index, function(index){ |
@@ -124,11 +121,11 b' casper.notebook_test(function () {' | |||
|
124 | 121 | |
|
125 | 122 | // Clear the int textbox value and then set it to 120 by emulating |
|
126 | 123 | // keyboard presses. |
|
127 |
this.cell_element_function(int |
|
|
128 |
this.sendKeys(int_text |
|
|
124 | this.cell_element_function(int_text2.index, int_text2.query, 'val', ['']); | |
|
125 | this.sendKeys(int_text2.query, '120'); | |
|
129 | 126 | }); |
|
130 | 127 | |
|
131 | this.wait(500); // Wait for change to execute in kernel | |
|
128 | this.wait_for_widget(int_text2); | |
|
132 | 129 | |
|
133 | 130 | index = this.append_cell('print(intrange[0].value)\n'); |
|
134 | 131 | this.execute_cell_then(index, function(index){ |
@@ -137,11 +134,11 b' casper.notebook_test(function () {' | |||
|
137 | 134 | |
|
138 | 135 | // Clear the int textbox value and then set it to 'hello world' by |
|
139 | 136 | // emulating keyboard presses. 'hello world' should get filtered... |
|
140 |
this.cell_element_function(int |
|
|
141 |
this.sendKeys(int_text |
|
|
137 | this.cell_element_function(int_text2.index, int_text2.query, 'val', ['']); | |
|
138 | this.sendKeys(int_text2.query, 'hello world'); | |
|
142 | 139 | }); |
|
143 | 140 | |
|
144 | this.wait(500); // Wait for change to execute in kernel | |
|
141 | this.wait_for_widget(int_text2); | |
|
145 | 142 | |
|
146 | 143 | index = this.append_cell('print(intrange[0].value)\n'); |
|
147 | 144 | this.execute_cell_then(index, function(index){ |
@@ -36,7 +36,7 b' casper.notebook_test(function () {' | |||
|
36 | 36 | this.click(multicontainer1_query + ' li:nth-child(2) a'); |
|
37 | 37 | }); |
|
38 | 38 | |
|
39 | this.wait(500); // Wait for change to execute in kernel | |
|
39 | this.wait_for_idle(); | |
|
40 | 40 | |
|
41 | 41 | index = this.append_cell( |
|
42 | 42 | 'print(multicontainer.selected_index)\n' + |
@@ -98,7 +98,7 b' casper.notebook_test(function () {' | |||
|
98 | 98 | this.click(multicontainer2_query + ' .accordion-group:nth-child(2) .accordion-heading .accordion-toggle'); |
|
99 | 99 | }); |
|
100 | 100 | |
|
101 | this.wait(500); // Wait for change to execute in kernel | |
|
101 | this.wait_for_idle(); | |
|
102 | 102 | |
|
103 | 103 | index = this.append_cell('print(multicontainer.selected_index)'); // 0 based |
|
104 | 104 | this.execute_cell_then(index, function(index){ |
@@ -93,33 +93,33 b' casper.notebook_test(function () {' | |||
|
93 | 93 | // Verify that selecting a radio button updates all of the others. |
|
94 | 94 | this.cell_element_function(selection_index, radio_selector + ' .radio:nth-child(2) input', 'click'); |
|
95 | 95 | }); |
|
96 |
this.wait( |
|
|
96 | this.wait_for_idle(); | |
|
97 | 97 | this.then(function () { |
|
98 | 98 | this.test.assert(verify_selection(this, 1), 'Radio button selection updated view states correctly.'); |
|
99 | 99 | |
|
100 | 100 | // Verify that selecting a list option updates all of the others. |
|
101 | 101 | this.cell_element_function(selection_index, list_selector + ' option:nth-child(3)', 'click'); |
|
102 | 102 | }); |
|
103 |
this.wait( |
|
|
103 | this.wait_for_idle(); | |
|
104 | 104 | this.then(function () { |
|
105 | 105 | this.test.assert(verify_selection(this, 2), 'List selection updated view states correctly.'); |
|
106 | 106 | |
|
107 | 107 | // Verify that selecting a multibutton option updates all of the others. |
|
108 | 108 | this.cell_element_function(selection_index, multibtn_selector + ' .btn:nth-child(4)', 'click'); |
|
109 | 109 | }); |
|
110 |
this.wait( |
|
|
110 | this.wait_for_idle(); | |
|
111 | 111 | this.then(function () { |
|
112 | 112 | this.test.assert(verify_selection(this, 3), 'Multibutton selection updated view states correctly.'); |
|
113 | 113 | |
|
114 | 114 | // Verify that selecting a combobox option updates all of the others. |
|
115 | 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 | 116 | }); |
|
117 |
this.wait( |
|
|
117 | this.wait_for_idle(); | |
|
118 | 118 | this.then(function () { |
|
119 | 119 | this.test.assert(verify_selection(this, 2), 'Combobox selection updated view states correctly.'); |
|
120 | 120 | }); |
|
121 | 121 | |
|
122 | this.wait(500); // Wait for change to execute in kernel | |
|
122 | this.wait_for_idle(); | |
|
123 | 123 | |
|
124 | 124 | index = this.append_cell( |
|
125 | 125 | 'for widget in selection:\n' + |
@@ -94,6 +94,27 b' casper.wait_for_output = function (cell_num, out_num) {' | |||
|
94 | 94 | }); |
|
95 | 95 | }; |
|
96 | 96 | |
|
97 | // wait for a widget msg que to reach 0 | |
|
98 | // | |
|
99 | // Parameters | |
|
100 | // ---------- | |
|
101 | // widget_info : object | |
|
102 | // Object which contains info related to the widget. The model_id property | |
|
103 | // is used to identify the widget. | |
|
104 | casper.wait_for_widget = function (widget_info) { | |
|
105 | this.waitFor(function () { | |
|
106 | var pending = this.evaluate(function (m) { | |
|
107 | return IPython.notebook.kernel.widget_manager.get_model(m).pending_msgs; | |
|
108 | }, {m: widget_info.model_id}); | |
|
109 | ||
|
110 | if (pending == 0) { | |
|
111 | return true; | |
|
112 | } else { | |
|
113 | return false; | |
|
114 | } | |
|
115 | }); | |
|
116 | } | |
|
117 | ||
|
97 | 118 | // return an output of a given cell |
|
98 | 119 | casper.get_output_cell = function (cell_num, out_num) { |
|
99 | 120 | out_num = out_num || 0; |
General Comments 0
You need to be logged in to leave comments.
Login now