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..55789bc81023ee62806ad600f316dcd31b83dc67 |
| --- /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 |
| + |
|
Sami
2014/10/16 10:20:30
nit: one more blank line here.
picksi1
2014/10/17 08:34:49
Done.
|
| +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): |
|
Sami
2014/10/16 10:20:30
This isn't used anywhere, is it?
picksi1
2014/10/17 08:34:49
Oops. Well spotted, that's just debug code.
|
| + 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:]): |
| + self.assertGreaterEqual(first.value, second.value) |