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

Unified Diff: tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric_unittest.py

Issue 1357423008: [Telemetry] AddIsEventInInteractions helper method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric_unittest.py
diff --git a/tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric_unittest.py b/tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric_unittest.py
index b56b04a202003ef8dd888a6f73c05127b008eeae..94c93d8d01ad750ce34c58c451968e7322e9c4ed 100644
--- a/tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric_unittest.py
+++ b/tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric_unittest.py
@@ -7,6 +7,18 @@ import unittest
import telemetry.web_perf.metrics.timeline_based_metric as tbm_module
+class FakeEvent(object):
+ def __init__(self, start, end):
+ self.start = start
+ self.end = end
+
+
+class FakeRecord(object):
+ def __init__(self, start, end):
+ self.start = start
+ self.end = end
+
+
class TimelineBasedMetricTest(unittest.TestCase):
# pylint: disable=W0212
@@ -26,3 +38,21 @@ class TimelineBasedMetricTest(unittest.TestCase):
self.assertFalse(tbm_module._TimeRangesHasOverlap([(15, 18), (20, 25)]))
self.assertFalse(tbm_module._TimeRangesHasOverlap(
[(1, 2), (2, 3), (0, 1)]))
+
+ def testIsEventInInteractions(self):
+ self.assertFalse(
+ tbm_module.IsEventInInteractions(
+ FakeEvent(0, 100),
+ [FakeRecord(5, 105), FakeRecord(50, 200), FakeRecord(300, 400)]))
+ self.assertFalse(
+ tbm_module.IsEventInInteractions(
+ FakeEvent(50, 100),
+ [FakeRecord(105, 205), FakeRecord(0, 45), FakeRecord(0, 90)]))
+ self.assertTrue(
+ tbm_module.IsEventInInteractions(
+ FakeEvent(50, 100),
+ [FakeRecord(5, 105), FakeRecord(0, 45), FakeRecord(0, 90)]))
+ self.assertTrue(
+ tbm_module.IsEventInInteractions(
+ FakeEvent(50, 100),
+ [FakeRecord(5, 45), FakeRecord(0, 45), FakeRecord(0, 100)]))
« no previous file with comments | « tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698