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

Unified Diff: tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_timeline_unittest.py

Issue 903523002: Revert of Remove usages of Timeline commands in telemetry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_timeline_unittest.py
diff --git a/tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_timeline_unittest.py b/tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_timeline_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..f653b9c18fd107b2056d39d1233741ae6ff62a24
--- /dev/null
+++ b/tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_timeline_unittest.py
@@ -0,0 +1,41 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from telemetry.core import util
+from telemetry.core.backends.chrome_inspector import inspector_timeline
+from telemetry.unittest_util import tab_test_case
+
+
+class InspectorTimelineTabTest(tab_test_case.TabTestCase):
+ """Test case that opens a browser and creates and then checks an event."""
+
+ def _WaitForAnimationFrame(self):
+ """Wait until the variable window.done is set on the tab."""
+ def _IsDone():
+ return bool(self._tab.EvaluateJavaScript('window.done'))
+ util.WaitFor(_IsDone, 5)
+
+ def testGotTimeline(self):
+ # While the timeline is recording, call window.webkitRequestAnimationFrame.
+ # This will create a FireAnimationEvent, which can be checked below. See:
+ # https://developer.mozilla.org/en/docs/Web/API/window.requestAnimationFrame
+ with inspector_timeline.InspectorTimeline.Recorder(self._tab):
+ self._tab.ExecuteJavaScript(
+ """
+ var done = false;
+ function sleep(ms) {
+ var endTime = (new Date().getTime()) + ms;
+ while ((new Date().getTime()) < endTime);
+ }
+ window.webkitRequestAnimationFrame(function() {
+ sleep(10);
+ window.done = true;
+ });
+ """)
+ self._WaitForAnimationFrame()
+
+ # There should be at least a FireAnimationFrame record with some duration.
+ events = self._tab.timeline_model.GetAllEventsOfName('FireAnimationFrame')
+ self.assertTrue(len(events) > 0)
+ self.assertTrue(events[0].duration > 0)

Powered by Google App Engine
This is Rietveld 408576698