| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import sys | 5 import sys |
| 6 import time | 6 import time |
| 7 import unittest | |
| 8 | 7 |
| 9 import common | 8 import common |
| 10 from common import TestDriver | 9 from common import TestDriver |
| 10 from common import IntegrationTest |
| 11 | 11 |
| 12 | 12 |
| 13 class SimpleSmoke(unittest.TestCase): | 13 class SimpleSmoke(IntegrationTest): |
| 14 | 14 |
| 15 # Simple example integration test. | 15 # Simple example integration test. |
| 16 def testCheckPageWithProxy(self): | 16 def testCheckPageWithProxy(self): |
| 17 with TestDriver() as t: | 17 with TestDriver() as t: |
| 18 t.AddChromeArg('--enable-spdy-proxy-auth') | 18 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 19 t.LoadURL('http://check.googlezip.net/test.html') | 19 t.LoadURL('http://check.googlezip.net/test.html') |
| 20 print 'Document Title: ', t.ExecuteJavascriptStatement('document.title', | 20 print 'Document Title: ', t.ExecuteJavascriptStatement('document.title', |
| 21 timeout=1) | 21 timeout=1) |
| 22 responses = t.GetHTTPResponses() | 22 responses = t.GetHTTPResponses() |
| 23 for response in responses: | 23 for response in responses: |
| 24 print "URL: %s, ViaHeader: %s, XHR: %s" % (response.url, | 24 print "URL: %s, ViaHeader: %s, XHR: %s" % (response.url, |
| 25 response.ResponseHasViaHeader(), response.WasXHR()) | 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) |
| 26 | 40 |
| 27 # Show how to get a histogram. | 41 # Show how to get a histogram. |
| 28 def testPingbackHistogram(self): | 42 def testPingbackHistogram(self): |
| 29 with TestDriver() as t: | 43 with TestDriver() as t: |
| 30 t.AddChromeArg('--enable-spdy-proxy-auth') | 44 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 31 t.LoadURL('http://check.googlezip.net/test.html') | 45 t.LoadURL('http://check.googlezip.net/test.html') |
| 32 t.LoadURL('http://check.googlezip.net/test.html') | 46 t.LoadURL('http://check.googlezip.net/test.html') |
| 33 print t.GetHistogram('DataReductionProxy.Pingback.Attempted') | 47 print t.GetHistogram('DataReductionProxy.Pingback.Attempted') |
| 34 | 48 |
| 35 # Show how to use WaitForJavascriptExpression | 49 # Show how to use WaitForJavascriptExpression |
| 36 def testHTML5(self): | 50 def testHTML5(self): |
| 37 with TestDriver() as t: | 51 with TestDriver() as t: |
| 38 t.AddChromeArg('--enable-spdy-proxy-auth') | 52 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 39 t.LoadURL('http://html5test.com/') | 53 t.LoadURL('http://html5test.com/') |
| 40 t.WaitForJavascriptExpression( | 54 t.WaitForJavascriptExpression( |
| 41 'document.getElementsByClassName("pointsPanel")', 15) | 55 'document.getElementsByClassName("pointsPanel")', 15) |
| 42 | 56 |
| 43 if __name__ == '__main__': | 57 if __name__ == '__main__': |
| 44 # The unittest library uses sys.argv itself and is easily confused by our | 58 IntegrationTest.RunAllTests() |
| 45 # command line options. Pass it a simpler argv instead, while working in the | |
| 46 # unittest command line args functionality. | |
| 47 flags = common.ParseFlags() | |
| 48 unittest.main(argv=[sys.argv[0]], verbosity=2, failfast=flags.failfast, | |
| 49 catchbreak=flags.catch, buffer=(not flags.disable_buffer)) | |
| OLD | NEW |