OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 /** | 6 /** |
7 * @fileoverview This file contains small testing framework along with the | 7 * @fileoverview This file contains small testing framework along with the |
8 * test suite for the frontend. These tests are a part of the continues build | 8 * test suite for the frontend. These tests are a part of the continues build |
9 * and are executed by the devtools_sanity_unittest.cc as a part of the | 9 * and are executed by the devtools_sanity_unittest.cc as a part of the |
10 * Interactive UI Test suite. | 10 * Interactive UI Test suite. |
(...skipping 601 matching lines...) Loading... |
612 assertNext('13', 'error', 'error-level'); | 612 assertNext('13', 'error', 'error-level'); |
613 assertNext('15', 'Message format number 1, 2 and 3.5'); | 613 assertNext('15', 'Message format number 1, 2 and 3.5'); |
614 assertNext('17', 'Message format for string'); | 614 assertNext('17', 'Message format for string'); |
615 assertNext('19', 'Object Object'); | 615 assertNext('19', 'Object Object'); |
616 assertNext('22', 'repeated', 'log-level', 5); | 616 assertNext('22', 'repeated', 'log-level', 5); |
617 assertNext('26', 'count: 1'); | 617 assertNext('26', 'count: 1'); |
618 assertNext('26', 'count: 2'); | 618 assertNext('26', 'count: 2'); |
619 assertNext('29', 'group', 'group-title'); | 619 assertNext('29', 'group', 'group-title'); |
620 index++; | 620 index++; |
621 assertNext('33', 'timer:', 'log-level', '', true); | 621 assertNext('33', 'timer:', 'log-level', '', true); |
| 622 assertNext('35', '1 2 3', 'log-level'); |
| 623 assertNext('37', 'HTMLDocument', 'log-level'); |
| 624 assertNext('39', '<html>', 'log-level', '', true); |
622 }; | 625 }; |
623 | 626 |
624 | 627 |
625 /** | 628 /** |
626 * Tests eval of global objects. | 629 * Tests eval of global objects. |
627 */ | 630 */ |
628 TestSuite.prototype.testEvalGlobal = function() { | 631 TestSuite.prototype.testEvalGlobal = function() { |
629 WebInspector.console.visible = true; | 632 WebInspector.console.visible = true; |
630 WebInspector.console.prompt.text = 'foo'; | |
631 WebInspector.console.promptElement.handleKeyEvent( | |
632 new TestSuite.KeyEvent('Enter')); | |
633 | 633 |
| 634 var inputs = ['foo', 'foobar']; |
| 635 var expectations = ['foo', 'fooValue', |
| 636 'foobar', 'ReferenceError: foobar is not defined']; |
| 637 |
| 638 // Do not change code below - simply add inputs and expectations above. |
| 639 var initEval = function(input) { |
| 640 WebInspector.console.prompt.text = input; |
| 641 WebInspector.console.promptElement.handleKeyEvent( |
| 642 new TestSuite.KeyEvent('Enter')); |
| 643 }; |
634 var test = this; | 644 var test = this; |
| 645 var messagesCount = 0; |
| 646 var inputIndex = 0; |
635 this.addSniffer(WebInspector.ConsoleView.prototype, 'addMessage', | 647 this.addSniffer(WebInspector.ConsoleView.prototype, 'addMessage', |
636 function(commandResult) { | 648 function(commandResult) { |
637 test.assertEquals('fooValue', | 649 messagesCount++; |
638 commandResult.toMessageElement().textContent); | 650 if (messagesCount == expectations.length) { |
639 test.releaseControl(); | 651 var messages = WebInspector.console.messages; |
640 }); | 652 for (var i = 0; i < expectations; ++i) { |
| 653 var elem = messages[i++].toMessageElement(); |
| 654 test.assertEquals(elem.textContent, expectations[i]); |
| 655 } |
| 656 test.releaseControl(); |
| 657 } else if (messagesCount % 2 == 0) { |
| 658 initEval(inputs[inputIndex++]); |
| 659 } |
| 660 }, true); |
641 | 661 |
| 662 initEval(inputs[inputIndex++]); |
642 this.takeControl(); | 663 this.takeControl(); |
643 }; | 664 }; |
644 | 665 |
645 | 666 |
646 /** | 667 /** |
647 * Tests eval on call frame. | 668 * Tests eval on call frame. |
648 */ | 669 */ |
649 TestSuite.prototype.testEvalCallFrame = function() { | 670 TestSuite.prototype.testEvalCallFrame = function() { |
650 }; | 671 }; |
651 | 672 |
(...skipping 21 matching lines...) Loading... |
673 /** | 694 /** |
674 * Run specified test on a fresh instance of the test suite. | 695 * Run specified test on a fresh instance of the test suite. |
675 * @param {string} name Name of a test method from TestSuite class. | 696 * @param {string} name Name of a test method from TestSuite class. |
676 */ | 697 */ |
677 uiTests.runTest = function(name) { | 698 uiTests.runTest = function(name) { |
678 new TestSuite().runTest(name); | 699 new TestSuite().runTest(name); |
679 }; | 700 }; |
680 | 701 |
681 | 702 |
682 } | 703 } |
OLD | NEW |