| OLD | NEW |
| (Empty) |
| 1 # Copyright 2016 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 sys | |
| 6 import time | |
| 7 | |
| 8 import common | |
| 9 from common import TestDriver | |
| 10 from common import IntegrationTest | |
| 11 | |
| 12 | |
| 13 class Examples(IntegrationTest): | |
| 14 | |
| 15 # Simple example integration test. | |
| 16 def testCheckPageWithProxy(self): | |
| 17 with TestDriver() as t: | |
| 18 t.AddChromeArg('--enable-spdy-proxy-auth') | |
| 19 t.LoadURL('http://check.googlezip.net/test.html') | |
| 20 print 'Document Title: ', t.ExecuteJavascriptStatement('document.title', | |
| 21 timeout=1) | |
| 22 responses = t.GetHTTPResponses() | |
| 23 for response in responses: | |
| 24 print "URL: %s, ViaHeader: %s, XHR: %s" % (response.url, | |
| 25 response.ResponseHasViaHeader(), response.WasXHR()) | |
| 26 self.assertHasChromeProxyViaHeader(response) | |
| 27 | |
| 28 # Simple example integration test. | |
| 29 def testCheckPageWithoutProxy(self): | |
| 30 with TestDriver() as t: | |
| 31 t.AddChromeArg('--enable-spdy-proxy-auth') | |
| 32 t.LoadURL('https://check.googlezip.net/test.html') | |
| 33 print 'Document Title: ', t.ExecuteJavascriptStatement('document.title', | |
| 34 timeout=1) | |
| 35 responses = t.GetHTTPResponses() | |
| 36 for response in responses: | |
| 37 print "URL: %s, ViaHeader: %s, XHR: %s" % (response.url, | |
| 38 response.ResponseHasViaHeader(), response.WasXHR()) | |
| 39 self.assertNotHasChromeProxyViaHeader(response) | |
| 40 | |
| 41 # Show how to get a histogram. | |
| 42 def testPingbackHistogram(self): | |
| 43 with TestDriver() as t: | |
| 44 t.AddChromeArg('--enable-spdy-proxy-auth') | |
| 45 t.LoadURL('http://check.googlezip.net/test.html') | |
| 46 t.LoadURL('http://check.googlezip.net/test.html') | |
| 47 print t.GetHistogram('DataReductionProxy.Pingback.Attempted') | |
| 48 | |
| 49 # Show how to use WaitForJavascriptExpression | |
| 50 def testHTML5(self): | |
| 51 with TestDriver() as t: | |
| 52 t.AddChromeArg('--enable-spdy-proxy-auth') | |
| 53 t.LoadURL('http://html5test.com/') | |
| 54 t.WaitForJavascriptExpression( | |
| 55 'document.getElementsByClassName("pointsPanel")', 15) | |
| 56 | |
| 57 # Show how to use SetNetworkConnection | |
| 58 def testSetNetworkConnection(self): | |
| 59 with TestDriver(control_network_connection=True) as t: | |
| 60 t.SetNetworkConnection("2G") | |
| 61 t.LoadURL('https://www.google.com') | |
| 62 | |
| 63 if __name__ == '__main__': | |
| 64 IntegrationTest.RunAllTests() | |
| OLD | NEW |