| 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 475 |
| 476 /** | 476 /** |
| 477 * Tests console log. | 477 * Tests console log. |
| 478 */ | 478 */ |
| 479 TestSuite.prototype.testConsoleLog = function() { | 479 TestSuite.prototype.testConsoleLog = function() { |
| 480 WebInspector.console.visible = true; | 480 WebInspector.console.visible = true; |
| 481 var messages = WebInspector.console.messages; | 481 var messages = WebInspector.console.messages; |
| 482 var index = 0; | 482 var index = 0; |
| 483 | 483 |
| 484 var test = this; | 484 var test = this; |
| 485 var assertNext = function(line, message, opt_level, opt_count, opt_substr) { | 485 var assertNext = function(line, message, opt_class, opt_count, opt_substr) { |
| 486 var elem = messages[index++].toMessageElement(); | 486 var elem = messages[index++].toMessageElement(); |
| 487 var clazz = elem.getAttribute('class'); | 487 var clazz = elem.getAttribute('class'); |
| 488 var expectation = (opt_count || '') + 'console_test_page.html:' + | 488 var expectation = (opt_count || '') + 'console_test_page.html:' + |
| 489 line + message; | 489 line + message; |
| 490 if (opt_substr) { | 490 if (opt_substr) { |
| 491 test.assertContains(elem.textContent, expectation); | 491 test.assertContains(elem.textContent, expectation); |
| 492 } else { | 492 } else { |
| 493 test.assertEquals(expectation, elem.textContent); | 493 test.assertEquals(expectation, elem.textContent); |
| 494 } | 494 } |
| 495 if (opt_level) { | 495 if (opt_class) { |
| 496 test.assertContains(clazz, 'console-' + opt_level + '-level'); | 496 test.assertContains(clazz, 'console-' + opt_class); |
| 497 } | 497 } |
| 498 }; | 498 }; |
| 499 | 499 |
| 500 assertNext('5', 'log', 'log'); | 500 assertNext('5', 'log', 'log-level'); |
| 501 assertNext('7', 'debug', 'log'); | 501 assertNext('7', 'debug', 'log-level'); |
| 502 assertNext('9', 'info', 'log'); | 502 assertNext('9', 'info', 'log-level'); |
| 503 assertNext('11', 'warn', 'warning'); | 503 assertNext('11', 'warn', 'warning-level'); |
| 504 assertNext('13', 'error', 'error'); | 504 assertNext('13', 'error', 'error-level'); |
| 505 assertNext('15', 'Message format number 1, 2 and 3.5'); | 505 assertNext('15', 'Message format number 1, 2 and 3.5'); |
| 506 assertNext('17', 'Message format for string'); | 506 assertNext('17', 'Message format for string'); |
| 507 assertNext('19', 'Object Object'); | 507 assertNext('19', 'Object Object'); |
| 508 assertNext('22', 'repeated', 'log', 5); | 508 assertNext('22', 'repeated', 'log-level', 5); |
| 509 assertNext('26', 'count: 1'); | 509 assertNext('26', 'count: 1'); |
| 510 assertNext('26', 'count: 2'); | 510 assertNext('26', 'count: 2'); |
| 511 assertNext('29', 'group', 'group-title'); | 511 assertNext('29', 'group', 'group-title'); |
| 512 index++; | 512 index++; |
| 513 assertNext('33', 'timer:', 'log', '', true); | 513 assertNext('33', 'timer:', 'log-level', '', true); |
| 514 }; | 514 }; |
| 515 | 515 |
| 516 | 516 |
| 517 /** | 517 /** |
| 518 * Tests eval of global objects. | 518 * Tests eval of global objects. |
| 519 */ | 519 */ |
| 520 TestSuite.prototype.testEvalGlobal = function() { | 520 TestSuite.prototype.testEvalGlobal = function() { |
| 521 WebInspector.console.visible = true; | 521 WebInspector.console.visible = true; |
| 522 WebInspector.console.prompt.text = 'foo'; | 522 WebInspector.console.prompt.text = 'foo'; |
| 523 WebInspector.console.promptElement.handleKeyEvent( | 523 WebInspector.console.promptElement.handleKeyEvent( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 /** | 565 /** |
| 566 * Run specified test on a fresh instance of the test suite. | 566 * Run specified test on a fresh instance of the test suite. |
| 567 * @param {string} name Name of a test method from TestSuite class. | 567 * @param {string} name Name of a test method from TestSuite class. |
| 568 */ | 568 */ |
| 569 uiTests.runTest = function(name) { | 569 uiTests.runTest = function(name) { |
| 570 new TestSuite().runTest(name); | 570 new TestSuite().runTest(name); |
| 571 }; | 571 }; |
| 572 | 572 |
| 573 | 573 |
| 574 } | 574 } |
| OLD | NEW |