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..408054cf88478f2db6bbb709bf1d417653b6c229 |
| --- /dev/null |
| +++ b/tools/perf/measurements/task_execution_time_unittest.py |
| @@ -0,0 +1,52 @@ |
| +# 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) |
|
petrcermak
2014/10/13 16:46:23
The indentation is not in line with the style guid
|
| + |
| + 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): |
| + 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( |
| + 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 first, second in zip(results.all_page_specific_values, |
| + results.all_page_specific_values[1:]): |
|
petrcermak
2014/10/13 16:46:23
ditto.
picksi1
2014/10/16 09:44:28
Done.
|
| + self.assertGreaterEqual(first.value, second.value) |