|
|
|
|
@ -395,7 +395,7 @@ casper.validate_notebook_state = function(message, mode, cell_index) {
|
|
|
|
|
if (cell_index!==undefined) {
|
|
|
|
|
// Is the specified cell the only cell in edit mode?
|
|
|
|
|
this.test.assert(this.is_only_cell_edit(cell_index),
|
|
|
|
|
message + '; cell ' + cell_index + ' is the only cell in edit mode');
|
|
|
|
|
message + '; cell ' + cell_index + ' is the only cell in edit mode '+ this.cells_modes());
|
|
|
|
|
// Is the specified cell the only cell with a focused code mirror?
|
|
|
|
|
this.test.assert(this.is_cell_editor_focused(cell_index),
|
|
|
|
|
message + '; cell ' + cell_index + '\'s editor is appropriately focused');
|
|
|
|
|
@ -506,7 +506,19 @@ casper.is_only_cell_selected = function(index) {
|
|
|
|
|
casper.is_only_cell_edit = function(index) {
|
|
|
|
|
// Check if a cell is the only cell in edit mode.
|
|
|
|
|
// Pass null as the index to check if all of the cells are in command mode.
|
|
|
|
|
return this.is_only_cell_on(index, 'edit_mode', 'command_mode');
|
|
|
|
|
var cells_length = this.get_cells_length();
|
|
|
|
|
for (var j = 0; j < cells_length; j++) {
|
|
|
|
|
if (j === index) {
|
|
|
|
|
if (!this.cell_mode_is(j, 'edit')) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (this.cell_mode_is(j, 'edit')) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
casper.is_only_cell_on = function(i, on_class, off_class) {
|
|
|
|
|
@ -528,6 +540,24 @@ casper.is_only_cell_on = function(i, on_class, off_class) {
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
casper.cells_modes = function(){
|
|
|
|
|
return this.evaluate(function(){
|
|
|
|
|
return IPython.notebook.get_cells().map(function(x,c){return x.mode})
|
|
|
|
|
}, {});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
casper.cell_mode_is = function(index, mode) {
|
|
|
|
|
// Check if a cell is in a specific mode
|
|
|
|
|
return this.evaluate(function(i, m) {
|
|
|
|
|
var cell = IPython.notebook.get_cell(i);
|
|
|
|
|
if (cell) {
|
|
|
|
|
return cell.mode === m;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}, {i : index, m: mode});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
casper.cell_has_class = function(index, classes) {
|
|
|
|
|
// Check if a cell has a class.
|
|
|
|
|
return this.evaluate(function(i, c) {
|
|
|
|
|
|