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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/main/Tests.js

Issue 1704723002: DevTools: add input event instrumentation test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: speculative attempt to fix MacOS 10.6 flakiness Created 4 years, 10 months 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/common/TestBase.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 29 matching lines...) Expand all
40 function createTestSuite(domAutomationController) 40 function createTestSuite(domAutomationController)
41 { 41 {
42 42
43 /** 43 /**
44 * Test suite for interactive UI tests. 44 * Test suite for interactive UI tests.
45 * @constructor 45 * @constructor
46 */ 46 */
47 function TestSuite() 47 function TestSuite()
48 { 48 {
49 WebInspector.TestBase.call(this, domAutomationController); 49 WebInspector.TestBase.call(this, domAutomationController);
50 this._asyncInvocationId = 0;
50 }; 51 };
51 52
52 TestSuite.prototype = { 53 TestSuite.prototype = {
53 __proto__: WebInspector.TestBase.prototype 54 __proto__: WebInspector.TestBase.prototype
54 }; 55 };
55 56
56 57
57 /** 58 /**
58 * @param {string} panelName Name of the panel to show. 59 * @param {string} panelName Name of the panel to show.
59 */ 60 */
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 if (text === "PASS") 645 if (text === "PASS")
645 this.releaseControl(); 646 this.releaseControl();
646 else if (/^FAIL/.test(text)) 647 else if (/^FAIL/.test(text))
647 this.fail(text); 648 this.fail(text);
648 } 649 }
649 650
650 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleMo del.Events.MessageAdded, onConsoleMessage, this); 651 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleMo del.Events.MessageAdded, onConsoleMessage, this);
651 this.takeControl(); 652 this.takeControl();
652 }; 653 };
653 654
654 TestSuite.prototype.invokeAsyncWithTimeline_ = function(functionName, callback) 655 TestSuite.prototype.startTimeline = function(callback)
655 { 656 {
656 var test = this; 657 this.showPanel("timeline").then(function() {
657 test.showPanel("timeline").then(function() {
658 WebInspector.panels.timeline._model.addEventListener(WebInspector.Timeli neModel.Events.RecordingStarted, onRecordingStarted); 658 WebInspector.panels.timeline._model.addEventListener(WebInspector.Timeli neModel.Events.RecordingStarted, onRecordingStarted);
659 WebInspector.panels.timeline._toggleRecording(); 659 WebInspector.panels.timeline._toggleRecording();
660 }); 660 });
661 661
662 function onRecordingStarted() 662 function onRecordingStarted()
663 { 663 {
664 WebInspector.panels.timeline._model.removeEventListener(WebInspector.Tim elineModel.Events.RecordingStarted, onRecordingStarted); 664 WebInspector.panels.timeline._model.removeEventListener(WebInspector.Tim elineModel.Events.RecordingStarted, onRecordingStarted);
665 test.evaluateInConsole_(functionName + "(function() { console.log('DONE' ); });", function() {}); 665 callback();
666 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso leModel.Events.MessageAdded, onConsoleMessage);
667 } 666 }
667 }
668 668
669 function onConsoleMessage(event) 669 TestSuite.prototype.stopTimeline = function(callback)
670 { 670 {
671 var text = event.data.messageText; 671 WebInspector.panels.timeline._model.addEventListener(WebInspector.TimelineMo del.Events.RecordingStopped, onRecordingStopped);
672 if (text === "DONE") { 672 WebInspector.panels.timeline._toggleRecording();
673 WebInspector.multitargetConsoleModel.removeEventListener(WebInspecto r.ConsoleModel.Events.MessageAdded, onConsoleMessage);
674 pageActionsDone();
675 }
676 }
677
678 function pageActionsDone()
679 {
680 WebInspector.panels.timeline._model.addEventListener(WebInspector.Timeli neModel.Events.RecordingStopped, onRecordingStopped);
681 WebInspector.panels.timeline._toggleRecording();
682 }
683
684 function onRecordingStopped() 673 function onRecordingStopped()
685 { 674 {
686 WebInspector.panels.timeline._model.removeEventListener(WebInspector.Tim elineModel.Events.RecordingStopped, onRecordingStopped); 675 WebInspector.panels.timeline._model.removeEventListener(WebInspector.Tim elineModel.Events.RecordingStopped, onRecordingStopped);
687 callback(); 676 callback();
688 } 677 }
678 }
679
680 TestSuite.prototype.invokePageFunctionAsync = function(functionName, opt_args, c allback_is_always_last)
681 {
682 var callback = arguments[arguments.length - 1];
683 var doneMessage = `DONE: ${functionName}.${++this._asyncInvocationId}`;
684 var argsString = arguments.length < 3 ? "" : Array.prototype.slice.call(argu ments, 1, -1).map(arg => JSON.stringify(arg)).join(",") + ",";
685 this.evaluateInConsole_(`${functionName}(${argsString} function() { console. log('${doneMessage}'); });`, function() {});
686 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleMo del.Events.MessageAdded, onConsoleMessage);
687
688 function onConsoleMessage(event)
689 {
690 var text = event.data.messageText;
691 if (text === doneMessage) {
692 WebInspector.multitargetConsoleModel.removeEventListener(WebInspecto r.ConsoleModel.Events.MessageAdded, onConsoleMessage);
693 callback();
694 }
695 }
696 }
697
698 TestSuite.prototype.invokeAsyncWithTimeline_ = function(functionName, callback)
699 {
700 var test = this;
701
702 this.startTimeline(onRecordingStarted);
703
704 function onRecordingStarted()
705 {
706 test.invokePageFunctionAsync(functionName, pageActionsDone);
707 }
708
709 function pageActionsDone()
710 {
711 test.stopTimeline(callback);
712 }
689 }; 713 };
690 714
715 TestSuite.prototype.enableExperiment = function(name)
716 {
717 Runtime.experiments.enableForTest(name);
718 }
719
720 TestSuite.prototype.checkInputEventsPresent = function()
721 {
722 var expectedEvents = new Set(arguments);
723 var model = WebInspector.panels.timeline._model;
724 var asyncEvents = model.mainThreadAsyncEvents();
725 var input = asyncEvents.get(WebInspector.TimelineUIUtils.asyncEventGroups(). input) || [];
726 var prefix = "InputLatency::";
727 for (var e of input) {
728 if (!e.name.startsWith(prefix))
729 continue;
730 expectedEvents.delete(e.name.substr(prefix.length));
731 }
732 if (expectedEvents.size)
733 throw "Some expected events are not found: " + Array.from(expectedEvents .keys()).join(",");
734 }
735
691 /** 736 /**
692 * Serializes array of uiSourceCodes to string. 737 * Serializes array of uiSourceCodes to string.
693 * @param {!Array.<!WebInspectorUISourceCode>} uiSourceCodes 738 * @param {!Array.<!WebInspectorUISourceCode>} uiSourceCodes
694 * @return {string} 739 * @return {string}
695 */ 740 */
696 TestSuite.prototype.uiSourceCodesToString_ = function(uiSourceCodes) 741 TestSuite.prototype.uiSourceCodesToString_ = function(uiSourceCodes)
697 { 742 {
698 var names = []; 743 var names = [];
699 for (var i = 0; i < uiSourceCodes.length; i++) 744 for (var i = 0; i < uiSourceCodes.length; i++)
700 names.push('"' + WebInspector.networkMapping.networkURL(uiSourceCodes[i] ) + '"'); 745 names.push('"' + WebInspector.networkMapping.networkURL(uiSourceCodes[i] ) + '"');
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 }; 878 };
834 879
835 return new TestSuite(); 880 return new TestSuite();
836 881
837 } 882 }
838 883
839 if (window.uiTests) { 884 if (window.uiTests) {
840 WebInspector.notifications.addEventListener(WebInspector.NotificationService .Events.InspectorAgentEnabledForTests, 885 WebInspector.notifications.addEventListener(WebInspector.NotificationService .Events.InspectorAgentEnabledForTests,
841 window.uiTests.testSuiteReady.bind(null, createTestSuite)); 886 window.uiTests.testSuiteReady.bind(null, createTestSuite));
842 } 887 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/common/TestBase.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698