##// END OF EJS Templates
Removed float widget bound tests,...
Jonathan Frederic -
Show More
@@ -1,147 +1,108 b''
1 1 // Test widget float class
2 2 casper.notebook_test(function () {
3 3 index = this.append_cell(
4 4 'from IPython.html import widgets\n' +
5 5 'from IPython.display import display, clear_output\n' +
6 6 'print("Success")');
7 7 this.execute_cell_then(index);
8 8
9 9 var float_text_query_2 = '.widget-area .widget-subarea .widget-hbox-single .my-second-float-text';
10 10
11 11 var float_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 15 'print("Success")\n');
16 16 this.execute_cell_then(float_index, function(index){
17 17
18 18 this.test.assert(this.get_output_cell(index).text == 'Success\n',
19 19 'Create float cell executed with correct output.');
20 20
21 21 this.test.assert(this.cell_element_exists(index,
22 22 '.widget-area .widget-subarea'),
23 23 'Widget subarea exists.');
24 24
25 25 this.test.assert(this.cell_element_exists(index, float_text_query_2),
26 26 'Widget float textbox exists.');
27 27
28 28 this.cell_element_function(float_index, float_text_query_2, 'val', ['']);
29 29 this.sendKeys(float_text_query_2, '1.05');
30 30 });
31 31
32 32 this.wait(500); // Wait for change to execute in kernel
33 33
34 34 index = this.append_cell('print(float_widget.value)\n');
35 35 this.execute_cell_then(index, function(index){
36 36 this.test.assert(this.get_output_cell(index).text == '1.05\n',
37 37 'Float textbox value set.');
38 38 this.cell_element_function(float_index, float_text_query_2, 'val', ['']);
39 39 this.sendKeys(float_text_query_2, '123456789.0');
40 40 });
41 41
42 42 this.wait(500); // Wait for change to execute in kernel
43 43
44 44 index = this.append_cell('print(float_widget.value)\n');
45 45 this.execute_cell_then(index, function(index){
46 46 this.test.assert(this.get_output_cell(index).text == '123456789.0\n',
47 47 'Long float textbox value set (probably triggers throttling).');
48 48 this.cell_element_function(float_index, float_text_query_2, 'val', ['']);
49 49 this.sendKeys(float_text_query_2, '12hello');
50 50 });
51 51
52 52 this.wait(500); // Wait for change to execute in kernel
53 53
54 54 index = this.append_cell('print(float_widget.value)\n');
55 55 this.execute_cell_then(index, function(index){
56 56 this.test.assert(this.get_output_cell(index).text == '12.0\n',
57 57 'Invald float textbox value caught and filtered.');
58 58 });
59 59
60 60 index = this.append_cell(
61 61 'from IPython.html import widgets\n' +
62 62 'from IPython.display import display, clear_output\n' +
63 63 'print("Success")');
64 64 this.execute_cell_then(index);
65 65
66 66 var slider_query = '.widget-area .widget-subarea .widget-hbox-single .slider';
67 67 var float_text_query = '.widget-area .widget-subarea .widget-hbox-single .widget-numeric-text';
68 68
69 69 var floatrange_index = this.append_cell(
70 70 'floatrange = [widgets.BoundedFloatTextWidget(), \n' +
71 71 ' widgets.FloatSliderWidget()]\n' +
72 72 '[display(floatrange[i]) for i in range(2)]\n' +
73 73 'print("Success")\n');
74 74 this.execute_cell_then(floatrange_index, function(index){
75 75
76 76 this.test.assert(this.get_output_cell(index).text == 'Success\n',
77 77 'Create float range cell executed with correct output.');
78 78
79 79 this.test.assert(this.cell_element_exists(index,
80 80 '.widget-area .widget-subarea'),
81 81 'Widget subarea exists.');
82 82
83 83 this.test.assert(this.cell_element_exists(index, slider_query),
84 84 'Widget slider exists.');
85 85
86 86 this.test.assert(this.cell_element_exists(index, float_text_query),
87 87 'Widget float textbox exists.');
88 88 });
89 89
90 90 index = this.append_cell(
91 91 'for widget in floatrange:\n' +
92 92 ' widget.max = 50.0\n' +
93 93 ' widget.min = -50.0\n' +
94 ' widget.value = 20.0\n' +
94 ' widget.value = 25.0\n' +
95 95 'print("Success")\n');
96 96 this.execute_cell_then(index, function(index){
97 97
98 98 this.test.assert(this.get_output_cell(index).text == 'Success\n',
99 99 'Float range properties cell executed with correct output.');
100 100
101 101 this.test.assert(this.cell_element_exists(floatrange_index, slider_query),
102 102 'Widget slider exists.');
103 103
104 104 this.test.assert(this.cell_element_function(floatrange_index, slider_query,
105 'slider', ['value']) == 20.0,
105 'slider', ['value']) == 25.0,
106 106 'Slider set to Python value.');
107
108 // Clear the float textbox value and then set it to 1 by emulating
109 // keyboard presses.
110 this.cell_element_function(floatrange_index, float_text_query, 'val', ['']);
111 this.sendKeys(float_text_query, '1');
112 });
113
114 this.wait(1500); // Wait for change to execute in kernel
115
116 index = this.append_cell('for widget in floatrange:\n print(widget.value)\n');
117 this.execute_cell_then(index, function(index){
118 this.test.assert(this.get_output_cell(index).text == '1.0\n20.0\n',
119 'Float textbox set float range value');
120
121 // Clear the float textbox value and then set it to 120 by emulating
122 // keyboard presses.
123 this.cell_element_function(floatrange_index, float_text_query, 'val', ['']);
124 this.sendKeys(float_text_query, '120');
125 });
126
127 this.wait(500); // Wait for change to execute in kernel
128
129 index = this.append_cell('print(floatrange[0].value)\n');
130 this.execute_cell_then(index, function(index){
131 this.test.assert(this.get_output_cell(index).text == '50.0\n',
132 'Float textbox value bound');
133
134 // Clear the float textbox value and then set it to 'hello world' by
135 // emulating keyboard presses. 'hello world' should get filtered...
136 this.cell_element_function(floatrange_index, float_text_query, 'val', ['']);
137 this.sendKeys(float_text_query, 'hello world');
138 });
139
140 this.wait(500); // Wait for change to execute in kernel
141
142 index = this.append_cell('print(floatrange[0].value)\n');
143 this.execute_cell_then(index, function(index){
144 this.test.assert(this.get_output_cell(index).text == '50.0\n',
145 'Invalid float textbox characters ignored');
146 107 });
147 108 }); No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now