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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 }, true /* sticky */); | 387 }, true /* sticky */); |
388 | 388 |
389 this.showPanel('scripts'); | 389 this.showPanel('scripts'); |
390 | 390 |
391 // Wait until all scripts are added to the debugger. | 391 // Wait until all scripts are added to the debugger. |
392 this.takeControl(); | 392 this.takeControl(); |
393 }; | 393 }; |
394 | 394 |
395 | 395 |
396 /** | 396 /** |
| 397 * Tests that scripts are not duplicaed on Scripts tab switch. |
| 398 */ |
| 399 TestSuite.prototype.testNoScriptDuplicatesOnPanelSwitch = function() { |
| 400 var test = this; |
| 401 |
| 402 // There should be two scripts: one for the main page and another |
| 403 // one which is source of console API(see |
| 404 // InjectedScript._ensureCommandLineAPIInstalled). |
| 405 var expectedScriptsCount = 2; |
| 406 var parsedScripts = []; |
| 407 |
| 408 |
| 409 function switchToElementsTab() { |
| 410 test.showPanel('elements'); |
| 411 setTimeout(switchToScriptsTab, 0); |
| 412 } |
| 413 |
| 414 function switchToScriptsTab() { |
| 415 test.showPanel('scripts'); |
| 416 setTimeout(checkScriptsPanel, 0); |
| 417 } |
| 418 |
| 419 function checkScriptsPanel() { |
| 420 test.assertTrue(!!WebInspector.panels.scripts.visibleView, |
| 421 'No visible script view.'); |
| 422 var select = WebInspector.panels.scripts.filesSelectElement; |
| 423 test.assertEquals(expectedScriptsCount, select.options.length, |
| 424 'Unexpected options count'); |
| 425 test.releaseControl(); |
| 426 } |
| 427 |
| 428 this.addSniffer(WebInspector, 'parsedScriptSource', |
| 429 function(sourceID, sourceURL, source, startingLine) { |
| 430 test.assertTrue( |
| 431 parsedScripts.indexOf(sourceURL) == -1, |
| 432 'Duplicated script: ' + sourceURL); |
| 433 test.assertTrue( |
| 434 parsedScripts.length < expectedScriptsCount, |
| 435 'Too many scripts: ' + sourceURL); |
| 436 parsedScripts.push(sourceURL); |
| 437 |
| 438 if (parsedScripts.length == expectedScriptsCount) { |
| 439 setTimeout(switchToElementsTab, 0); |
| 440 } |
| 441 }, true /* sticky */); |
| 442 |
| 443 this.showPanel('scripts'); |
| 444 |
| 445 // Wait until all scripts are added to the debugger. |
| 446 this.takeControl(); |
| 447 }; |
| 448 |
| 449 |
| 450 /** |
397 * Tests that a breakpoint can be set. | 451 * Tests that a breakpoint can be set. |
398 */ | 452 */ |
399 TestSuite.prototype.testSetBreakpoint = function() { | 453 TestSuite.prototype.testSetBreakpoint = function() { |
400 var parsedDebuggerTestPageHtml = false; | 454 var parsedDebuggerTestPageHtml = false; |
401 var parsedDebuggerTestJs = false; | 455 var parsedDebuggerTestJs = false; |
402 | 456 |
403 this.showPanel('scripts'); | 457 this.showPanel('scripts'); |
404 | 458 |
405 var scriptUrl = null; | 459 var scriptUrl = null; |
406 var breakpointLine = 12; | 460 var breakpointLine = 12; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 /** | 673 /** |
620 * Run specified test on a fresh instance of the test suite. | 674 * Run specified test on a fresh instance of the test suite. |
621 * @param {string} name Name of a test method from TestSuite class. | 675 * @param {string} name Name of a test method from TestSuite class. |
622 */ | 676 */ |
623 uiTests.runTest = function(name) { | 677 uiTests.runTest = function(name) { |
624 new TestSuite().runTest(name); | 678 new TestSuite().runTest(name); |
625 }; | 679 }; |
626 | 680 |
627 | 681 |
628 } | 682 } |
OLD | NEW |