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

Unified Diff: LayoutTests/inspector-protocol/timeline/timeline-timer.html

Issue 391413003: DevTools: [Timeline] extract common infrastructure from tracing tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: comments addressed Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/inspector-protocol/timeline/timeline-raf.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/inspector-protocol/timeline/timeline-timer.html
diff --git a/LayoutTests/inspector-protocol/timeline/timeline-timer.html b/LayoutTests/inspector-protocol/timeline/timeline-timer.html
index 4c69c735b77dcf78e16a11e0f450a47eb62b555b..106935cde4a093e7c4fe9db74a91638b47d5e62e 100644
--- a/LayoutTests/inspector-protocol/timeline/timeline-timer.html
+++ b/LayoutTests/inspector-protocol/timeline/timeline-timer.html
@@ -1,13 +1,15 @@
<html>
<head>
<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
+<script type="text/javascript" src="../../http/tests/inspector-protocol/tracing-test.js"></script>
<script>
-function testFunction()
+function performActions(callback)
{
var timerId = setTimeout(function()
{
evaluateInFrontend("InspectorTest.testFunctionTimerFired(" + timerId + ", " + timerId2 + ")");
+ callback();
}, 0);
var timerId2 = setTimeout(function() { }, 0);
@@ -17,9 +19,7 @@ function testFunction()
function test()
{
- InspectorTest.eventHandler["Tracing.dataCollected"] = dataCollected;
- InspectorTest.eventHandler["Tracing.tracingComplete"] = tracingComplete;
- InspectorTest.sendCommand("Tracing.start", { "categories" : "disabled-by-default-devtools.timeline", "type": "" }, onStart);
+ InspectorTest.invokeAsyncWithTracing("performActions", finish);
var firedTimerId;
var removedTimerId;
@@ -28,58 +28,24 @@ function test()
firedTimerId = timerId1;
removedTimerId = timerId2;
InspectorTest.log("SUCCESS: testFunctionTimerFired");
- InspectorTest.sendCommand("Tracing.end", { }, onStop);
}
- function onStart(response)
+ function finish(devtoolsEvents)
{
- InspectorTest.log("Recording started");
- InspectorTest.sendCommand("Runtime.evaluate", { "expression": "testFunction()" });
- }
-
- var devtoolsEvents = [];
- function dataCollected(reply)
- {
- var allEvents = reply.params.value;
- devtoolsEvents = devtoolsEvents.concat(allEvents.filter(function(e)
- {
- return e.cat === "disabled-by-default-devtools.timeline";
- }));
- }
-
- function tracingComplete(event)
- {
- InspectorTest.log("Tracing complete");
-
function hasTimerId(id, e) { return e.args.data.timerId === id}
- var installTimer1 = findEvent("TimerInstall", "I", hasTimerId.bind(this, firedTimerId));
- var installTimer2 = findEvent("TimerInstall", "I", hasTimerId.bind(this, removedTimerId));
+ var installTimer1 = InspectorTest.findEvent("TimerInstall", "I", hasTimerId.bind(this, firedTimerId));
+ var installTimer2 = InspectorTest.findEvent("TimerInstall", "I", hasTimerId.bind(this, removedTimerId));
InspectorTest.assert(!!installTimer1.args.data.frame, "TimerInstall frame");
InspectorTest.assertEquals(installTimer1.args.data.frame, installTimer2.args.data.frame, "TimerInstall frame match");
- findEvent("TimerRemove", "I", hasTimerId.bind(this, removedTimerId));
- findEvent("TimerFire", "X", hasTimerId.bind(this, firedTimerId));
+ InspectorTest.findEvent("TimerRemove", "I", hasTimerId.bind(this, removedTimerId));
+ InspectorTest.findEvent("TimerFire", "X", hasTimerId.bind(this, firedTimerId));
InspectorTest.log("SUCCESS: found all expected events.");
InspectorTest.completeTest();
}
-
- function findEvent(name, ph, condition)
- {
- for (var i = 0; i < devtoolsEvents.length; i++) {
- var e = devtoolsEvents[i];
- if (e.name === name && e.ph === ph && (!condition || condition(e)))
- return e;
- }
- throw new Error("Couldn't find event " + name + " / " + ph + "\n\n in " + JSON.stringify(devtoolsEvents, null, 2));
- }
-
- function onStop(response)
- {
- InspectorTest.log("Recording stopped");
- }
}
</script>
</head>
« no previous file with comments | « LayoutTests/inspector-protocol/timeline/timeline-raf.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698