Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: tools/chrome_proxy/common/chrome_proxy_metrics_unittest.py

Issue 1098253004: Move top_20 tests to a separate suite (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use ChromeProxyValidation in common in integration_tests Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/chrome_proxy/common/chrome_proxy_metrics.py ('k') | tools/chrome_proxy/common/network_metrics.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/chrome_proxy/common/chrome_proxy_metrics_unittest.py
diff --git a/tools/chrome_proxy/common/chrome_proxy_metrics_unittest.py b/tools/chrome_proxy/common/chrome_proxy_metrics_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..35c9e1bfb91045554350488f119fac7089cd64f0
--- /dev/null
+++ b/tools/chrome_proxy/common/chrome_proxy_metrics_unittest.py
@@ -0,0 +1,44 @@
+# 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.
+
+import base64
+import unittest
+
+from common import chrome_proxy_metrics as metrics
+from common import network_metrics_unittest as network_unittest
+
+
+class ChromeProxyMetricTest(unittest.TestCase):
+
+ def testChromeProxyResponse(self):
+ # An https non-proxy response.
+ resp = metrics.ChromeProxyResponse(
+ network_unittest.NetworkMetricTest.MakeNetworkTimelineEvent(
+ url='https://test.url',
+ response_headers={
+ 'Content-Type': 'text/html',
+ 'Content-Length': str(len(network_unittest.HTML_BODY)),
+ 'Via': 'some other via',
+ },
+ body=network_unittest.HTML_BODY))
+ self.assertFalse(resp.ShouldHaveChromeProxyViaHeader())
+ self.assertFalse(resp.HasChromeProxyViaHeader())
+ self.assertTrue(resp.IsValidByViaHeader())
+
+ # A proxied JPEG image response
+ resp = metrics.ChromeProxyResponse(
+ network_unittest.NetworkMetricTest.MakeNetworkTimelineEvent(
+ url='http://test.image',
+ response_headers={
+ 'Content-Type': 'image/jpeg',
+ 'Content-Encoding': 'gzip',
+ 'Via': '1.1 ' + metrics.CHROME_PROXY_VIA_HEADER,
+ 'X-Original-Content-Length': str(network_unittest.IMAGE_OCL),
+ },
+ body=base64.b64encode(network_unittest.IMAGE_BODY),
+ base64_encoded_body=True))
+ self.assertTrue(resp.ShouldHaveChromeProxyViaHeader())
+ self.assertTrue(resp.HasChromeProxyViaHeader())
+ self.assertTrue(resp.IsValidByViaHeader())
+
« no previous file with comments | « tools/chrome_proxy/common/chrome_proxy_metrics.py ('k') | tools/chrome_proxy/common/network_metrics.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698