Skip to content

Commit

Permalink
added tests for chrome proxy video transcoder
Browse files Browse the repository at this point in the history
BUG=

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

Cr-Commit-Position: refs/heads/master@{#335987}
  • Loading branch information
harringtond authored and Commit bot committed Jun 24, 2015
1 parent 0ca2573 commit cd1a256
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 2 deletions.
25 changes: 25 additions & 0 deletions tools/chrome_proxy/integration_tests/chrome_proxy_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,28 @@ class ChromeProxyVideoCompare(benchmark.Benchmark):
@classmethod
def Name(cls):
return 'chrome_proxy_benchmark.video.compare'

@benchmark.Enabled('desktop')
class ChromeProxyVideoFrames(benchmark.Benchmark):
"""Check for video frames similar to original video."""

tag = 'video'
test = measurements.ChromeProxyInstrumentedVideoValidation
page_set = pagesets.VideoFramePageSet

@classmethod
def Name(cls):
return 'chrome_proxy_benchmark.video.frames'

@benchmark.Enabled('desktop')
class ChromeProxyVideoAudio(benchmark.Benchmark):
"""Check that audio is similar to original video."""

tag = 'video'
test = measurements.ChromeProxyInstrumentedVideoValidation
page_set = pagesets.VideoAudioPageSet

@classmethod
def Name(cls):
return 'chrome_proxy_benchmark.video.audio'

Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@ def __init__(self):
def CustomizeBrowserOptionsForSinglePage(self, page, options):
if page.use_chrome_proxy:
options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
options.AppendExtraBrowserArgs('--data-reduction-proxy-experiment=video')

def DidNavigateToPage(self, page, tab):
self._currMetrics = metrics.ChromeProxyVideoMetric(tab)
Expand Down Expand Up @@ -479,3 +478,23 @@ def err(s):
if pxocl != dcl:
err('Mismatch for content length (proxied=%s direct=%s): %s' %
(str(pxocl), str(dcl), page.url))

class ChromeProxyInstrumentedVideoValidation(page_test.PageTest):
"""Tests a specially instrumented page for correct video transcoding."""

def __init__(self):
super(ChromeProxyInstrumentedVideoValidation, self).__init__(
needs_browser_restart_after_each_page=True,
clear_cache_before_each_run=True)
self._metrics = metrics.ChromeProxyInstrumentedVideoMetric()

def CustomizeBrowserOptions(self, options):
options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')

def WillNavigateToPage(self, page, tab):
tab.ClearCache(force=True)
self._metrics.Start(page, tab)

def ValidateAndMeasurePage(self, page, tab, results):
self._metrics.Stop(page, tab)
self._metrics.AddResults(tab, results)
26 changes: 25 additions & 1 deletion tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from common.chrome_proxy_metrics import ChromeProxyMetricException
from telemetry.page import page_test
from telemetry.value import scalar

from metrics import Metric

class ChromeProxyMetric(network_metrics.NetworkMetric):
"""A Chrome proxy timeline metric."""
Expand Down Expand Up @@ -705,6 +705,30 @@ def err(s):
k = "%s_%s" % (k, kind)
results.AddValue(scalar.ScalarValue(results.current_page, k, "", v))

class ChromeProxyInstrumentedVideoMetric(Metric):
"""Metric for pages instrumented to evaluate video transcoding."""
def __init__(self):
super(ChromeProxyInstrumentedVideoMetric, self).__init__()

def Stop(self, page, tab):
waitTime = tab.EvaluateJavaScript('test.waitTime')
tab.WaitForJavaScriptExpression('test.metrics.complete', waitTime)
super(ChromeProxyInstrumentedVideoMetric, self).Stop(page, tab)

def AddResults(self, tab, results):
metrics = tab.EvaluateJavaScript('test.metrics')
for (k,v) in metrics.iteritems():
results.AddValue(scalar.ScalarValue(results.current_page, k, '', v))
try:
complete = metrics['complete']
failed = metrics['failed']
if not complete:
raise ChromeProxyMetricException, 'Test not complete'
if failed:
raise ChromeProxyMetricException, 'failed'
except KeyError:
raise ChromeProxyMetricException, 'No metrics found'

# Returns whether |url| is a block-once test URL. Data Reduction Proxy has been
# configured to always return block-once for these URLs.
def IsTestUrlForBlockOnce(url):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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 telemetry.page import page as page_module
from telemetry.page import page_set as page_set_module

class VideoFramePageSet(page_set_module.PageSet):
"""Chrome proxy video tests: verify frames of transcoded videos"""
def __init__(self):
super(VideoFramePageSet, self).__init__()
for url in [
'http://check.googlezip.net/cacheable/video/buck_bunny_640x360_24fps_video.html',
'http://check.googlezip.net/cacheable/video/buck_bunny_60fps_video.html',
]:
self.AddUserStory(page_module.Page(url, self))

class VideoAudioPageSet(page_set_module.PageSet):
"""Chrome proxy video tests: verify audio of transcoded videos"""
def __init__(self):
super(VideoAudioPageSet, self).__init__()
for url in [
'http://check.googlezip.net/cacheable/video/buck_bunny_640x360_24fps_audio.html',
]:
self.AddUserStory(page_module.Page(url, self))

0 comments on commit cd1a256

Please sign in to comment.