| 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 | 7 import unittest |
| 8 | 8 |
| 9 import common | 9 import common |
| 10 from common import TestDriver | 10 from common import TestDriver |
| 11 | 11 |
| 12 | 12 |
| 13 class SimpleSmoke(unittest.TestCase): | 13 class SimpleSmoke(unittest.TestCase): |
| 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.SetURL('http://check.googlezip.net/test.html') | 19 t.LoadURL('http://check.googlezip.net/test.html') |
| 20 t.LoadPage() | |
| 21 print 'Document Title: ', t.ExecuteJavascriptStatement('document.title', | 20 print 'Document Title: ', t.ExecuteJavascriptStatement('document.title', |
| 22 timeout=1) | 21 timeout=1) |
| 23 time.sleep(5) | |
| 24 responses = t.GetHTTPResponses() | 22 responses = t.GetHTTPResponses() |
| 25 for response in responses: | 23 for response in responses: |
| 26 print "URL: %s, ViaHeader: %s, XHR: %s" % (response.url, | 24 print "URL: %s, ViaHeader: %s, XHR: %s" % (response.url, |
| 27 response.ResponseHasViaHeader(), response.WasXHR()) | 25 response.ResponseHasViaHeader(), response.WasXHR()) |
| 28 | 26 |
| 29 # Show how to get a histogram. | 27 # Show how to get a histogram. |
| 30 def testPingbackHistogram(self): | 28 def testPingbackHistogram(self): |
| 31 with TestDriver() as t: | 29 with TestDriver() as t: |
| 32 t.AddChromeArg('--enable-spdy-proxy-auth') | 30 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 33 t.SetURL('http://check.googlezip.net/test.html') | 31 t.LoadURL('http://check.googlezip.net/test.html') |
| 34 t.LoadPage() | 32 t.LoadURL('http://check.googlezip.net/test.html') |
| 35 t.LoadPage() | |
| 36 print t.GetHistogram('DataReductionProxy.Pingback.Attempted') | 33 print t.GetHistogram('DataReductionProxy.Pingback.Attempted') |
| 37 | 34 |
| 35 # Show how to use WaitForJavascriptExpression |
| 36 def testHTML5(self): |
| 37 with TestDriver() as t: |
| 38 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 39 t.LoadURL('http://html5test.com/') |
| 40 t.WaitForJavascriptExpression( |
| 41 'document.getElementsByClassName("pointsPanel")', 15) |
| 42 |
| 38 if __name__ == '__main__': | 43 if __name__ == '__main__': |
| 39 # The unittest library uses sys.argv itself and is easily confused by our | 44 # The unittest library uses sys.argv itself and is easily confused by our |
| 40 # command line options. Pass it a simpler argv instead. | 45 # command line options. Pass it a simpler argv instead. |
| 41 unittest.main(argv=[sys.argv[0]], verbosity=2) | 46 unittest.main(argv=[sys.argv[0]], verbosity=2) |
| OLD | NEW |