OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * @fileoverview The way these tests work is as follows: | 6 * @fileoverview The way these tests work is as follows: |
7 * C++ in net_internals_ui_browsertest.cc does any necessary setup, and then | 7 * C++ in net_internals_ui_browsertest.cc does any necessary setup, and then |
8 * calls the entry point for a test with RunJavascriptTest. The called | 8 * calls the entry point for a test with RunJavascriptTest. The called |
9 * function can then use the assert/expect functions defined in test_api.js. | 9 * function can then use the assert/expect functions defined in test_api.js. |
10 * All callbacks from the browser are wrapped in such a way that they can | 10 * All callbacks from the browser are wrapped in such a way that they can |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 }; | 590 }; |
591 | 591 |
592 /** | 592 /** |
593 * Creates a new NetLog source. Note that the id may conflict with events | 593 * Creates a new NetLog source. Note that the id may conflict with events |
594 * received from the browser. | 594 * received from the browser. |
595 * @param {int}: type The source type. | 595 * @param {int}: type The source type. |
596 * @param {int}: id The source id. | 596 * @param {int}: id The source id. |
597 * @constructor | 597 * @constructor |
598 */ | 598 */ |
599 NetInternalsTest.Source = function(type, id) { | 599 NetInternalsTest.Source = function(type, id) { |
600 assertNotEquals(getKeyWithValue(LogSourceType, type), '?'); | 600 assertNotEquals(getKeyWithValue(EventSourceType, type), '?'); |
601 assertGE(id, 0); | 601 assertGE(id, 0); |
602 this.type = type; | 602 this.type = type; |
603 this.id = id; | 603 this.id = id; |
604 }; | 604 }; |
605 | 605 |
606 /** | 606 /** |
607 * Creates a new NetLog event. | 607 * Creates a new NetLog event. |
608 * @param {Source}: source The source associated with the event. | 608 * @param {Source}: source The source associated with the event. |
609 * @param {int}: type The event id. | 609 * @param {int}: type The event id. |
610 * @param {int}: time When the event occurred. | 610 * @param {int}: time When the event occurred. |
611 * @param {int}: phase The event phase. | 611 * @param {int}: phase The event phase. |
612 * @param {object}: params The event parameters. May be null. | 612 * @param {object}: params The event parameters. May be null. |
613 * @constructor | 613 * @constructor |
614 */ | 614 */ |
615 NetInternalsTest.Event = function(source, type, time, phase, params) { | 615 NetInternalsTest.Event = function(source, type, time, phase, params) { |
616 assertNotEquals(getKeyWithValue(LogEventType, type), '?'); | 616 assertNotEquals(getKeyWithValue(EventType, type), '?'); |
617 assertNotEquals(getKeyWithValue(LogEventPhase, phase), '?'); | 617 assertNotEquals(getKeyWithValue(EventPhase, phase), '?'); |
618 | 618 |
619 this.source = source; | 619 this.source = source; |
620 this.phase = phase; | 620 this.phase = phase; |
621 this.type = type; | 621 this.type = type; |
622 this.time = '' + time; | 622 this.time = '' + time; |
623 this.phase = phase; | 623 this.phase = phase; |
624 if (params) | 624 if (params) |
625 this.params = params; | 625 this.params = params; |
626 }; | 626 }; |
627 | 627 |
628 /** | 628 /** |
629 * Creates a new NetLog begin event. Parameters are the same as Event, | 629 * Creates a new NetLog begin event. Parameters are the same as Event, |
630 * except there's no |phase| argument. | 630 * except there's no |phase| argument. |
631 * @see Event | 631 * @see Event |
632 */ | 632 */ |
633 NetInternalsTest.createBeginEvent = function(source, type, time, params) { | 633 NetInternalsTest.createBeginEvent = function(source, type, time, params) { |
634 return new NetInternalsTest.Event(source, type, time, | 634 return new NetInternalsTest.Event(source, type, time, |
635 LogEventPhase.PHASE_BEGIN, params); | 635 EventPhase.PHASE_BEGIN, params); |
636 }; | 636 }; |
637 | 637 |
638 /** | 638 /** |
639 * Creates a new NetLog end event. Parameters are the same as Event, | 639 * Creates a new NetLog end event. Parameters are the same as Event, |
640 * except there's no |phase| argument. | 640 * except there's no |phase| argument. |
641 * @see Event | 641 * @see Event |
642 */ | 642 */ |
643 NetInternalsTest.createEndEvent = function(source, type, time, params) { | 643 NetInternalsTest.createEndEvent = function(source, type, time, params) { |
644 return new NetInternalsTest.Event(source, type, time, | 644 return new NetInternalsTest.Event(source, type, time, |
645 LogEventPhase.PHASE_END, params); | 645 EventPhase.PHASE_END, params); |
646 }; | 646 }; |
647 | 647 |
648 /** | 648 /** |
649 * Creates a new NetLog end event matching the given begin event. | 649 * Creates a new NetLog end event matching the given begin event. |
650 * @param {Event}: beginEvent The begin event. Returned event will have the | 650 * @param {Event}: beginEvent The begin event. Returned event will have the |
651 * same source and type. | 651 * same source and type. |
652 * @param {int}: time When the event occurred. | 652 * @param {int}: time When the event occurred. |
653 * @param {object}: params The event parameters. May be null. | 653 * @param {object}: params The event parameters. May be null. |
654 * @see Event | 654 * @see Event |
655 */ | 655 */ |
(...skipping 14 matching lines...) Expand all Loading... |
670 ]; | 670 ]; |
671 | 671 |
672 for (var i = 0; i < allIds.length; ++i) { | 672 for (var i = 0; i < allIds.length; ++i) { |
673 var curId = allIds[i]; | 673 var curId = allIds[i]; |
674 expectEquals(nodeId == curId, NetInternalsTest.nodeIsVisible($(curId))); | 674 expectEquals(nodeId == curId, NetInternalsTest.nodeIsVisible($(curId))); |
675 } | 675 } |
676 }; | 676 }; |
677 | 677 |
678 return NetInternalsTest; | 678 return NetInternalsTest; |
679 })(); | 679 })(); |
OLD | NEW |