Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: chrome/browser/resources/hterm/js/vt100_tests.js

Issue 8680034: Initial landing of Screen, Terminal, and VT100 classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview VT100 test suite.
7 *
8 * This is more of an integration test suite for the VT100 and Terminal classes,
9 * as each test typically sends strings into the VT100 parser and then reads
10 * the terminal to verify that everyone did the right thing.
11 */
12
13 hterm.VT100.Tests = new TestManager.Suite('hterm.VT100.Tests');
14
15 hterm.VT100.Tests.prototype.setup = function(cx) {
16 this.setDefaults(cx,
17 { visibleColumnCount: 15,
18 visibleRowCount: 6,
19 fontSize: 15,
20 lineHeight: 17,
21 charWidth: 9,
22 scrollbarWidth: 16,
23 });
24 };
25
26 /**
27 * Clear out the current document and create a new hterm.Terminal object for
28 * testing.
29 *
30 * Called before each test case in this suite.
31 */
32 hterm.VT100.Tests.prototype.preamble = function(result, cx) {
33 var document = cx.window.document;
34
35 document.body.innerHTML = '';
36
37 var div = document.createElement('div');
38 div.style.position = 'absolute';
39 div.style.height = this.lineHeight * this.visibleRowCount + 'px';
40 div.style.width = this.charWidth * this.visibleColumnCount +
41 this.scrollbarWidth + 'px';
42 document.body.appendChild(div);
43
44 cx.window.terminal = this.terminal = new hterm.Terminal(
45 this.fontSize, this.lineHeight);
46
47 this.terminal.decorate(div);
48 };
49
50 /**
51 * Ensure that blink is off after the test so we don't have runaway timeouts.
52 *
53 * Called after each test case in this suite.
54 */
55 hterm.VT100.Tests.prototype.postamble = function(result, cx) {
56 this.terminal.setCursorBlink(false);
57 };
58
59 /**
60 * Overridden addTest method.
61 *
62 * Every test in this suite needs to wait for the terminal initialization to
63 * complete asynchronously. Rather than stick a bunch of biolerplate into each
64 * test case, we use this overridden addText method to add a proxy around the
65 * actual test.
66 */
67 hterm.VT100.Tests.addTest = function(name, callback) {
68 function testProxy(result, cx) {
69 setTimeout(function() {
70 this.terminal.setCursorPosition(0, 0);
71 this.terminal.setCursorVisible(true);
72 callback.apply(this, [result, cx]);
73 }, 0);
74
75 result.requestTime(200);
76 }
77
78 TestManager.Suite.addTest.apply(this, [name, testProxy]);
79 };
80
81 /**
82 * Basic sanity test to make sure that when we insert plain text it appears
83 * on the screen and scrolls into the scrollback buffer correctly.
84 */
85 hterm.VT100.Tests.addTest('sanity', function(result, cx) {
86 this.terminal.interpret('0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12');
87
88 var text = this.terminal.getRowsText(0, 13);
89 result.assertEQ(text, '0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12');
90
91 result.assertEQ(this.terminal.scrollbackRows_.length, 7);
92
93 result.pass();
94 });
95
96 /**
97 * Basic cursor positioning tests.
98 *
99 * TODO(rginda): Test the VT52 variants too.
100 */
101 hterm.VT100.Tests.addTest('cursor-relative', function(result, cx) {
102 this.terminal.interpret('line 1\nline 2\nline 3');
103 this.terminal.interpret('\x1b[A\x1b[Dtwo' +
104 '\x1b[3D' +
105 '\x1b[Aone' +
106 '\x1b[4D' +
107 '\x1b[2B' +
108 '\x1b[Cthree');
109 var text = this.terminal.getRowsText(0, 3);
110 result.assertEQ(text, 'line one\nline two\nline three');
111 result.pass();
112 });
113
114 /**
115 * Test absolute cursor positioning.
116 */
117 hterm.VT100.Tests.addTest('cursor-absolute', function(result, cx) {
118 this.terminal.interpret('line 1\nline 2\nline 3');
119
120 this.terminal.interpret('\x1b[1Gline three' +
121 '\x1b[2;6Htwo' +
122 '\x1b[1;5f one');
123
124 var text = this.terminal.getRowsText(0, 3);
125 result.assertEQ(text, 'line one\nline two\nline three');
126
127 result.pass();
128 });
129
130 /**
131 * Test line positioning.
132 */
133 hterm.VT100.Tests.addTest('line-position', function(result, cx) {
134 this.terminal.interpret('line 1\nline 2\nline 3');
135
136 this.terminal.interpret('\x1b[Fline two' +
137 '\x1b[Fline one' +
138 '\x1b[E\x1b[Eline three');
139
140 var text = this.terminal.getRowsText(0, 3);
141 result.assertEQ(text, 'line one\nline two\nline three');
142 result.pass();
143 });
144
145 /**
146 * Test that a partial sequence is buffered until the entire sequence is
147 * received.
148 */
149 hterm.VT100.Tests.addTest('partial-sequence', function(result, cx) {
150 this.terminal.interpret('line 1\nline 2\nline three');
151
152 this.terminal.interpret('\x1b');
153 this.terminal.interpret('[');
154 this.terminal.interpret('5');
155 this.terminal.interpret('D');
156 this.terminal.interpret('\x1b[');
157 this.terminal.interpret('Atwo\x1b[3');
158 this.terminal.interpret('D\x1b[Aone');
159
160 var text = this.terminal.getRowsText(0, 3);
161 result.assertEQ(text, 'line one\nline two\nline three');
162 result.pass();
163 });
164
165 /**
166 * Test that two ESC characters in a row are handled properly.
167 */
168 hterm.VT100.Tests.addTest('double-sequence', function(result, cx) {
169 this.terminal.interpret('line one\nline two\nline 3');
170
171 this.terminal.interpret('\x1b[\x1b[Dthree');
172
173 var text = this.terminal.getRowsText(0, 3);
174 result.assertEQ(text, 'line one\nline two\nline three');
175 result.pass();
176 });
177
178 /**
179 * Test the erase left command.
180 */
181 hterm.VT100.Tests.addTest('erase-left', function(result, cx) {
182 this.terminal.interpret('line one\noooooooo\nline three');
183 this.terminal.interpret('\x1b[5D\x1b[A' +
184 '\x1b[1Ktw');
185
186 var text = this.terminal.getRowsText(0, 3);
187 result.assertEQ(text,
188 'line one\n' +
189 ' two\n' +
190 'line three');
191 result.pass();
192 });
193
194 /**
195 * Test the erase right command.
196 */
197 hterm.VT100.Tests.addTest('erase-right', function(result, cx) {
198 this.terminal.interpret('line one\nline XXXX\nline three');
199 this.terminal.interpret('\x1b[5D\x1b[A' +
200 '\x1b[0Ktwo');
201
202 var text = this.terminal.getRowsText(0, 3);
203 result.assertEQ(text,
204 'line one\n' +
205 'line two\n' +
206 'line three');
207 result.pass();
208 });
209
210 /**
211 * Test the erase line command.
212 */
213 hterm.VT100.Tests.addTest('erase-line', function(result, cx) {
214 this.terminal.interpret('line one\nline twoo\nline three');
215 this.terminal.interpret('\x1b[5D\x1b[A' +
216 '\x1b[2Ktwo');
217
218 var text = this.terminal.getRowsText(0, 3);
219 result.assertEQ(text,
220 'line one\n' +
221 ' two\n' +
222 'line three');
223 result.pass();
224 });
225
226 /**
227 * Test the erase above command.
228 */
229 hterm.VT100.Tests.addTest('erase-above', function(result, cx) {
230 this.terminal.interpret('line one\noooooooo\nline three');
231 this.terminal.interpret('\x1b[5D\x1b[A' +
232 '\x1b[1Jtw');
233
234 var text = this.terminal.getRowsText(0, 3);
235 result.assertEQ(text,
236 '\n' +
237 ' two\n' +
238 'line three');
239 result.pass();
240 });
241
242 /**
243 * Test the erase all command.
244 */
245 hterm.VT100.Tests.addTest('erase-all', function(result, cx) {
246 this.terminal.interpret('line one\nline XXXX\nline three');
247 this.terminal.interpret('\x1b[5D\x1b[A' +
248 '\x1b[2Jtwo');
249
250 var text = this.terminal.getRowsText(0, 3);
251 result.assertEQ(text,
252 '\n' +
253 ' two\n' +
254 '');
255 result.pass();
256 });
257
258 /**
259 * Test the erase below command.
260 */
261 hterm.VT100.Tests.addTest('erase-below', function(result, cx) {
262 this.terminal.interpret('line one\nline XXXX\nline three');
263 this.terminal.interpret('\x1b[5D\x1b[A' +
264 '\x1b[0Jtwo');
265
266 var text = this.terminal.getRowsText(0, 3);
267 result.assertEQ(text,
268 'line one\n' +
269 'line two\n' +
270 '');
271 result.pass();
272 });
273
274 /**
275 * Test the erase character command.
276 */
277 hterm.VT100.Tests.addTest('erase-char', function(result, cx) {
278 this.terminal.interpret('line one\nline XXXX\nline three');
279 this.terminal.interpret('\x1b[5D\x1b[A' +
280 '\x1b[4Xtwo');
281
282 var text = this.terminal.getRowsText(0, 3);
283 result.assertEQ(text,
284 'line one\n' +
285 'line two\n' +
286 'line three');
287 result.pass();
288 });
289
290 /**
291 * Test the insert line command.
292 */
293 hterm.VT100.Tests.addTest('insert-line', function(result, cx) {
294 this.terminal.interpret('line two\nline three');
295 this.terminal.interpret('\x1b[5D\x1b[2A\x1b[L' +
296 'line one');
297
298 var text = this.terminal.getRowsText(0, 3);
299 result.assertEQ(text,
300 'line one\n' +
301 'line two\n' +
302 'line three');
303 result.pass();
304 });
305
306 /**
307 * Test the insert line command with an argument.
308 */
309 hterm.VT100.Tests.addTest('insert-lines', function(result, cx) {
310 this.terminal.interpret('line three\n\n');
311 this.terminal.interpret('\x1b[5D\x1b[2A\x1b[2L' +
312 'line one\nline two');
313
314 var text = this.terminal.getRowsText(0, 3);
315 result.assertEQ(text,
316 'line one\n' +
317 'line two\n' +
318 'line three');
319 result.pass();
320 });
321
322 /**
323 * Test that the insert line command handles overflow properly.
324 */
325 hterm.VT100.Tests.addTest('insert-toomany-lines', function(result, cx) {
326 this.terminal.interpret('XXXXX');
327 this.terminal.interpret('\x1b[6L' +
328 'line one\nline two\nline three');
329
330 var text = this.terminal.getRowsText(0, 5);
331 result.assertEQ(text,
332 'line one\n' +
333 'line two\n' +
334 'line three\n' +
335 '\n' +
336 '');
337 result.pass();
338 });
339
340 /**
341 * Test the delete line command.
342 */
343 hterm.VT100.Tests.addTest('delete-line', function(result, cx) {
344 this.terminal.interpret('line one\nline two\n' +
345 'XXXXXXXX\n' +
346 'line XXXXX');
347 this.terminal.interpret('\x1b[5D\x1b[A\x1b[Mthree');
348
349 var text = this.terminal.getRowsText(0, 3);
350 result.assertEQ(text,
351 'line one\n' +
352 'line two\n' +
353 'line three');
354 result.pass();
355 });
356
357 /**
358 * Test the delete line command with an argument.
359 */
360 hterm.VT100.Tests.addTest('delete-lines', function(result, cx) {
361 this.terminal.interpret('line one\nline two\n' +
362 'XXXXXXXX\nXXXXXXXX\n' +
363 'line XXXXX');
364 this.terminal.interpret('\x1b[5D\x1b[2A\x1b[2Mthree');
365
366 var text = this.terminal.getRowsText(0, 3);
367 result.assertEQ(text,
368 'line one\n' +
369 'line two\n' +
370 'line three');
371 result.pass();
372 });
373
374 /**
375 * Test the insert space command.
376 */
377 hterm.VT100.Tests.addTest('insert-space', function(result, cx) {
378 this.terminal.interpret('line one\nlinetwo\nline three');
379 this.terminal.interpret('\x1b[6D\x1b[A\x1b[@');
380
381 var text = this.terminal.getRowsText(0, 3);
382 result.assertEQ(text,
383 'line one\n' +
384 'line two\n' +
385 'line three');
386 result.pass();
387 });
388
389 /**
390 * Test the insert space command with an argument.
391 */
392 hterm.VT100.Tests.addTest('insert-spaces', function(result, cx) {
393 this.terminal.interpret('line one\nlinetwo\nline three');
394 this.terminal.interpret('\x1b[6D\x1b[A\x1b[3@');
395
396 var text = this.terminal.getRowsText(0, 3);
397 result.assertEQ(text,
398 'line one\n' +
399 'line two\n' +
400 'line three');
401 result.pass();
402 });
403
404 /**
405 * Test the delete characters command.
406 */
407 hterm.VT100.Tests.addTest('delete-chars', function(result, cx) {
408 this.terminal.interpret('line one\nline XXXX\nline three');
409 this.terminal.interpret('\x1b[5D\x1b[A\x1b[4Ptwo');
410
411 var text = this.terminal.getRowsText(0, 3);
412 result.assertEQ(text,
413 'line one\n' +
414 'line two\n' +
415 'line three');
416 result.pass();
417 });
418
419 /**
420 * Test that the delete characters command handles overflow properly.
421 */
422 hterm.VT100.Tests.addTest('delete-toomany', function(result, cx) {
423 this.terminal.interpret('line one\nline XXXX\nline three');
424 this.terminal.interpret('\x1b[5D\x1b[A\x1b[20Ptwo');
425
426 var text = this.terminal.getRowsText(0, 3);
427 result.assertEQ(text,
428 'line one\n' +
429 'line two\n' +
430 'line three');
431 result.pass();
432 });
433
434 /**
435 * Test the scroll up command.
436 */
437 hterm.VT100.Tests.addTest('scroll-up', function(result, cx) {
438 this.terminal.interpret('\n\nline one\nline two\nline XXXXX');
439 this.terminal.interpret('\x1b[5D\x1b[2A\x1b[2Sthree');
440
441 var text = this.terminal.getRowsText(0, 3);
442 result.assertEQ(text,
443 'line one\n' +
444 'line two\n' +
445 'line three');
446 result.pass();
447 });
448
449 /**
450 * Test the scroll down command.
451 */
452 hterm.VT100.Tests.addTest('scroll-down', function(result, cx) {
453 this.terminal.interpret('line one\nline two\nline XXXXX\n');
454 this.terminal.interpret(' \x1b[Tthree');
455
456 var text = this.terminal.getRowsText(0, 5);
457 result.assertEQ(text,
458 '\n' +
459 'line one\n' +
460 'line two\n' +
461 'line three\n' +
462 ' ');
463 result.pass();
464 });
465
466 /**
467 * Test the absolute line positioning command.
468 */
469 hterm.VT100.Tests.addTest('line-position-absolute', function(result, cx) {
470 this.terminal.interpret('line XXX\nline YYY\nline ZZZZZ\n');
471 this.terminal.interpret(' \x1b[3dthree\x1b[5D');
472 this.terminal.interpret('\x1b[2dtwo\x1b[3D');
473 this.terminal.interpret('\x1b[1done');
474
475 var text = this.terminal.getRowsText(0, 3);
476 result.assertEQ(text,
477 'line one\n' +
478 'line two\n' +
479 'line three');
480 result.pass();
481 });
482
483 /**
484 * Test the device attributes command.
485 */
486 hterm.VT100.Tests.addTest('device-attributes', function(result, cx) {
487 this.terminal.interpret('\x1b[c');
488 result.assertEQ(this.terminal.vt100_.getAndClearPendingResponse(),
489 '\x1b[?1;2c');
490 result.pass();
491 });
492
493 /**
494 * TODO(rginda): Test the clear tabstops on this line command.
495 */
496 hterm.VT100.Tests.disableTest('clear-line-tabstops', function(result, cx) {
497 '[0g';
498 });
499
500 /**
501 * TODO(rginda): Test the clear all tabstops command.
502 */
503 hterm.VT100.Tests.disableTest('clear-all-tabstops', function(result, cx) {
504 '[3g';
505 });
506
507 /**
508 * TODO(rginda): Test text attributes.
509 */
510 hterm.VT100.Tests.disableTest('color-change', function(result, cx) {
511 '[Xm';
512 });
513
514 /**
515 * Test the status report command.
516 */
517 hterm.VT100.Tests.addTest('status-report', function(result, cx) {
518 this.terminal.interpret('\x1b[5n');
519 result.assertEQ(this.terminal.vt100_.getAndClearPendingResponse(),
520 '\x1b0n');
521
522 this.terminal.interpret('line one\nline two\nline three');
523 // Reposition the cursor and ask for a position report.
524 this.terminal.interpret('\x1b[5D\x1b[A\x1b[6n');
525 result.assertEQ(this.terminal.vt100_.getAndClearPendingResponse(),
526 '\x1b[2;6R');
527
528 var text = this.terminal.getRowsText(0, 3);
529 result.assertEQ(text,
530 'line one\n' +
531 'line two\n' +
532 'line three');
533
534 result.pass();
535 });
536
537 /**
538 * Test that various mode commands correctly change the state of the terminal.
539 *
540 * Most of these should have more in-depth testing below.
541 */
542 hterm.VT100.Tests.addTest('mode-bits', function(result, cx) {
543 this.terminal.interpret('\x1b[?1h');
544 result.assertEQ(this.terminal.vt100_.getApplicationCursor(), true);
545
546 this.terminal.interpret('\x1b[?1l');
547 result.assertEQ(this.terminal.vt100_.getApplicationCursor(), false);
548
549 var fg = this.terminal.foregroundColor;
550 var bg = this.terminal.backgroundColor;
551
552 this.terminal.interpret('\x1b[?5h');
553 result.assertEQ(this.terminal.scrollPort_.getForegroundColor(), bg);
554 result.assertEQ(this.terminal.scrollPort_.getBackgroundColor(), fg);
555
556 this.terminal.interpret('\x1b[?5l');
557 result.assertEQ(this.terminal.scrollPort_.getForegroundColor(), fg);
558 result.assertEQ(this.terminal.scrollPort_.getBackgroundColor(), bg);
559
560 this.terminal.interpret('\x1b[?5l');
561 result.assertEQ(this.terminal.scrollPort_.getForegroundColor(), fg);
562 result.assertEQ(this.terminal.scrollPort_.getBackgroundColor(), bg);
563
564 this.terminal.interpret('\x1b[?6h');
565 result.assertEQ(this.terminal.options_.originMode, true);
566
567 this.terminal.interpret('\x1b[?6l');
568 result.assertEQ(this.terminal.options_.originMode, false);
569
570 this.terminal.interpret('\x1b[4h');
571 result.assertEQ(this.terminal.options_.insertMode, true);
572
573 this.terminal.interpret('\x1b[4l');
574 result.assertEQ(this.terminal.options_.insertMode, false);
575
576 this.terminal.interpret('\x1b[?7h');
577 result.assertEQ(this.terminal.options_.wraparound, true);
578
579 this.terminal.interpret('\x1b[?7l');
580 result.assertEQ(this.terminal.options_.wraparound, false);
581
582 this.terminal.interpret('\x1b[?12l');
583 result.assertEQ(this.terminal.options_.cursorBlink, false);
584 result.assertEQ(this.terminal.cursorTimer_, null);
585
586 this.terminal.interpret('\x1b[?12h');
587 result.assertEQ(this.terminal.options_.cursorBlink, true);
588 result.assert(this.terminal.cursorTimer_ != null);
589
590 this.terminal.interpret('\x1b[?25l');
591 result.assertEQ(this.terminal.options_.cursorVisible, false);
592 result.assertEQ(this.terminal.cursorNode_.style.display, 'none');
593
594 this.terminal.interpret('\x1b[?25h');
595 result.assertEQ(this.terminal.options_.cursorVisible, true);
596
597 // Turn off blink so we know the cursor should be on.
598 this.terminal.interpret('\x1b[?12l');
599 result.assertEQ(this.terminal.cursorNode_.style.display, 'block');
600
601 this.terminal.interpret('\x1b[?45h');
602 result.assertEQ(this.terminal.options_.reverseWraparound, true);
603
604 this.terminal.interpret('\x1b[?45l');
605 result.assertEQ(this.terminal.options_.reverseWraparound, false);
606
607 this.terminal.interpret('\x1b[?67h');
608 result.assertEQ(this.terminal.vt100_.backspaceSendsBackspace_, true);
609
610 this.terminal.interpret('\x1b[?67l');
611 result.assertEQ(this.terminal.vt100_.backspaceSendsBackspace_, false);
612
613 this.terminal.interpret('\x1b[?1036h');
614 result.assertEQ(this.terminal.vt100_.metaSendsEscape_, true);
615
616 this.terminal.interpret('\x1b[?1036l');
617 result.assertEQ(this.terminal.vt100_.metaSendsEscape_, false);
618
619 this.terminal.interpret('\x1b[?1039h');
620 result.assertEQ(this.terminal.vt100_.altSendsEscape_, true);
621
622 this.terminal.interpret('\x1b[?1039l');
623 result.assertEQ(this.terminal.vt100_.altSendsEscape_, false);
624
625 result.assertEQ(this.terminal.screen_,
626 this.terminal.primaryScreen_);
627
628 this.terminal.interpret('\x1b[?1049h');
629 result.assertEQ(this.terminal.screen_,
630 this.terminal.alternateScreen_);
631
632 this.terminal.interpret('\x1b[?1049l');
633 result.assertEQ(this.terminal.screen_,
634 this.terminal.primaryScreen_);
635
636 result.pass();
637 });
638
639 /**
640 * TODO(rginda): Test origin mode.
641 */
642 hterm.VT100.Tests.disableTest('origin-mode', function(result, cx) {
643 });
644
645 /**
646 * Test insert/overwrite mode.
647 */
648 hterm.VT100.Tests.addTest('insert-mode', function(result, cx) {
649 // Should be off by default.
650 result.assertEQ(this.terminal.options_.insertMode, false);
651
652 this.terminal.interpret('\x1b[4h');
653 this.terminal.interpret(' one\x1b[4Dline\n');
654
655 this.terminal.interpret('\x1b[4l');
656 this.terminal.interpret('XXXXXXXX\x1b[8Dline two\n');
657
658 this.terminal.interpret('\x1b[4h');
659 this.terminal.interpret(' three\x1b[6Dline');
660
661 var text = this.terminal.getRowsText(0, 3);
662 result.assertEQ(text,
663 'line one\n' +
664 'line two\n' +
665 'line three');
666
667 result.pass();
668 });
669
670 /**
671 * Test wraparound mode.
672 */
673 hterm.VT100.Tests.addTest('wraparound-mode', function(result, cx) {
674 // Should be on by default.
675 result.assertEQ(this.terminal.options_.wraparound, true);
676
677 this.terminal.interpret('----- 1 -----');
678 this.terminal.interpret('----- 2 -----');
679
680 var text = this.terminal.getRowsText(0, 3);
681 result.assertEQ(text,
682 '----- 1 -----\n' +
683 '----- 2 -----\n' +
684 '');
685
686
687 result.pass();
688 });
689
690 /**
691 * Test the interactions between insert and wraparound modes.
692 */
693 hterm.VT100.Tests.addTest('insert-wrap', function(result, cx) {
694 // Should be on by default.
695 result.assertEQ(this.terminal.options_.wraparound, true);
696
697 this.terminal.interpret('' + // Insert off, wrap on (default).
698 'AAAAXX\n' +
699 '[?7l' + // Insert on, wrap off.
700 'AAAAXX\n' +
701 '[?7h' + // Insert on, wrap on.
702 'AAAAXX\n' +
703 '[?7l' + // Insert off, wrap off.
704 'AAAAXX');
705
706 var text = this.terminal.getRowsText(0, 6);
707 result.assertEQ(text,
708 ' A\n' +
709 'XXA\n' +
710
711 'XX \n' +
712
713 ' A\n' +
714 'XXAAA\n' +
715
716 'XX A');
717
718
719 result.pass();
720 });
721
722 hterm.VT100.Tests.addTest('alternate-screen', function(result, cx) {
723 this.terminal.interpret('1\n2\n3\n4\n5\n6\n7\n8\n9\n10');
724 this.terminal.interpret('\x1b[3;3f'); // Leave the cursor at (3,3)
725 var text = this.terminal.getRowsText(0, 10);
726 result.assertEQ(text, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10');
727
728 // Switch to alternate screen.
729 this.terminal.interpret('\x1b[?1049h');
730 text = this.terminal.getRowsText(0, 10);
731 result.assertEQ(text, '1\n2\n3\n4\n\n\n\n\n\n');
732
733 this.terminal.interpret('\nhi');
734 text = this.terminal.getRowsText(0, 10);
735 result.assertEQ(text, '1\n2\n3\n4\n\nhi\n\n\n\n');
736
737 // Switch back to primary screen.
738 this.terminal.interpret('\x1b[?1049l');
739 text = this.terminal.getRowsText(0, 10);
740 result.assertEQ(text, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10');
741
742 this.terminal.interpret('XX');
743 text = this.terminal.getRowsText(0, 10);
744 result.assertEQ(text, '1\n2\n3\n4\n5\n6\n7 XX\n8\n9\n10');
745
746 // Aand back to alternate screen.
747 this.terminal.interpret('\x1b[?1049h');
748 text = this.terminal.getRowsText(0, 10);
749 result.assertEQ(text, '1\n2\n3\n4\n\nhi\n\n\n\n');
750
751 this.terminal.interpret('XX');
752 text = this.terminal.getRowsText(0, 10);
753 result.assertEQ(text, '1\n2\n3\n4\n\nhiXX\n\n\n\n');
754
755 result.pass();
756 });
OLDNEW
« chrome/browser/resources/hterm/js/vt100.js ('K') | « chrome/browser/resources/hterm/js/vt100.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698