Commit eceaabf4 authored by dtu@chromium.org's avatar dtu@chromium.org

[telemetry] Cleanups for benchmarks importing page sets.

Some of the code from a previous prototype [1] pulled out into a smaller patch that can be committed.

[1] https://chromiumcodereview.appspot.com/274773002/


BUG=362293

Review URL: https://codereview.chromium.org/311193003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275633 0039d316-1c4b-4281-b951-d872f2087c98
parent 5210d592
...@@ -183,7 +183,6 @@ class ContextLost(test_module.Test): ...@@ -183,7 +183,6 @@ class ContextLost(test_module.Test):
def CreatePageSet(self, options): def CreatePageSet(self, options):
ps = page_set.PageSet( ps = page_set.PageSet(
file_path=data_path, file_path=data_path,
description='Test cases for real and synthetic context lost events',
user_agent_type='desktop', user_agent_type='desktop',
serving_dirs=set([''])) serving_dirs=set(['']))
ps.AddPage(WebGLContextLostFromGPUProcessExitPage(ps, ps.base_dir)) ps.AddPage(WebGLContextLostFromGPUProcessExitPage(ps, ps.base_dir))
......
...@@ -53,10 +53,7 @@ class HardwareAcceleratedFeature(test.Test): ...@@ -53,10 +53,7 @@ class HardwareAcceleratedFeature(test.Test):
def CreatePageSet(self, options): def CreatePageSet(self, options):
features = ['WebGL', 'Canvas'] features = ['WebGL', 'Canvas']
ps = page_set.PageSet( ps = page_set.PageSet(user_agent_type='desktop', file_path='')
description='Tests GPU acceleration is reported as active',
user_agent_type='desktop',
file_path='')
for feature in features: for feature in features:
ps.AddPage(ChromeGpuPage(page_set=ps, feature=feature)) ps.AddPage(ChromeGpuPage(page_set=ps, feature=feature))
......
...@@ -52,9 +52,6 @@ class ScreenshotSyncProcess(test.Test): ...@@ -52,9 +52,6 @@ class ScreenshotSyncProcess(test.Test):
return expectations.ScreenshotSyncExpectations() return expectations.ScreenshotSyncExpectations()
def CreatePageSet(self, options): def CreatePageSet(self, options):
ps = page_set.PageSet( ps = page_set.PageSet(file_path=data_path, serving_dirs=[''])
file_path=data_path,
description='Test cases for screenshot synchronization',
serving_dirs=[''])
ps.AddPage(ScreenshotSyncPage(ps, ps.base_dir)) ps.AddPage(ScreenshotSyncPage(ps, ps.base_dir))
return ps return ps
...@@ -108,7 +108,6 @@ class WebglConformance(test_module.Test): ...@@ -108,7 +108,6 @@ class WebglConformance(test_module.Test):
options.webgl_conformance_version) options.webgl_conformance_version)
ps = page_set.PageSet( ps = page_set.PageSet(
description='Executes WebGL conformance tests',
user_agent_type='desktop', user_agent_type='desktop',
serving_dirs=[''], serving_dirs=[''],
file_path=conformance_path) file_path=conformance_path)
......
...@@ -67,7 +67,6 @@ class WebglRobustness(test.Test): ...@@ -67,7 +67,6 @@ class WebglRobustness(test.Test):
def CreatePageSet(self, options): def CreatePageSet(self, options):
ps = page_set.PageSet( ps = page_set.PageSet(
file_path=conformance_path, file_path=conformance_path,
description='Test cases for WebGL robustness',
user_agent_type='desktop', user_agent_type='desktop',
serving_dirs=['']) serving_dirs=[''])
ps.AddPage(WebglRobustnessPage(ps, ps.base_dir)) ps.AddPage(WebglRobustnessPage(ps, ps.base_dir))
......
...@@ -4,13 +4,12 @@ ...@@ -4,13 +4,12 @@
import os import os
from telemetry.core import discover
from telemetry.page import page_set as page_set_module
from telemetry.page import page_set_archive_info
from telemetry.unittest import page_set_smoke_test from telemetry.unittest import page_set_smoke_test
class PageSetUnitTest(page_set_smoke_test.PageSetSmokeTest): class PageSetUnitTest(page_set_smoke_test.PageSetSmokeTest):
def testSmoke(self): def testSmoke(self):
self.RunSmokeTest(os.path.dirname(__file__)) page_sets_dir = os.path.dirname(os.path.realpath(__file__))
top_level_dir = os.path.dirname(page_sets_dir)
self.RunSmokeTest(page_sets_dir, top_level_dir)
...@@ -3,18 +3,15 @@ ...@@ -3,18 +3,15 @@
# found in the LICENSE file. # found in the LICENSE file.
from telemetry import test from telemetry import test
from measurements import chrome_proxy from measurements import chrome_proxy
from page_sets.chrome_proxy import bypass import page_sets
from page_sets.chrome_proxy import fallback_viaheader
from page_sets.chrome_proxy import safebrowsing
from page_sets.chrome_proxy import smoke
from page_sets.chrome_proxy import synthetic
from page_sets.chrome_proxy import top_20
class ChromeProxyLatency(test.Test): class ChromeProxyLatency(test.Test):
tag = 'latency' tag = 'latency'
test = chrome_proxy.ChromeProxyLatency test = chrome_proxy.ChromeProxyLatency
page_set = top_20.Top20PageSet() page_set = page_sets.Top20PageSet
options = {'pageset_repeat_iters': 2} options = {'pageset_repeat_iters': 2}
def CustomizeBrowserOptions(self, options): def CustomizeBrowserOptions(self, options):
...@@ -24,22 +21,22 @@ class ChromeProxyLatency(test.Test): ...@@ -24,22 +21,22 @@ class ChromeProxyLatency(test.Test):
class ChromeProxyLatencyDirect(test.Test): class ChromeProxyLatencyDirect(test.Test):
tag = 'latency_direct' tag = 'latency_direct'
test = chrome_proxy.ChromeProxyLatency test = chrome_proxy.ChromeProxyLatency
page_set = top_20.Top20PageSet() page_set = page_sets.Top20PageSet
options = {'pageset_repeat_iters': 2} options = {'pageset_repeat_iters': 2}
class ChromeProxyLatencySynthetic(ChromeProxyLatency): class ChromeProxyLatencySynthetic(ChromeProxyLatency):
page_set = synthetic.SyntheticPageSet() page_set = page_sets.SyntheticPageSet
class ChromeProxyLatencySyntheticDirect(ChromeProxyLatencyDirect): class ChromeProxyLatencySyntheticDirect(ChromeProxyLatencyDirect):
page_set = synthetic.SyntheticPageSet() page_set = page_sets.SyntheticPageSet
class ChromeProxyDataSaving(test.Test): class ChromeProxyDataSaving(test.Test):
tag = 'data_saving' tag = 'data_saving'
test = chrome_proxy.ChromeProxyDataSaving test = chrome_proxy.ChromeProxyDataSaving
page_set = top_20.Top20PageSet() page_set = page_sets.Top20PageSet
options = {'pageset_repeat_iters': 1} options = {'pageset_repeat_iters': 1}
def CustomizeBrowserOptions(self, options): def CustomizeBrowserOptions(self, options):
options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth') options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
...@@ -48,49 +45,49 @@ class ChromeProxyDataSaving(test.Test): ...@@ -48,49 +45,49 @@ class ChromeProxyDataSaving(test.Test):
class ChromeProxyDataSavingDirect(test.Test): class ChromeProxyDataSavingDirect(test.Test):
tag = 'data_saving_direct' tag = 'data_saving_direct'
test = chrome_proxy.ChromeProxyDataSaving test = chrome_proxy.ChromeProxyDataSaving
page_set = page_sets.Top20PageSet
options = {'pageset_repeat_iters': 2} options = {'pageset_repeat_iters': 2}
page_set = top_20.Top20PageSet()
class ChromeProxyDataSavingSynthetic(ChromeProxyDataSaving): class ChromeProxyDataSavingSynthetic(ChromeProxyDataSaving):
page_set = synthetic.SyntheticPageSet() page_set = page_sets.SyntheticPageSet
class ChromeProxyDataSavingSyntheticDirect(ChromeProxyDataSavingDirect): class ChromeProxyDataSavingSyntheticDirect(ChromeProxyDataSavingDirect):
page_set = synthetic.SyntheticPageSet() page_set = page_sets.SyntheticPageSet
class ChromeProxyHeaderValidation(test.Test): class ChromeProxyHeaderValidation(test.Test):
tag = 'header_validation' tag = 'header_validation'
test = chrome_proxy.ChromeProxyHeaders test = chrome_proxy.ChromeProxyHeaders
page_set = top_20.Top20PageSet() page_set = page_sets.Top20PageSet
class ChromeProxyBypass(test.Test): class ChromeProxyBypass(test.Test):
tag = 'bypass' tag = 'bypass'
test = chrome_proxy.ChromeProxyBypass test = chrome_proxy.ChromeProxyBypass
page_set = bypass.BypassPageSet() page_set = page_sets.BypassPageSet
class ChromeProxySafeBrowsing(test.Test): class ChromeProxySafeBrowsing(test.Test):
tag = 'safebrowsing' tag = 'safebrowsing'
test = chrome_proxy.ChromeProxySafebrowsing test = chrome_proxy.ChromeProxySafebrowsing
page_set = safebrowsing.SafebrowsingPageSet() page_set = page_sets.SafebrowsingPageSet
class ChromeProxyHTTPFallbackProbeURL(test.Test): class ChromeProxyHTTPFallbackProbeURL(test.Test):
tag = 'fallback-probe' tag = 'fallback-probe'
test = chrome_proxy.ChromeProxyHTTPFallbackProbeURL test = chrome_proxy.ChromeProxyHTTPFallbackProbeURL
page_set = synthetic.SyntheticPageSet() page_set = page_sets.SyntheticPageSet
class ChromeProxyHTTPFallbackViaHeader(test.Test): class ChromeProxyHTTPFallbackViaHeader(test.Test):
tag = 'fallback-viaheader' tag = 'fallback-viaheader'
test = chrome_proxy.ChromeProxyHTTPFallbackViaHeader test = chrome_proxy.ChromeProxyHTTPFallbackViaHeader
page_set = fallback_viaheader.FallbackViaHeaderPageSet() page_set = page_sets.FallbackViaHeaderPageSet
class ChromeProxySmoke(test.Test): class ChromeProxySmoke(test.Test):
tag = 'smoke' tag = 'smoke'
test = chrome_proxy.ChromeProxySmoke test = chrome_proxy.ChromeProxySmoke
page_set = smoke.SmokePageSet() page_set = page_sets.SmokePageSet
...@@ -57,13 +57,9 @@ class _DromaeoBenchmark(test.Test): ...@@ -57,13 +57,9 @@ class _DromaeoBenchmark(test.Test):
if not hasattr(self, 'query_param'): if not hasattr(self, 'query_param'):
raise NotImplementedError('query_param not in Dromaeo benchmark.') raise NotImplementedError('query_param not in Dromaeo benchmark.')
url = 'file://index.html?%s&automated' % self.query_param url = 'file://index.html?%s&automated' % self.query_param
# The docstring of benchmark classes may also be used as a description
# when 'run_benchmarks list' is run.
description = self.__doc__ or 'Dromaeo JavaScript Benchmark'
dromaeo_dir = os.path.join(util.GetChromiumSrcDir(), dromaeo_dir = os.path.join(util.GetChromiumSrcDir(),
'chrome', 'test', 'data', 'dromaeo') 'chrome', 'test', 'data', 'dromaeo')
ps = page_set.PageSet(description=description, ps = page_set.PageSet(file_path=dromaeo_dir)
file_path=dromaeo_dir)
ps.AddPageWithDefaultRunNavigate(url) ps.AddPageWithDefaultRunNavigate(url)
return ps return ps
......
...@@ -4,30 +4,27 @@ ...@@ -4,30 +4,27 @@
from telemetry import test from telemetry import test
from measurements import memory from measurements import memory
from page_sets import mobile_memory import page_sets
from page_sets import top_25
from page_sets import top_desktop_sites_2012Q3
from page_sets import tough_dom_memory_cases
@test.Disabled('android') # crbug.com/370977 @test.Disabled('android') # crbug.com/370977
class MemoryMobile(test.Test): class MemoryMobile(test.Test):
test = memory.Memory test = memory.Memory
page_set = mobile_memory.MobileMemoryPageSet() page_set = page_sets.MobileMemoryPageSet
class MemoryTop25(test.Test): class MemoryTop25(test.Test):
test = memory.Memory test = memory.Memory
page_set = top_25.Top25PageSet() page_set = page_sets.Top25PageSet
class Reload2012Q3(test.Test): class Reload2012Q3(test.Test):
tag = 'reload' tag = 'reload'
test = memory.Memory test = memory.Memory
page_set = top_desktop_sites_2012Q3.Top2012Q3PageSet() page_set = page_sets.Top2012Q3PageSet
@test.Disabled('android') # crbug.com/371153 @test.Disabled('android') # crbug.com/371153
class MemoryToughDomMemoryCases(test.Test): class MemoryToughDomMemoryCases(test.Test):
test = memory.Memory test = memory.Memory
page_set = tough_dom_memory_cases.ToughDomMemoryCasesPageSet() page_set = page_sets.ToughDomMemoryCasesPageSet
...@@ -78,11 +78,7 @@ class PeaceKeeperBenchmark(test.Test): ...@@ -78,11 +78,7 @@ class PeaceKeeperBenchmark(test.Test):
if not hasattr(self, 'test_param'): if not hasattr(self, 'test_param'):
raise NotImplementedError('test_param not in PeaceKeeper benchmark.') raise NotImplementedError('test_param not in PeaceKeeper benchmark.')
# The docstring of benchmark classes may also be used as a description
# when 'run_benchmarks list' is run.
description = self.__doc__ or 'PeaceKeeper Benchmark'
ps = page_set.PageSet( ps = page_set.PageSet(
description=description,
archive_data_file='../page_sets/data/peacekeeper_%s.json' % self.tag, archive_data_file='../page_sets/data/peacekeeper_%s.json' % self.tag,
make_javascript_deterministic=False) make_javascript_deterministic=False)
for test_name in self.test_param: for test_name in self.test_param:
......
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from telemetry import test
from benchmarks import silk_flags from benchmarks import silk_flags
from measurements import smoothness from measurements import smoothness
from telemetry import test import page_sets
@test.Disabled # crbug.com/368767 @test.Disabled # crbug.com/368767
...@@ -13,24 +15,24 @@ class SmoothnessTop25(test.Test): ...@@ -13,24 +15,24 @@ class SmoothnessTop25(test.Test):
http://www.chromium.org/developers/design-documents/rendering-benchmarks""" http://www.chromium.org/developers/design-documents/rendering-benchmarks"""
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/top_25.py' page_set = page_sets.Top25PageSet
@test.Disabled('linux', 'mac', 'win') # crbug.com/368767 @test.Disabled('linux', 'mac', 'win') # crbug.com/368767
class SmoothnessToughCanvasCases(test.Test): class SmoothnessToughCanvasCases(test.Test):
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/tough_canvas_cases.py' page_set = page_sets.ToughCanvasCasesPageSet
@test.Disabled # crbug.com/373812 @test.Disabled # crbug.com/373812
class SmoothnessToughWebGLCases(test.Test): class SmoothnessToughWebGLCases(test.Test):
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/tough_webgl_cases.py' page_set = page_sets.ToughWebglCasesPageSet
class SmoothnessMaps(test.Test): class SmoothnessMaps(test.Test):
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/maps.py' page_set = page_sets.MapsPageSet
class SmoothnessKeyMobileSites(test.Test): class SmoothnessKeyMobileSites(test.Test):
...@@ -38,13 +40,13 @@ class SmoothnessKeyMobileSites(test.Test): ...@@ -38,13 +40,13 @@ class SmoothnessKeyMobileSites(test.Test):
http://www.chromium.org/developers/design-documents/rendering-benchmarks""" http://www.chromium.org/developers/design-documents/rendering-benchmarks"""
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/key_mobile_sites.py' page_set = page_sets.KeyMobileSitesPageSet
@test.Disabled('android', 'mac') # crbug.com/350692, crbug.com/368767 @test.Disabled('android', 'mac') # crbug.com/350692, crbug.com/368767
class SmoothnessToughAnimationCases(test.Test): class SmoothnessToughAnimationCases(test.Test):
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/tough_animation_cases.py' page_set = page_sets.ToughAnimationCasesPageSet
class SmoothnessKeySilkCases(test.Test): class SmoothnessKeySilkCases(test.Test):
...@@ -52,7 +54,7 @@ class SmoothnessKeySilkCases(test.Test): ...@@ -52,7 +54,7 @@ class SmoothnessKeySilkCases(test.Test):
rasterization rasterization
""" """
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/key_silk_cases.py' page_set = page_sets.KeySilkCasesPageSet
class SmoothnessFastPathKeySilkCases(test.Test): class SmoothnessFastPathKeySilkCases(test.Test):
...@@ -61,7 +63,7 @@ class SmoothnessFastPathKeySilkCases(test.Test): ...@@ -61,7 +63,7 @@ class SmoothnessFastPathKeySilkCases(test.Test):
""" """
tag = 'fast_path' tag = 'fast_path'
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/key_silk_cases.py' page_set = page_sets.KeySilkCasesPageSet
def CustomizeBrowserOptions(self, options): def CustomizeBrowserOptions(self, options):
silk_flags.CustomizeBrowserOptionsForFastPath(options) silk_flags.CustomizeBrowserOptionsForFastPath(options)
...@@ -72,7 +74,7 @@ class SmoothnessGpuRasterizationTop25(test.Test): ...@@ -72,7 +74,7 @@ class SmoothnessGpuRasterizationTop25(test.Test):
""" """
tag = 'gpu_rasterization' tag = 'gpu_rasterization'
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/top_25.py' page_set = page_sets.Top25PageSet
def CustomizeBrowserOptions(self, options): def CustomizeBrowserOptions(self, options):
silk_flags.CustomizeBrowserOptionsForGpuRasterization(options) silk_flags.CustomizeBrowserOptionsForGpuRasterization(options)
...@@ -84,7 +86,7 @@ class SmoothnessGpuRasterizationKeyMobileSites(test.Test): ...@@ -84,7 +86,7 @@ class SmoothnessGpuRasterizationKeyMobileSites(test.Test):
""" """
tag = 'gpu_rasterization' tag = 'gpu_rasterization'
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/key_mobile_sites.py' page_set = page_sets.KeyMobileSitesPageSet
def CustomizeBrowserOptions(self, options): def CustomizeBrowserOptions(self, options):
silk_flags.CustomizeBrowserOptionsForGpuRasterization(options) silk_flags.CustomizeBrowserOptionsForGpuRasterization(options)
...@@ -94,7 +96,7 @@ class SmoothnessGpuRasterizationKeySilkCases(test.Test): ...@@ -94,7 +96,7 @@ class SmoothnessGpuRasterizationKeySilkCases(test.Test):
""" """
tag = 'gpu_rasterization' tag = 'gpu_rasterization'
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/key_silk_cases.py' page_set = page_sets.KeySilkCasesPageSet
def CustomizeBrowserOptions(self, options): def CustomizeBrowserOptions(self, options):
silk_flags.CustomizeBrowserOptionsForGpuRasterization(options) silk_flags.CustomizeBrowserOptionsForGpuRasterization(options)
...@@ -106,7 +108,7 @@ class SmoothnessFastPathGpuRasterizationKeySilkCases( ...@@ -106,7 +108,7 @@ class SmoothnessFastPathGpuRasterizationKeySilkCases(
""" """
tag = 'fast_path_gpu_rasterization' tag = 'fast_path_gpu_rasterization'
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/key_silk_cases.py' page_set = page_sets.KeySilkCasesPageSet
def CustomizeBrowserOptions(self, options): def CustomizeBrowserOptions(self, options):
super(SmoothnessFastPathGpuRasterizationKeySilkCases, self). \ super(SmoothnessFastPathGpuRasterizationKeySilkCases, self). \
CustomizeBrowserOptions(options) CustomizeBrowserOptions(options)
...@@ -119,7 +121,7 @@ class SmoothnessToughPinchZoomCases(test.Test): ...@@ -119,7 +121,7 @@ class SmoothnessToughPinchZoomCases(test.Test):
cases cases
""" """
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/tough_pinch_zoom_cases.py' page_set = page_sets.ToughPinchZoomCasesPageSet
@test.Disabled # crbug.com/370725 @test.Disabled # crbug.com/370725
...@@ -127,7 +129,7 @@ class SmoothnessPolymer(test.Test): ...@@ -127,7 +129,7 @@ class SmoothnessPolymer(test.Test):
"""Measures rendering statistics for Polymer cases. """Measures rendering statistics for Polymer cases.
""" """
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/polymer.py' page_set = page_sets.PolymerPageSet
@test.Disabled # crbug.com/370725 @test.Disabled # crbug.com/370725
...@@ -137,7 +139,7 @@ class SmoothnessFastPathPolymer(test.Test): ...@@ -137,7 +139,7 @@ class SmoothnessFastPathPolymer(test.Test):
""" """
tag = 'fast_path' tag = 'fast_path'
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/polymer.py' page_set = page_sets.PolymerPageSet
def CustomizeBrowserOptions(self, options): def CustomizeBrowserOptions(self, options):
silk_flags.CustomizeBrowserOptionsForFastPath(options) silk_flags.CustomizeBrowserOptionsForFastPath(options)
...@@ -148,7 +150,7 @@ class SmoothnessGpuRasterizationPolymer(test.Test): ...@@ -148,7 +150,7 @@ class SmoothnessGpuRasterizationPolymer(test.Test):
""" """
tag = 'gpu_rasterization' tag = 'gpu_rasterization'
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/polymer.py' page_set = page_sets.PolymerPageSet
def CustomizeBrowserOptions(self, options): def CustomizeBrowserOptions(self, options):
silk_flags.CustomizeBrowserOptionsForGpuRasterization(options) silk_flags.CustomizeBrowserOptionsForGpuRasterization(options)
...@@ -161,7 +163,7 @@ class SmoothnessFastPathGpuRasterizationPolymer( ...@@ -161,7 +163,7 @@ class SmoothnessFastPathGpuRasterizationPolymer(
""" """
tag = 'fast_path_gpu_rasterization' tag = 'fast_path_gpu_rasterization'
test = smoothness.Smoothness test = smoothness.Smoothness
page_set = 'page_sets/polymer.py' page_set = page_sets.PolymerPageSet
def CustomizeBrowserOptions(self, options): def CustomizeBrowserOptions(self, options):
super(SmoothnessFastPathGpuRasterizationPolymer, self). \ super(SmoothnessFastPathGpuRasterizationPolymer, self). \
CustomizeBrowserOptions(options) CustomizeBrowserOptions(options)
......
# Copyright 2012 The Chromium Authors. All rights reserved. # Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import inspect
import os
import sys
from telemetry.core import discover
from telemetry.page import page_set
# Import all submodules' PageSet classes.
start_dir = os.path.dirname(os.path.abspath(__file__))
top_level_dir = os.path.dirname(start_dir)
base_class = page_set.PageSet
for cls in discover.DiscoverClasses(
start_dir, top_level_dir, base_class).values():
setattr(sys.modules[__name__], cls.__name__, cls)
...@@ -11,6 +11,8 @@ class BlankPage(page_module.Page): ...@@ -11,6 +11,8 @@ class BlankPage(page_module.Page):
class BlankPageSet(page_set_module.PageSet): class BlankPageSet(page_set_module.PageSet):
"""A single blank page."""
def __init__(self): def __init__(self):
super(BlankPageSet, self).__init__(description='A single blank page.') super(BlankPageSet, self).__init__()
self.AddPage(BlankPage('file://blank_page/blank_page.html', self)) self.AddPage(BlankPage('file://blank_page/blank_page.html', self))
...@@ -10,4 +10,6 @@ from telemetry.unittest import page_set_smoke_test ...@@ -10,4 +10,6 @@ from telemetry.unittest import page_set_smoke_test
class PageSetUnitTest(page_set_smoke_test.PageSetSmokeTest): class PageSetUnitTest(page_set_smoke_test.PageSetSmokeTest):
def testSmoke(self): def testSmoke(self):
self.RunSmokeTest(os.path.dirname(__file__)) page_sets_dir = os.path.dirname(os.path.realpath(__file__))
top_level_dir = os.path.dirname(page_sets_dir)
self.RunSmokeTest(page_sets_dir, top_level_dir)
...@@ -17,9 +17,10 @@ class ServiceWorkerPage(page.Page): ...@@ -17,9 +17,10 @@ class ServiceWorkerPage(page.Page):
class ServiceWorkerPageSet(page_set.PageSet): class ServiceWorkerPageSet(page_set.PageSet):
"""ServiceWorker performance tests"""
def __init__(self): def __init__(self):
super(ServiceWorkerPageSet, self).__init__( super(ServiceWorkerPageSet, self).__init__(
description='ServiceWorker performance tests',
archive_data_file=archive_data_file_path, archive_data_file=archive_data_file_path,
make_javascript_deterministic=False) make_javascript_deterministic=False)
......
...@@ -87,9 +87,10 @@ class Facebook(SimpleScrollPage): ...@@ -87,9 +87,10 @@ class Facebook(SimpleScrollPage):
class Top10PageSet(page_set_module.PageSet): class Top10PageSet(page_set_module.PageSet):
"""10 Pages chosen from Alexa top sites"""
def __init__(self): def __init__(self):
super(Top10PageSet, self).__init__( super(Top10PageSet, self).__init__(
description='10 Pages chosen from Alexa top sites',
archive_data_file='data/top_10.json', archive_data_file='data/top_10.json',
credentials_path='data/credentials.json', credentials_path='data/credentials.json',
user_agent_type='desktop') user_agent_type='desktop')
......
# Copyright 2013 The Chromium Authors. All rights reserved. # Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import json import json
import logging import logging
import os import os
...@@ -13,10 +14,10 @@ import time ...@@ -13,10 +14,10 @@ import time
import urllib2 import urllib2
import zipfile import zipfile
from telemetry.core import util
from telemetry.page import page_set
from telemetry.page import profile_creator from telemetry.page import profile_creator
import page_sets
def _ExternalExtensionsPath(): def _ExternalExtensionsPath():
"""Returns the OS-dependent path at which to install the extension deployment """Returns the OS-dependent path at which to install the extension deployment
...@@ -84,8 +85,7 @@ class ExtensionsProfileCreator(profile_creator.ProfileCreator): ...@@ -84,8 +85,7 @@ class ExtensionsProfileCreator(profile_creator.ProfileCreator):
def __init__(self): def __init__(self):
super(ExtensionsProfileCreator, self).__init__() super(ExtensionsProfileCreator, self).__init__()
typical_25 = os.path.join(util.GetBaseDir(), 'page_sets', 'typical_25.py') self._page_set = page_sets.Typical25()
self._page_set = page_set.PageSet.FromFile(typical_25)
# Directory into which the output profile is written. # Directory into which the output profile is written.
self._output_profile_path = None self._output_profile_path = None
......
# Copyright 2013 The Chromium Authors. All rights reserved. # Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from telemetry.page import extensions_profile_creator
from profile_creators import extensions_profile_creator
class ManyExtensionsProfileCreator( class ManyExtensionsProfileCreator(
......
...@@ -2,12 +2,10 @@ ...@@ -2,12 +2,10 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import os
from telemetry.core import util
from telemetry.page import page_set
from telemetry.page import profile_creator from telemetry.page import profile_creator
import page_sets
class SmallProfileCreator(profile_creator.ProfileCreator): class SmallProfileCreator(profile_creator.ProfileCreator):
""" """
...@@ -16,8 +14,7 @@ class SmallProfileCreator(profile_creator.ProfileCreator): ...@@ -16,8 +14,7 @@ class SmallProfileCreator(profile_creator.ProfileCreator):
def __init__(self): def __init__(self):
super(SmallProfileCreator, self).__init__() super(SmallProfileCreator, self).__init__()
typical_25 = os.path.join(util.GetBaseDir(), 'page_sets', 'typical_25.py') self._page_set = page_sets.Typical25()
self._page_set = page_set.PageSet.FromFile(typical_25)
# Open all links in the same tab save for the last _NUM_TABS links which # Open all links in the same tab save for the last _NUM_TABS links which
# are each opened in a new tab. # are each opened in a new tab.
......
# Copyright 2013 The Chromium Authors. All rights reserved. # Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from telemetry.page import extensions_profile_creator
from profile_creators import extensions_profile_creator
class ThemeProfileCreator(extensions_profile_creator.ExtensionsProfileCreator): class ThemeProfileCreator(extensions_profile_creator.ExtensionsProfileCreator):
......
...@@ -133,15 +133,3 @@ def IsPageSetFile(file_path): ...@@ -133,15 +133,3 @@ def IsPageSetFile(file_path):
return False return False
module = util.GetPythonPageSetModule(file_path) module = util.GetPythonPageSetModule(file_path)
return bool(DiscoverClassesInModule(module, page_set.PageSet)) return bool(DiscoverClassesInModule(module, page_set.PageSet))
def GetAllPageSetFilenames(dir_path):
results = []
for sub_path, _, filenames in os.walk(dir_path):
for f in filenames:
if f.startswith('.'):
continue
filename = os.path.join(sub_path, f)
if IsPageSetFile(filename):
results.append(filename)
return results
...@@ -15,7 +15,7 @@ class PageSetError(Exception): ...@@ -15,7 +15,7 @@ class PageSetError(Exception):
class PageSet(object): class PageSet(object):
def __init__(self, file_path=None, description='', archive_data_file='', def __init__(self, file_path=None, archive_data_file='',
credentials_path=None, user_agent_type=None, credentials_path=None, user_agent_type=None,
make_javascript_deterministic=True, startup_url='', make_javascript_deterministic=True, startup_url='',
serving_dirs=None): serving_dirs=None):
...@@ -29,7 +29,6 @@ class PageSet(object): ...@@ -29,7 +29,6 @@ class PageSet(object):
self.file_path = file_path self.file_path = file_path
# These attributes can be set dynamically by the page set. # These attributes can be set dynamically by the page set.
self.description = description
self.archive_data_file = archive_data_file self.archive_data_file = archive_data_file
self.credentials_path = credentials_path self.credentials_path = credentials_path
self.user_agent_type = user_agent_type self.user_agent_type = user_agent_type
...@@ -46,6 +45,17 @@ class PageSet(object): ...@@ -46,6 +45,17 @@ class PageSet(object):
else: else:
self.serving_dirs.add(os.path.realpath(os.path.join(self.base_dir, sd))) self.serving_dirs.add(os.path.realpath(os.path.join(self.base_dir, sd)))
@classmethod
def Name(cls):
return cls.__module__.split('.')[-1]
@classmethod
def Description(cls):
if cls.__doc__:
return cls.__doc__.splitlines()[0]
else:
return ''
def AddPage(self, page): def AddPage(self, page):
assert page.page_set is self assert page.page_set is self
self.pages.append(page) self.pages.append(page)
......
...@@ -45,7 +45,7 @@ class TestPageSet(unittest.TestCase): ...@@ -45,7 +45,7 @@ class TestPageSet(unittest.TestCase):
test_pps_dir = os.path.join(util.GetUnittestDataDir(), 'test_page_set.py') test_pps_dir = os.path.join(util.GetUnittestDataDir(), 'test_page_set.py')
pps = page_set.PageSet.FromFile(test_pps_dir) pps = page_set.PageSet.FromFile(test_pps_dir)
self.assertEqual('TestPageSet', pps.__class__.__name__) self.assertEqual('TestPageSet', pps.__class__.__name__)
self.assertEqual('A pageset for testing purpose', pps.description) self.assertEqual('A pageset for testing purpose', pps.Description())
self.assertEqual('data/test.json', pps.archive_data_file) self.assertEqual('data/test.json', pps.archive_data_file)
self.assertEqual('data/credential', pps.credentials_path) self.assertEqual('data/credential', pps.credentials_path)
self.assertEqual('desktop', pps.user_agent_type) self.assertEqual('desktop', pps.user_agent_type)
......
...@@ -37,14 +37,12 @@ class Test(command_line.Command): ...@@ -37,14 +37,12 @@ class Test(command_line.Command):
name = cls.__module__.split('.')[-1] name = cls.__module__.split('.')[-1]
if hasattr(cls, 'tag'): if hasattr(cls, 'tag'):
name += '.' + cls.tag name += '.' + cls.tag
page_set_name = None if hasattr(cls, 'page_set'):
if hasattr(cls, 'page_set') and isinstance(cls.page_set, page_set.PageSet): if isinstance(cls.page_set, basestring):
page_set_name = os.path.basename( # TODO(dtu): Remove this code path after crbug.com/362293.
os.path.splitext(cls.page_set.file_path)[0]) name += '.' + os.path.basename(os.path.splitext(cls.page_set)[0])
elif hasattr(cls, 'page_set') and isinstance(cls.page_set, str): else:
page_set_name = os.path.basename(os.path.splitext(cls.page_set)[0]) name += '.' + cls.page_set.Name()
if page_set_name:
name += '.' + page_set_name
return name return name
@classmethod @classmethod
...@@ -169,6 +167,18 @@ class Test(command_line.Command): ...@@ -169,6 +167,18 @@ class Test(command_line.Command):
raise TypeError('"%s" is not a PageTest.' % cls.test.__name__) raise TypeError('"%s" is not a PageTest.' % cls.test.__name__)
return cls.test return cls.test
@classmethod
def PageSetClass(cls):
"""Get the PageSet for this Test.
If the Test has no PageSet, raises NotImplementedError.
"""
if not hasattr(cls, 'page_set'):
raise NotImplementedError('This test has no "page_set" attribute.')
if not issubclass(cls.page_set, page_set.PageSet):
raise TypeError('"%s" is not a PageSet.' % cls.page_set.__name__)
return cls.page_set
@classmethod @classmethod
def CreatePageSet(cls, options): # pylint: disable=W0613 def CreatePageSet(cls, options): # pylint: disable=W0613
"""Get the page set this test will run on. """Get the page set this test will run on.
...@@ -178,15 +188,12 @@ class Test(command_line.Command): ...@@ -178,15 +188,12 @@ class Test(command_line.Command):
""" """
if not hasattr(cls, 'page_set'): if not hasattr(cls, 'page_set'):
raise NotImplementedError('This test has no "page_set" attribute.') raise NotImplementedError('This test has no "page_set" attribute.')
if isinstance(cls.page_set, basestring):
if isinstance(cls.page_set, str): # TODO(dtu): Remove this code path after crbug.com/362293.
return page_set.PageSet.FromFile( return page_set.PageSet.FromFile(
file_path=os.path.join(util.GetBaseDir(), cls.page_set)) file_path=os.path.join(util.GetBaseDir(), cls.page_set))
elif isinstance(cls.page_set, page_set.PageSet):
return cls.page_set
else: else:
raise TypeError('The page_set field of %s has unsupported type.' % return cls.PageSetClass()()
cls.Name)
@classmethod @classmethod
def CreateExpectations(cls, ps): # pylint: disable=W0613 def CreateExpectations(cls, ps): # pylint: disable=W0613
......
...@@ -66,10 +66,6 @@ class PageSetSmokeTest(unittest.TestCase): ...@@ -66,10 +66,6 @@ class PageSetSmokeTest(unittest.TestCase):
isinstance(page_set.file_path, str), isinstance(page_set.file_path, str),
msg='page_set %\'s file_path must have type string') msg='page_set %\'s file_path must have type string')
self.assertTrue(
isinstance(page_set.description, str),
msg='page_set\'s description must have type string')
self.assertTrue( self.assertTrue(
isinstance(page_set.archive_data_file, str), isinstance(page_set.archive_data_file, str),
msg='page_set\'s archive_data_file path must have type string') msg='page_set\'s archive_data_file path must have type string')
...@@ -99,16 +95,16 @@ class PageSetSmokeTest(unittest.TestCase): ...@@ -99,16 +95,16 @@ class PageSetSmokeTest(unittest.TestCase):
isinstance(page.name, str), isinstance(page.name, str),
msg='page %s \'s name field must have type string' % page.display_name) msg='page %s \'s name field must have type string' % page.display_name)
def RunSmokeTest(self, page_sets_dir): def RunSmokeTest(self, page_sets_dir, top_level_dir):
"""Run smoke test on all page sets in page_sets_dir. """Run smoke test on all page sets in page_sets_dir.
Subclass of PageSetSmokeTest is supposed to call this in some test Subclass of PageSetSmokeTest is supposed to call this in some test
method to run smoke test. method to run smoke test.
""" """
page_sets = discover.GetAllPageSetFilenames(page_sets_dir) page_sets = discover.DiscoverClasses(page_sets_dir, top_level_dir,
page_set_module.PageSet).values()
for page_set_path in page_sets: for page_set_class in page_sets:
page_set = page_set_module.PageSet.FromFile(page_set_path) page_set = page_set_class()
logging.info('Testing %s', page_set.file_path) logging.info('Testing %s', page_set.file_path)
self.CheckArchive(page_set) self.CheckArchive(page_set)
self.CheckCredentials(page_set) self.CheckCredentials(page_set)
......
...@@ -12,9 +12,10 @@ class InternalPage(Page): ...@@ -12,9 +12,10 @@ class InternalPage(Page):
super(InternalPage, self).__init__('file://bar.html', page_set=ps) super(InternalPage, self).__init__('file://bar.html', page_set=ps)
class TestPageSet(PageSet): class TestPageSet(PageSet):
"""A pageset for testing purpose"""
def __init__(self): def __init__(self):
super(TestPageSet, self).__init__( super(TestPageSet, self).__init__(
description='A pageset for testing purpose',
archive_data_file='data/test.json', archive_data_file='data/test.json',
credentials_path='data/credential', credentials_path='data/credential',
user_agent_type='desktop') user_agent_type='desktop')
......
...@@ -7,7 +7,6 @@ from telemetry.page.page_set import PageSet ...@@ -7,7 +7,6 @@ from telemetry.page.page_set import PageSet
class TestSimpleOnePageSet(PageSet): class TestSimpleOnePageSet(PageSet):
def __init__(self): def __init__(self):
super(TestSimpleOnePageSet, self).__init__( super(TestSimpleOnePageSet, self).__init__(
description='A pageset for testing purpose',
archive_data_file='data/test.json', archive_data_file='data/test.json',
credentials_path='data/credential', credentials_path='data/credential',
user_agent_type='desktop') user_agent_type='desktop')
...@@ -7,7 +7,6 @@ from telemetry.page.page_set import PageSet ...@@ -7,7 +7,6 @@ from telemetry.page.page_set import PageSet
class TestSimpleTwoPageSet(PageSet): class TestSimpleTwoPageSet(PageSet):
def __init__(self): def __init__(self):
super(TestSimpleTwoPageSet, self).__init__( super(TestSimpleTwoPageSet, self).__init__(
description='A pageset for testing purpose',
archive_data_file='data/test.json', archive_data_file='data/test.json',
credentials_path='data/credential', credentials_path='data/credential',
user_agent_type='desktop') user_agent_type='desktop')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment