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

Side by Side Diff: tools/chrome_proxy/webdriver/lite_page.py

Issue 2726423003: Integration tests for WebLite to Lo-Fi fallback (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « tools/chrome_proxy/webdriver/common.py ('k') | tools/chrome_proxy/webdriver/lofi.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2017 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.
4
5 import common
6 from common import TestDriver
7 from common import IntegrationTest
8
9
10 class LitePage(IntegrationTest):
11
12 # Checks that a Lite Page is served and that the ignore_preview_blacklist
13 # experiment is being used.
14 def testLitePage(self):
15 with TestDriver() as test_driver:
16 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
17 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on')
18 test_driver.AddChromeArg('--enable-data-reduction-proxy-lite-page')
19
20 test_driver.LoadURL('http://check.googlezip.net/test.html')
21
22 lite_page_responses = 0
23 for response in test_driver.GetHTTPResponses():
24 # Skip CSI requests when validating Lite Page headers. CSI requests
25 # aren't expected to have LoFi headers.
26 if '/csi?' in response.url:
27 continue
28 if response.url.startswith('data:'):
29 continue
30 self.assertIn('exp=ignore_preview_blacklist',
31 response.request_headers['chrome-proxy'])
32 if (self.checkLitePageResponse(response)):
33 lite_page_responses = lite_page_responses + 1
34
35 # Verify that a Lite Page response for the main frame was seen.
36 self.assertEqual(1, lite_page_responses)
37
38 # Checks that Lo-Fi images are used when the user is in the
39 # DataCompressionProxyLitePageFallback field trial and a Lite Page is not
40 # served.
41 def testLitePageFallback(self):
42 with TestDriver() as test_driver:
43 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
44 test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=always-on')
tbansal1 2017/03/03 21:17:56 Can you add a comment that setting these two flags
megjablon 2017/03/03 22:05:03 Made it consistent with the test below.
45 test_driver.AddChromeArg('--enable-data-reduction-proxy-lite-page')
46
47 test_driver.LoadURL('http://check.googlezip.net/lite-page-fallback')
48
49 lite_page_requests = 0
50 lo_fi_responses = 0
51 for response in test_driver.GetHTTPResponses():
52 if not response.request_headers:
53 continue
54
55 cpat_request = response.request_headers['chrome-proxy-accept-transform']
56 if ('lite-page' in cpat_request):
57 lite_page_requests = lite_page_requests + 1
58 self.assertFalse(self.checkLitePageResponse(response))
59
60 if not response.url.endswith('png'):
61 continue
62
63 if (self.checkLoFiResponse(response, True)):
64 lo_fi_responses = lo_fi_responses + 1
65
66 # Verify that a Lite Page was requested and that the page fell back to
67 # Lo-Fi images.
68 self.assertEqual(1, lite_page_requests)
69 self.assertEqual(1, lo_fi_responses)
70
71 # Checks that Lo-Fi images are not used when the user is not in the
72 # DataCompressionProxyLitePageFallback field trial and a Lite Page is not
73 # served.
74 def testLitePageNoFallback(self):
75 with TestDriver() as test_driver:
76 test_driver.AddChromeArg('--enable-spdy-proxy-auth')
77 # Lite Pages must be enabled via the field trial because the Lite Page
78 # flag always falls back to Lo-Fi.
79 test_driver.AddChromeArg('--force-fieldtrials='
80 'DataCompressionProxyLoFi/Enabled_Preview')
81 test_driver.AddChromeArg('--force-fieldtrial-params='
82 'DataCompressionProxyLoFi.Enabled_Preview:'
83 'effective_connection_type/4G')
tbansal1 2017/03/03 21:17:56 I think it is safer to also force NQE to return EC
megjablon 2017/03/03 22:05:03 Done.
84
85 test_driver.LoadURL('http://check.googlezip.net/lite-page-fallback')
86
87 lite_page_requests = 0
88 for response in test_driver.GetHTTPResponses():
89 if not response.request_headers:
90 continue
91
92 if ('chrome-proxy-accept-transform' in response.request_headers):
93 cpat_request = response.request_headers[
94 'chrome-proxy-accept-transform']
95 if ('lite-page' in cpat_request):
96 lite_page_requests = lite_page_requests + 1
97 self.assertFalse(self.checkLitePageResponse(response))
98
99 if not response.url.endswith('png'):
100 continue
101
102 print response.url
tbansal1 2017/03/03 21:17:56 Why print?
megjablon 2017/03/03 22:05:03 Ah my bad, was using this when .png was getting li
103
104 self.checkLoFiResponse(response, False)
105
106 # Verify that a Lite Page was requested and that the page fell back to
107 # Lo-Fi images.
108 self.assertEqual(1, lite_page_requests)
109
110 if __name__ == '__main__':
111 IntegrationTest.RunAllTests()
OLDNEW
« no previous file with comments | « tools/chrome_proxy/webdriver/common.py ('k') | tools/chrome_proxy/webdriver/lofi.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698