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