##// END OF EJS Templates
utility functions + tests for shift- & ctrl-enter
Paul Ivanov -
Show More
@@ -365,6 +365,16 b' IPython.utils = (function (IPython) {'
365 var press_up = function() { press(keycodes.UP); };
365 var press_up = function() { press(keycodes.UP); };
366 var press_down = function() { press(keycodes.DOWN); };
366 var press_down = function() { press(keycodes.DOWN); };
367
367
368 var press_ctrl_enter = function() {
369 $(document).trigger($.Event('keydown', {which: keycodes.ENTER, ctrlKey: true}));
370 };
371
372 var press_shift_enter = function() {
373 $(document).trigger($.Event('keydown', {which: keycodes.ENTER, shiftKey: true}));
374 };
375 // trigger the ctrl-m shortcut followed by one of our keys
376 var press_ghetto = function(key) { presspress(key); };
377
368
378
369 var points_to_pixels = function (points) {
379 var points_to_pixels = function (points) {
370 // A reasonably good way of converting between points and pixels.
380 // A reasonably good way of converting between points and pixels.
@@ -423,6 +433,8 b' IPython.utils = (function (IPython) {'
423 press : press,
433 press : press,
424 press_up : press_up,
434 press_up : press_up,
425 press_down : press_down,
435 press_down : press_down,
436 press_ctrl_enter : press_ctrl_enter,
437 press_shift_enter : press_shift_enter,
426 fixCarriageReturn : fixCarriageReturn,
438 fixCarriageReturn : fixCarriageReturn,
427 autoLinkUrls : autoLinkUrls,
439 autoLinkUrls : autoLinkUrls,
428 points_to_pixels : points_to_pixels,
440 points_to_pixels : points_to_pixels,
@@ -30,7 +30,7 b' casper.notebook_test(function () {'
30 var cell = IPython.notebook.get_cell(0);
30 var cell = IPython.notebook.get_cell(0);
31 cell.set_text('a=11; print(a)');
31 cell.set_text('a=11; print(a)');
32 cell.clear_output()
32 cell.clear_output()
33 $(document).trigger($.Event('keydown', {which: 13, ctrlKey: true}))
33 IPython.utils.press_ctrl_enter();
34 });
34 });
35
35
36 this.waitFor(function () {
36 this.waitFor(function () {
@@ -48,4 +48,28 b' casper.notebook_test(function () {'
48 })
48 })
49 this.test.assertEquals(result, '11\n', 'cell execute (using ctrl-enter)')
49 this.test.assertEquals(result, '11\n', 'cell execute (using ctrl-enter)')
50 });
50 });
51
52 // do it again with the keyboard shortcut
53 this.thenEvaluate(function () {
54 var cell = IPython.notebook.get_cell(0);
55 cell.set_text('a=12; print(a)');
56 cell.clear_output()
57 IPython.utils.press_shift_enter();
58 });
59
60 this.waitFor(function () {
61 return this.evaluate(function get_output() {
62 var cell = IPython.notebook.get_cell(0);
63 return cell.output_area.outputs.length != 0;
64 })
65 });
66
67 this.then(function () {
68 var result = this.evaluate(function () {
69 var cell = IPython.notebook.get_cell(0);
70 var output = cell.output_area.outputs[0].text;
71 return output;
72 })
73 this.test.assertEquals(result, '12\n', 'cell execute (using shift-enter)')
74 });
51 });
75 });
General Comments 0
You need to be logged in to leave comments. Login now