Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from measurements import task_execution_time | |
| 6 from telemetry.core import wpr_modes | |
| 7 from telemetry.page import page as page_module | |
| 8 from telemetry.unittest import options_for_unittests | |
| 9 from telemetry.unittest import page_test_test_case | |
| 10 | |
|
Sami
2014/10/16 10:20:30
nit: one more blank line here.
picksi1
2014/10/17 08:34:49
Done.
| |
| 11 class TestTaskExecutionTimePage(page_module.Page): | |
| 12 def __init__(self, page_set, base_dir): | |
| 13 super(TestTaskExecutionTimePage, self).__init__( | |
| 14 'file://blank.html', page_set, base_dir) | |
| 15 | |
| 16 def RunTaskExecutionTime(self, action_runner): | |
| 17 interaction = action_runner.BeginGestureInteraction( | |
| 18 'ScrollAction', is_smooth=True) | |
| 19 action_runner.ScrollPage() | |
| 20 interaction.End() | |
| 21 | |
| 22 | |
| 23 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.
| |
| 24 for attr in dir(obj): | |
| 25 print "obj.%s = %s" % (attr, getattr(obj, attr)) | |
| 26 | |
| 27 class TaskExecutionTimeUnitTest(page_test_test_case.PageTestTestCase): | |
| 28 def setUp(self): | |
| 29 self._options = options_for_unittests.GetCopy() | |
| 30 self._options.browser_options.wpr_mode = wpr_modes.WPR_OFF | |
| 31 | |
| 32 def testCorrectNumberOfResultsReturned(self): | |
| 33 ps = self.CreateEmptyPageSet() | |
| 34 ps.AddPage(TestTaskExecutionTimePage(ps, ps.base_dir)) | |
| 35 measurement = task_execution_time.TaskExecutionTime() | |
| 36 | |
| 37 results = self.RunMeasurement(measurement, ps, options=self._options) | |
| 38 | |
| 39 self.assertEquals( | |
| 40 task_execution_time.TaskExecutionTime.GetExpectedResultCount(), | |
| 41 len(results.all_page_specific_values)) | |
| 42 | |
| 43 def testResultsAreDecreasing(self): | |
| 44 ps = self.CreateEmptyPageSet() | |
| 45 ps.AddPage(TestTaskExecutionTimePage(ps, ps.base_dir)) | |
| 46 measurement = task_execution_time.TaskExecutionTime() | |
| 47 | |
| 48 results = self.RunMeasurement(measurement, ps, options=self._options) | |
| 49 | |
| 50 for first, second in zip( | |
| 51 results.all_page_specific_values, results.all_page_specific_values[1:]): | |
| 52 self.assertGreaterEqual(first.value, second.value) | |
| OLD | NEW |