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 | |
| 11 class TestTaskExecutionTimePage(page_module.Page): | |
| 12 def __init__(self, page_set, base_dir): | |
| 13 super(TestTaskExecutionTimePage, self).__init__('file://blank.html', | |
| 14 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): | |
| 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 """Unit test for task execution time measurement | |
| 29 """ | |
|
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.
| |
| 30 | |
| 31 def setUp(self): | |
| 32 self._options = options_for_unittests.GetCopy() | |
| 33 self._options.browser_options.wpr_mode = wpr_modes.WPR_OFF | |
| 34 | |
| 35 def testCorrectNumberOfResultsReturned(self): | |
| 36 ps = self.CreateEmptyPageSet() | |
| 37 ps.AddPage(TestTaskExecutionTimePage(ps, ps.base_dir)) | |
| 38 measurement = task_execution_time.TaskExecutionTime() | |
| 39 | |
| 40 results = self.RunMeasurement(measurement, ps, options=self._options) | |
| 41 | |
| 42 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
| |
| 43 task_execution_time.TaskExecutionTime.GetExpectedResultCount(), | |
| 44 len(results.all_page_specific_values)) | |
| 45 | |
| 46 def testResultsAreDecreasing(self): | |
| 47 ps = self.CreateEmptyPageSet() | |
| 48 ps.AddPage(TestTaskExecutionTimePage(ps, ps.base_dir)) | |
| 49 measurement = task_execution_time.TaskExecutionTime() | |
| 50 | |
| 51 results = self.RunMeasurement(measurement, ps, options=self._options) | |
| 52 | |
| 53 for index in xrange(len(results.all_page_specific_values) - 1): | |
| 54 self.assertTrue( | |
| 55 results.all_page_specific_values[index].value >= | |
| 56 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
| |
| OLD | NEW |