| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import os | 5 import os |
| 6 import unittest | 6 import unittest |
| 7 | 7 |
| 8 from telemetry import story | 8 from telemetry import story |
| 9 from telemetry.internal.results import page_test_results | 9 from telemetry.internal.results import page_test_results |
| 10 from telemetry.page import page as page_module | 10 from telemetry.page import page as page_module |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 tbm_module._GetRendererThreadsToInteractionRecordsMap(self._model)) | 100 tbm_module._GetRendererThreadsToInteractionRecordsMap(self._model)) |
| 101 self._story_set = story.StorySet(base_dir=os.path.dirname(__file__)) | 101 self._story_set = story.StorySet(base_dir=os.path.dirname(__file__)) |
| 102 self._story_set.AddStory(page_module.Page( | 102 self._story_set.AddStory(page_module.Page( |
| 103 'http://www.bar.com/', self._story_set, self._story_set.base_dir)) | 103 'http://www.bar.com/', self._story_set, self._story_set.base_dir)) |
| 104 self._results.WillRunPage(self._story_set.stories[0]) | 104 self._results.WillRunPage(self._story_set.stories[0]) |
| 105 | 105 |
| 106 def AddResults(self): | 106 def AddResults(self): |
| 107 all_metrics = self._tbm_options.GetTimelineBasedMetrics() | 107 all_metrics = self._tbm_options.GetTimelineBasedMetrics() |
| 108 | 108 |
| 109 for thread, records in self._threads_to_records_map.iteritems(): | 109 for thread, records in self._threads_to_records_map.iteritems(): |
| 110 metric = tbm_module._TimelineBasedMetrics( # pylint: disable=W0212 | 110 # pylint: disable=protected-access |
| 111 metric = tbm_module._TimelineBasedMetrics( |
| 111 self._model, thread, records, self._results_wrapper, all_metrics) | 112 self._model, thread, records, self._results_wrapper, all_metrics) |
| 112 metric.AddResults(self._results) | 113 metric.AddResults(self._results) |
| 113 | 114 |
| 114 for metric in all_metrics: | 115 for metric in all_metrics: |
| 115 metric.AddWholeTraceResults(self._model, self._results) | 116 metric.AddWholeTraceResults(self._model, self._results) |
| 116 | 117 |
| 117 self._results.DidRunPage(self._story_set.stories[0]) | 118 self._results.DidRunPage(self._story_set.stories[0]) |
| 118 | 119 |
| 119 | 120 |
| 120 class TimelineBasedMetricsTests(unittest.TestCase): | 121 class TimelineBasedMetricsTests(unittest.TestCase): |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 201 |
| 201 def testDuplicateRepeatableInteractions(self): | 202 def testDuplicateRepeatableInteractions(self): |
| 202 d = TimelineBasedMetricTestData(self._options) | 203 d = TimelineBasedMetricTestData(self._options) |
| 203 d.AddInteraction(d.renderer_thread, ts=10, duration=5, | 204 d.AddInteraction(d.renderer_thread, ts=10, duration=5, |
| 204 marker='Interaction.LogicalName/repeatable') | 205 marker='Interaction.LogicalName/repeatable') |
| 205 d.AddInteraction(d.renderer_thread, ts=20, duration=5, | 206 d.AddInteraction(d.renderer_thread, ts=20, duration=5, |
| 206 marker='Interaction.LogicalName/repeatable') | 207 marker='Interaction.LogicalName/repeatable') |
| 207 d.FinalizeImport() | 208 d.FinalizeImport() |
| 208 d.AddResults() | 209 d.AddResults() |
| 209 self.assertEquals(1, len(d.results.pages_that_succeeded)) | 210 self.assertEquals(1, len(d.results.pages_that_succeeded)) |
| OLD | NEW |