Chromium Code Reviews| Index: tools/perf/measurements/task_execution_time_unittest.py |
| diff --git a/tools/perf/measurements/task_execution_time_unittest.py b/tools/perf/measurements/task_execution_time_unittest.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1798bf2004151fab8325673f9841589401657ecf |
| --- /dev/null |
| +++ b/tools/perf/measurements/task_execution_time_unittest.py |
| @@ -0,0 +1,56 @@ |
| +# Copyright 2014 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 measurements import task_execution_time |
| +from telemetry.core import wpr_modes |
| +from telemetry.page import page as page_module |
| +from telemetry.unittest import options_for_unittests |
| +from telemetry.unittest import page_test_test_case |
| + |
| +class TestTaskExecutionTimePage(page_module.Page): |
| + def __init__(self, page_set, base_dir): |
| + super(TestTaskExecutionTimePage, self).__init__('file://blank.html', |
| + page_set, base_dir) |
| + |
| + def RunTaskExecutionTime(self, action_runner): |
| + interaction = action_runner.BeginGestureInteraction( |
| + 'ScrollAction', is_smooth=True) |
| + action_runner.ScrollPage() |
| + interaction.End() |
| + |
| + |
| +def dump(obj): |
| + for attr in dir(obj): |
| + print "obj.%s = %s" % (attr, getattr(obj, attr)) |
| + |
| +class TaskExecutionTimeUnitTest(page_test_test_case.PageTestTestCase): |
| + """Unit test for task execution time measurement |
| + """ |
|
Sami
2014/10/10 17:41:43
Looks like this would fit on the previous line. Th
picksi1
2014/10/13 15:19:39
Removed this comment as it is redundant.
|
| + |
| + def setUp(self): |
| + self._options = options_for_unittests.GetCopy() |
| + self._options.browser_options.wpr_mode = wpr_modes.WPR_OFF |
| + |
| + def testCorrectNumberOfResultsReturned(self): |
| + ps = self.CreateEmptyPageSet() |
| + ps.AddPage(TestTaskExecutionTimePage(ps, ps.base_dir)) |
| + measurement = task_execution_time.TaskExecutionTime() |
| + |
| + results = self.RunMeasurement(measurement, ps, options=self._options) |
| + |
| + self.assertEquals( |
|
Sami
2014/10/10 17:41:43
nit pick: What if there are less than 10 tasks in
picksi1
2014/10/13 15:19:39
Hmmm. I did consider hand-creating some event data
|
| + task_execution_time.TaskExecutionTime.GetExpectedResultCount(), |
| + len(results.all_page_specific_values)) |
| + |
| + def testResultsAreDecreasing(self): |
| + ps = self.CreateEmptyPageSet() |
| + ps.AddPage(TestTaskExecutionTimePage(ps, ps.base_dir)) |
| + measurement = task_execution_time.TaskExecutionTime() |
| + |
| + results = self.RunMeasurement(measurement, ps, options=self._options) |
| + |
| + for index in xrange(len(results.all_page_specific_values) - 1): |
| + self.assertTrue( |
| + results.all_page_specific_values[index].value >= |
| + results.all_page_specific_values[index+1].value) |
|
Sami
2014/10/10 17:41:43
nit: spaces around the plus.
A fancier way to do
picksi1
2014/10/13 15:19:39
Nice. Petr, Simon and myself discussed the various
|