Home | History | Annotate | Download | only in metrics
      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 telemetry.page import page as page_module
      6 from telemetry.results import page_test_results
      7 from telemetry.value import scalar
      8 
      9 
     10 class TestPageTestResults(
     11     page_test_results.PageTestResults):
     12   def __init__(self, test):
     13     super(TestPageTestResults, self).__init__()
     14     self.test = test
     15     page = page_module.Page("http://www.google.com", {})
     16     self.WillRunPage(page)
     17 
     18   def GetPageSpecificValueNamed(self, name):
     19     values = [value for value in self.all_page_specific_values
     20          if value.name == name]
     21     assert len(values) == 1, 'Could not find value named %s' % name
     22     return values[0]
     23 
     24   def AssertHasPageSpecificScalarValue(self, name, units, expected_value):
     25     value = self.GetPageSpecificValueNamed(name)
     26     self.test.assertEquals(units, value.units)
     27     self.test.assertTrue(isinstance(value, scalar.ScalarValue))
     28     self.test.assertEquals(expected_value, value.value)
     29 
     30   def __str__(self):
     31     return '\n'.join([repr(x) for x in self.all_page_specific_values])
     32