Show More
@@ -1,79 +1,84 b'' | |||||
1 | // Test the notebook dual mode feature. |
|
1 | // Test the notebook dual mode feature. | |
2 |
|
2 | |||
3 | // Test |
|
3 | // Test | |
4 | casper.notebook_test(function () { |
|
4 | casper.notebook_test(function () { | |
5 | var a = 'print("a")'; |
|
5 | var a = 'print("a")'; | |
6 | var index = this.append_cell(a); |
|
6 | var index = this.append_cell(a); | |
7 | this.execute_cell_then(index); |
|
7 | this.execute_cell_then(index); | |
8 |
|
8 | |||
9 | var b = 'print("b")'; |
|
9 | var b = 'print("b")'; | |
10 | index = this.append_cell(b); |
|
10 | index = this.append_cell(b); | |
11 | this.execute_cell_then(index); |
|
11 | this.execute_cell_then(index); | |
12 |
|
12 | |||
13 | var c = 'print("c")'; |
|
13 | var c = 'print("c")'; | |
14 | index = this.append_cell(c); |
|
14 | index = this.append_cell(c); | |
15 | this.execute_cell_then(index); |
|
15 | this.execute_cell_then(index); | |
16 |
|
16 | |||
17 | this.then(function () { |
|
17 | this.then(function () { | |
|
18 | // When running in xvfb, the Slimer window doesn't always have focus | |||
|
19 | // immediately. By clicking on a new element on the page we ccan force | |||
|
20 | // it to gain focus. | |||
18 | this.click_cell_editor(1); |
|
21 | this.click_cell_editor(1); | |
19 | this.click_cell_editor(0); |
|
22 | this.click_cell_editor(0); | |
|
23 | ||||
|
24 | this.validate_notebook_state('initial state', 'edit', 0); | |||
20 | this.trigger_keydown('esc'); |
|
25 | this.trigger_keydown('esc'); | |
21 | this.validate_notebook_state('esc', 'command', 0); |
|
26 | this.validate_notebook_state('esc', 'command', 0); | |
22 | this.trigger_keydown('down'); |
|
27 | this.trigger_keydown('down'); | |
23 | this.validate_notebook_state('down', 'command', 1); |
|
28 | this.validate_notebook_state('down', 'command', 1); | |
24 | this.trigger_keydown('enter'); |
|
29 | this.trigger_keydown('enter'); | |
25 | this.validate_notebook_state('enter', 'edit', 1); |
|
30 | this.validate_notebook_state('enter', 'edit', 1); | |
26 | this.trigger_keydown('j'); |
|
31 | this.trigger_keydown('j'); | |
27 | this.validate_notebook_state('j in edit mode', 'edit', 1); |
|
32 | this.validate_notebook_state('j in edit mode', 'edit', 1); | |
28 | this.trigger_keydown('esc'); |
|
33 | this.trigger_keydown('esc'); | |
29 | this.validate_notebook_state('esc', 'command', 1); |
|
34 | this.validate_notebook_state('esc', 'command', 1); | |
30 | this.trigger_keydown('j'); |
|
35 | this.trigger_keydown('j'); | |
31 | this.validate_notebook_state('j in command mode', 'command', 2); |
|
36 | this.validate_notebook_state('j in command mode', 'command', 2); | |
32 | this.click_cell_editor(0); |
|
37 | this.click_cell_editor(0); | |
33 | this.validate_notebook_state('click cell 0', 'edit', 0); |
|
38 | this.validate_notebook_state('click cell 0', 'edit', 0); | |
34 | this.click_cell_editor(3); |
|
39 | this.click_cell_editor(3); | |
35 | this.validate_notebook_state('click cell 3', 'edit', 3); |
|
40 | this.validate_notebook_state('click cell 3', 'edit', 3); | |
36 | this.trigger_keydown('esc'); |
|
41 | this.trigger_keydown('esc'); | |
37 | this.validate_notebook_state('esc', 'command', 3); |
|
42 | this.validate_notebook_state('esc', 'command', 3); | |
38 |
|
43 | |||
39 | // Open keyboard help |
|
44 | // Open keyboard help | |
40 | this.evaluate(function(){ |
|
45 | this.evaluate(function(){ | |
41 | $('#keyboard_shortcuts a').click(); |
|
46 | $('#keyboard_shortcuts a').click(); | |
42 | }, {}); |
|
47 | }, {}); | |
43 |
|
48 | |||
44 | this.trigger_keydown('k'); |
|
49 | this.trigger_keydown('k'); | |
45 | this.validate_notebook_state('k in command mode while keyboard help is up', 'command', 3); |
|
50 | this.validate_notebook_state('k in command mode while keyboard help is up', 'command', 3); | |
46 |
|
51 | |||
47 | // Close keyboard help |
|
52 | // Close keyboard help | |
48 | this.evaluate(function(){ |
|
53 | this.evaluate(function(){ | |
49 | $('div.modal button.close').click(); |
|
54 | $('div.modal button.close').click(); | |
50 | }, {}); |
|
55 | }, {}); | |
51 |
|
56 | |||
52 | this.trigger_keydown('k'); |
|
57 | this.trigger_keydown('k'); | |
53 | this.validate_notebook_state('k in command mode', 'command', 2); |
|
58 | this.validate_notebook_state('k in command mode', 'command', 2); | |
54 | this.click_cell_editor(0); |
|
59 | this.click_cell_editor(0); | |
55 | this.validate_notebook_state('click cell 0', 'edit', 0); |
|
60 | this.validate_notebook_state('click cell 0', 'edit', 0); | |
56 | this.focus_notebook(); |
|
61 | this.focus_notebook(); | |
57 | this.validate_notebook_state('focus #notebook', 'command', 0); |
|
62 | this.validate_notebook_state('focus #notebook', 'command', 0); | |
58 | this.click_cell_editor(0); |
|
63 | this.click_cell_editor(0); | |
59 | this.validate_notebook_state('click cell 0', 'edit', 0); |
|
64 | this.validate_notebook_state('click cell 0', 'edit', 0); | |
60 | this.focus_notebook(); |
|
65 | this.focus_notebook(); | |
61 | this.validate_notebook_state('focus #notebook', 'command', 0); |
|
66 | this.validate_notebook_state('focus #notebook', 'command', 0); | |
62 | this.click_cell_editor(3); |
|
67 | this.click_cell_editor(3); | |
63 | this.validate_notebook_state('click cell 3', 'edit', 3); |
|
68 | this.validate_notebook_state('click cell 3', 'edit', 3); | |
64 |
|
69 | |||
65 | // Cell deletion |
|
70 | // Cell deletion | |
66 | this.trigger_keydown('esc', 'd', 'd'); |
|
71 | this.trigger_keydown('esc', 'd', 'd'); | |
67 | this.test.assertEquals(this.get_cells_length(), 3, 'dd actually deletes a cell'); |
|
72 | this.test.assertEquals(this.get_cells_length(), 3, 'dd actually deletes a cell'); | |
68 | this.validate_notebook_state('dd', 'command', 2); |
|
73 | this.validate_notebook_state('dd', 'command', 2); | |
69 |
|
74 | |||
70 | // Make sure that if the time between d presses is too long, nothing gets removed. |
|
75 | // Make sure that if the time between d presses is too long, nothing gets removed. | |
71 | this.trigger_keydown('d'); |
|
76 | this.trigger_keydown('d'); | |
72 | }); |
|
77 | }); | |
73 | this.wait(1000); |
|
78 | this.wait(1000); | |
74 | this.then(function () { |
|
79 | this.then(function () { | |
75 | this.trigger_keydown('d'); |
|
80 | this.trigger_keydown('d'); | |
76 | this.test.assertEquals(this.get_cells_length(), 3, "d, 1 second wait, d doesn't delete a cell"); |
|
81 | this.test.assertEquals(this.get_cells_length(), 3, "d, 1 second wait, d doesn't delete a cell"); | |
77 | this.validate_notebook_state('d, 1 second wait, d', 'command', 2); |
|
82 | this.validate_notebook_state('d, 1 second wait, d', 'command', 2); | |
78 | }); |
|
83 | }); | |
79 | }); |
|
84 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now