Commit 2464c8bd authored by bustamante's avatar bustamante Committed by Commit bot

Fix broken chrome_proxy unit tests

testHTTPResponseTimelineRecorder was failing due to an occasional favicon
request which would occassional cause the test to fail.  To fix the issue
it will now filter out any favicon requests before validation.

testChromeProxyMetricForBlockOnce failed to due not being updated when
the BlockOnce case was changed.  I also renamed the metrics we store in the
test to be consistent with other cases.

Last item is adding myself to OWNERS for chrome_proxy tests.

BUG=452279,449979,455269

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

Cr-Commit-Position: refs/heads/master@{#367098}
parent 91ed691f
bengr@chromium.org
bolian@chromium.org
bustamante@chromium.org
kundaji@chromium.org
marq@chromium.org
megjablon@chromium.org
......
......@@ -20,6 +20,12 @@ class InspectorNetworkTabTest(tab_test_case.TabTestCase):
def __init__(self, *args):
super(InspectorNetworkTabTest, self).__init__(*args)
def _FilterFaviconEvents(self, events):
for event in events:
if 'favicon.ico' in event.args['response']['url']:
events.remove(event)
return events
def _NavigateAndGetHTTPResponseEvents(self, page):
network = inspector_network.InspectorNetwork(
self._tab._inspector_backend._websocket)
......@@ -29,8 +35,6 @@ class InspectorNetworkTabTest(tab_test_case.TabTestCase):
self.assertTrue(timeline_model)
return timeline_model.GetAllEventsOfName('HTTPResponse')
# crbug.com/449979, crbug.com/452279, crbug.com/455269, crbug.com/483212
@decorators.Disabled('mac', 'android', 'win', 'linux', 'chromeos')
def testHTTPResponseTimelineRecorder(self):
tests = {
'blank.html': InspectorNetworkTabTest.TestCase(responses_count=1),
......@@ -39,7 +43,8 @@ class InspectorNetworkTabTest(tab_test_case.TabTestCase):
responses_count=2, subresources=['image.png']),
}
for page, test in tests.iteritems():
events = self._NavigateAndGetHTTPResponseEvents(page)
events = self._FilterFaviconEvents(
self._NavigateAndGetHTTPResponseEvents(page))
self.assertEqual(test.responses_count, len(events))
# Verify required event fields
......
......@@ -417,7 +417,7 @@ class ChromeProxyMetric(network_metrics.NetworkMetric):
' test URLs. Expected: 2, Actual: ' + str(eligible_response_count))
results.AddValue(scalar.ScalarValue(results.current_page,
'BlockOnce_success', 'num_eligible_response', 2))
'eligible_responses', 'count', 2))
def AddResultsForSafebrowsingOn(self, tab, results):
......
......@@ -22,6 +22,16 @@ EVENT_HTML_DIRECT = network_unittest.NetworkMetricTest.MakeNetworkTimelineEvent(
},
body=network_unittest.HTML_BODY)
# A BlockOnce response not via proxy.
EVENT_HTML_BLOCKONCE = (
network_unittest.NetworkMetricTest.MakeNetworkTimelineEvent(
url='http://check.googlezip.net/blocksingle/',
response_headers={
'Content-Type': 'text/html',
'Content-Length': str(len(network_unittest.HTML_BODY)),
},
body=network_unittest.HTML_BODY))
# An HTML via proxy.
EVENT_HTML_PROXY_VIA = (
network_unittest.NetworkMetricTest.MakeNetworkTimelineEvent(
......@@ -264,14 +274,15 @@ class ChromeProxyMetricTest(unittest.TestCase):
def testChromeProxyMetricForBlockOnce(self):
metric = metrics.ChromeProxyMetric()
metric.SetEvents([EVENT_HTML_DIRECT,
metric.SetEvents([EVENT_HTML_BLOCKONCE,
EVENT_HTML_BLOCKONCE,
EVENT_IMAGE_PROXY_VIA])
results = test_page_test_results.TestPageTestResults(self)
metric.AddResultsForBlockOnce(None, results)
results.AssertHasPageSpecificScalarValue('eligible_responses', 'count', 2)
results.AssertHasPageSpecificScalarValue('bypass', 'count', 1)
metric.SetEvents([EVENT_HTML_DIRECT,
metric.SetEvents([EVENT_HTML_BLOCKONCE,
EVENT_HTML_BLOCKONCE,
EVENT_IMAGE_DIRECT])
exception_occurred = False
try:
......
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