Show More
@@ -73,7 +73,7 b' casper.notebook_test(function () {' | |||||
73 | // Utility functions. |
|
73 | // Utility functions. | |
74 | this.validate_state = function(message, mode, cell_index) { |
|
74 | this.validate_state = function(message, mode, cell_index) { | |
75 | // General tests. |
|
75 | // General tests. | |
76 |
this.test.assertEquals(this. |
|
76 | this.test.assertEquals(this.get_keyboard_mode(), this.get_notebook_mode(), | |
77 | message + '; keyboard and notebook modes match'); |
|
77 | message + '; keyboard and notebook modes match'); | |
78 | // Is codemirror focused appropriately? |
|
78 | // Is codemirror focused appropriately? | |
79 | this.test.assert(this.is_editor_focus_valid(), message + '; cell editor focused appropriately'); |
|
79 | this.test.assert(this.is_editor_focus_valid(), message + '; cell editor focused appropriately'); | |
@@ -86,7 +86,7 b' casper.notebook_test(function () {' | |||||
86 | // Mode specific tests. |
|
86 | // Mode specific tests. | |
87 | if (mode==='command') { |
|
87 | if (mode==='command') { | |
88 | // Are the notebook and keyboard manager in command mode? |
|
88 | // Are the notebook and keyboard manager in command mode? | |
89 |
this.test.assertEquals(this. |
|
89 | this.test.assertEquals(this.get_keyboard_mode(), 'command', | |
90 | message + '; in command mode'); |
|
90 | message + '; in command mode'); | |
91 | // Make sure there isn't a single cell in edit mode. |
|
91 | // Make sure there isn't a single cell in edit mode. | |
92 | this.test.assert(this.is_cell_edit(null), |
|
92 | this.test.assert(this.is_cell_edit(null), | |
@@ -94,7 +94,7 b' casper.notebook_test(function () {' | |||||
94 |
|
94 | |||
95 | } else if (mode==='edit') { |
|
95 | } else if (mode==='edit') { | |
96 | // Are the notebook and keyboard manager in edit mode? |
|
96 | // Are the notebook and keyboard manager in edit mode? | |
97 |
this.test.assertEquals(this. |
|
97 | this.test.assertEquals(this.get_keyboard_mode(), 'edit', | |
98 | message + '; in edit mode'); |
|
98 | message + '; in edit mode'); | |
99 | // Is the specified cell the only cell in edit mode? |
|
99 | // Is the specified cell the only cell in edit mode? | |
100 | if (cell_index!==undefined) { |
|
100 | if (cell_index!==undefined) { | |
@@ -108,7 +108,7 b' casper.notebook_test(function () {' | |||||
108 | }; |
|
108 | }; | |
109 |
|
109 | |||
110 | this.is_editor_focus_valid = function() { |
|
110 | this.is_editor_focus_valid = function() { | |
111 |
var cells = this. |
|
111 | var cells = this.get_cells(); | |
112 | for (var i = 0; i < cells.length; i++) { |
|
112 | for (var i = 0; i < cells.length; i++) { | |
113 | if (!this.is_cell_editor_focus_valid(i)) { |
|
113 | if (!this.is_cell_editor_focus_valid(i)) { | |
114 | return false; |
|
114 | return false; | |
@@ -117,24 +117,24 b' casper.notebook_test(function () {' | |||||
117 | return true; |
|
117 | return true; | |
118 | }; |
|
118 | }; | |
119 |
|
119 | |||
120 | this.is_cell_editor_focus_valid = function(i) { |
|
120 | this.is_cell_editor_focus_valid = function(index) { | |
121 |
var cell = this. |
|
121 | var cell = this.get_cell(index); | |
122 | if (cell) { |
|
122 | if (cell) { | |
123 | if (cell.mode == 'edit') { |
|
123 | if (cell.mode == 'edit') { | |
124 | return this.is_cell_editor_focused(i); |
|
124 | return this.is_cell_editor_focused(index); | |
125 | } else { |
|
125 | } else { | |
126 | return !this.is_cell_editor_focused(i); |
|
126 | return !this.is_cell_editor_focused(index); | |
127 | } |
|
127 | } | |
128 | } |
|
128 | } | |
129 | return true; |
|
129 | return true; | |
130 | }; |
|
130 | }; | |
131 |
|
131 | |||
132 | this.is_cell_selected = function(i) { |
|
132 | this.is_cell_selected = function(index) { | |
133 | return this.is_cell_on(i, 'selected', 'unselected'); |
|
133 | return this.is_cell_on(index, 'selected', 'unselected'); | |
134 | }; |
|
134 | }; | |
135 |
|
135 | |||
136 | this.is_cell_edit = function(i) { |
|
136 | this.is_cell_edit = function(index) { | |
137 | return this.is_cell_on(i, 'edit_mode', 'command_mode'); |
|
137 | return this.is_cell_on(index, 'edit_mode', 'command_mode'); | |
138 | }; |
|
138 | }; | |
139 |
|
139 | |||
140 | this.click_cell = function(index) { |
|
140 | this.click_cell = function(index) { | |
@@ -161,12 +161,12 b' casper.notebook_test(function () {' | |||||
161 | }, {k: key}); |
|
161 | }, {k: key}); | |
162 | }; |
|
162 | }; | |
163 |
|
163 | |||
164 | this.is_cell_editor_focused = function(i) { |
|
164 | this.is_cell_editor_focused = function(index) { | |
165 | return this._is_cell_inputfield(i, '.CodeMirror-focused *'); |
|
165 | return this._is_cell_inputfield(index, '.CodeMirror-focused *'); | |
166 | }; |
|
166 | }; | |
167 |
|
167 | |||
168 | this.is_cell_on = function(i, on_class, off_class) { |
|
168 | this.is_cell_on = function(i, on_class, off_class) { | |
169 |
var cells = this. |
|
169 | var cells = this.get_cells(); | |
170 | for (var j = 0; j < cells.length; j++) { |
|
170 | for (var j = 0; j < cells.length; j++) { | |
171 | if (j === i) { |
|
171 | if (j === i) { | |
172 | if (this._has_cell_class(j, off_class) || !this._has_cell_class(j, on_class)) { |
|
172 | if (this._has_cell_class(j, off_class) || !this._has_cell_class(j, on_class)) { | |
@@ -181,25 +181,25 b' casper.notebook_test(function () {' | |||||
181 | return true; |
|
181 | return true; | |
182 | }; |
|
182 | }; | |
183 |
|
183 | |||
184 |
this. |
|
184 | this.get_keyboard_mode = function() { | |
185 | return this.evaluate(function() { |
|
185 | return this.evaluate(function() { | |
186 | return IPython.keyboard_manager.mode; |
|
186 | return IPython.keyboard_manager.mode; | |
187 | }, {}); |
|
187 | }, {}); | |
188 | }; |
|
188 | }; | |
189 |
|
189 | |||
190 |
this. |
|
190 | this.get_notebook_mode = function() { | |
191 | return this.evaluate(function() { |
|
191 | return this.evaluate(function() { | |
192 | return IPython.notebook.mode; |
|
192 | return IPython.notebook.mode; | |
193 | }, {}); |
|
193 | }, {}); | |
194 | }; |
|
194 | }; | |
195 |
|
195 | |||
196 |
this. |
|
196 | this.get_cells = function() { | |
197 | return this.evaluate(function() { |
|
197 | return this.evaluate(function() { | |
198 | return IPython.notebook.get_cells(); |
|
198 | return IPython.notebook.get_cells(); | |
199 | }, {}); |
|
199 | }, {}); | |
200 | }; |
|
200 | }; | |
201 |
|
201 | |||
202 |
this. |
|
202 | this.get_cell = function(index) { | |
203 | return this.evaluate(function(i) { |
|
203 | return this.evaluate(function(i) { | |
204 | var cell = IPython.notebook.get_cell(i); |
|
204 | var cell = IPython.notebook.get_cell(i); | |
205 | if (cell) { |
|
205 | if (cell) { |
General Comments 0
You need to be logged in to leave comments.
Login now