Remove linux_chromium_gn_dbg from the chromium CQ.
[chromium-blink-merge.git] / tools / chrome_proxy / live_tests / chrome_proxy_measurements.py
blob96b5a4b4031a2420cfeba7af40cd435cfbf89f07
1 # Copyright 2015 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.
5 import logging
7 import chrome_proxy_metrics as metrics
8 from common import chrome_proxy_measurements as measurements
9 from telemetry.core import exceptions
10 from telemetry.page import page_test
12 class ChromeProxyLatencyBase(page_test.PageTest):
13 """Chrome latency measurement."""
15 def __init__(self, *args, **kwargs):
16 super(ChromeProxyLatencyBase, self).__init__(*args, **kwargs)
17 self._metrics = metrics.ChromeProxyMetric()
19 def WillNavigateToPage(self, page, tab):
20 tab.ClearCache(force=True)
21 self._metrics.Start(page, tab)
23 def ValidateAndMeasurePage(self, page, tab, results):
24 # Wait for the load event.
25 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300)
26 self._metrics.Stop(page, tab)
27 self._metrics.AddResultsForLatency(tab, results)
30 class ChromeProxyLatency(ChromeProxyLatencyBase):
31 """Chrome proxy latency measurement."""
33 def __init__(self, *args, **kwargs):
34 super(ChromeProxyLatency, self).__init__(*args, **kwargs)
36 def CustomizeBrowserOptions(self, options):
37 # NOTE: When using the Data Saver API, the first few requests for this test
38 # could go over direct instead of through the Data Reduction Proxy if the
39 # Data Saver API fetch is slow to finish. This test can't just use
40 # measurements.WaitForViaHeader(tab) since that would affect the results of
41 # the latency measurement, e.g. Chrome would have a hot proxy connection.
42 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
45 class ChromeProxyLatencyDirect(ChromeProxyLatencyBase):
46 """Direct connection latency measurement."""
48 def __init__(self, *args, **kwargs):
49 super(ChromeProxyLatencyDirect, self).__init__(*args, **kwargs)
52 class ChromeProxyDataSavingBase(page_test.PageTest):
53 """Chrome data saving measurement."""
54 def __init__(self, *args, **kwargs):
55 super(ChromeProxyDataSavingBase, self).__init__(*args, **kwargs)
56 self._metrics = metrics.ChromeProxyMetric()
58 def WillNavigateToPage(self, page, tab):
59 tab.ClearCache(force=True)
60 self._metrics.Start(page, tab)
62 def ValidateAndMeasurePage(self, page, tab, results):
63 # Wait for the load event.
64 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300)
65 self._metrics.Stop(page, tab)
66 self._metrics.AddResultsForDataSaving(tab, results)
69 class ChromeProxyDataSaving(ChromeProxyDataSavingBase):
70 """Chrome proxy data saving measurement."""
72 def __init__(self, *args, **kwargs):
73 super(ChromeProxyDataSaving, self).__init__(*args, **kwargs)
75 def CustomizeBrowserOptions(self, options):
76 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
78 def WillNavigateToPage(self, page, tab):
79 measurements.WaitForViaHeader(tab)
80 super(ChromeProxyDataSaving, self).WillNavigateToPage(page, tab)
83 class ChromeProxyDataSavingDirect(ChromeProxyDataSavingBase):
84 """Direct connection data saving measurement."""
86 def __init__(self, *args, **kwargs):
87 super(ChromeProxyDataSavingDirect, self).__init__(*args, **kwargs)