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

Side by Side Diff: chrome/test/chromedriver/test/run_py_tests.py

Issue 1004843002: [chromedriver] Add Network Presets to Network Throttling feature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """End to end tests for ChromeDriver.""" 6 """End to end tests for ChromeDriver."""
7 7
8 import base64 8 import base64
9 import json 9 import json
10 import math 10 import math
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 _NEGATIVE_FILTER = [ 47 _NEGATIVE_FILTER = [
48 # https://code.google.com/p/chromedriver/issues/detail?id=213 48 # https://code.google.com/p/chromedriver/issues/detail?id=213
49 'ChromeDriverTest.testClickElementInSubFrame', 49 'ChromeDriverTest.testClickElementInSubFrame',
50 # This test is flaky since it uses setTimeout. 50 # This test is flaky since it uses setTimeout.
51 # Re-enable once crbug.com/177511 is fixed and we can remove setTimeout. 51 # Re-enable once crbug.com/177511 is fixed and we can remove setTimeout.
52 'ChromeDriverTest.testAlert', 52 'ChromeDriverTest.testAlert',
53 # Enable per-browser when http://crbug.com/456324 is fixed. 53 # Enable per-browser when http://crbug.com/456324 is fixed.
54 'ChromeDriverTest.testEmulateNetworkConditionsOffline', 54 'ChromeDriverTest.testEmulateNetworkConditionsOffline',
55 # This test is too flaky on the bots, but seems to run perfectly fine 55 # This test is too flaky on the bots, but seems to run perfectly fine
56 # on developer workstations. 56 # on developer workstations.
57 'ChromeDriverTest.testEmulateNetworkConditionsNameSpeed',
57 'ChromeDriverTest.testEmulateNetworkConditionsSpeed', 58 'ChromeDriverTest.testEmulateNetworkConditionsSpeed',
58 ] 59 ]
59 60
60 _VERSION_SPECIFIC_FILTER = {} 61 _VERSION_SPECIFIC_FILTER = {}
61 _VERSION_SPECIFIC_FILTER['HEAD'] = [ 62 _VERSION_SPECIFIC_FILTER['HEAD'] = [
62 # https://code.google.com/p/chromedriver/issues/detail?id=992 63 # https://code.google.com/p/chromedriver/issues/detail?id=992
63 'ChromeDownloadDirTest.testDownloadDirectoryOverridesExistingPreferences', 64 'ChromeDownloadDirTest.testDownloadDirectoryOverridesExistingPreferences',
64 ] 65 ]
65 _VERSION_SPECIFIC_FILTER['37'] = [ 66 _VERSION_SPECIFIC_FILTER['37'] = [
66 # https://code.google.com/p/chromedriver/issues/detail?id=954 67 # https://code.google.com/p/chromedriver/issues/detail?id=954
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ] 155 ]
155 ) 156 )
156 _ANDROID_NEGATIVE_FILTER['chromedriver_webview_shell'] = ( 157 _ANDROID_NEGATIVE_FILTER['chromedriver_webview_shell'] = (
157 _ANDROID_NEGATIVE_FILTER['chrome_shell'] + [ 158 _ANDROID_NEGATIVE_FILTER['chrome_shell'] + [
158 # https://code.google.com/p/chromedriver/issues/detail?id=913 159 # https://code.google.com/p/chromedriver/issues/detail?id=913
159 'ChromeDriverTest.testChromeDriverSendLargeData', 160 'ChromeDriverTest.testChromeDriverSendLargeData',
160 'PerformanceLoggerTest.testPerformanceLogger', 161 'PerformanceLoggerTest.testPerformanceLogger',
161 'ChromeDriverTest.testShadowDom*', 162 'ChromeDriverTest.testShadowDom*',
162 # WebView doesn't support emulating network conditions. 163 # WebView doesn't support emulating network conditions.
163 'ChromeDriverTest.testEmulateNetworkConditions', 164 'ChromeDriverTest.testEmulateNetworkConditions',
165 'ChromeDriverTest.testEmulateNetworkConditionsNameSpeed',
164 'ChromeDriverTest.testEmulateNetworkConditionsOffline', 166 'ChromeDriverTest.testEmulateNetworkConditionsOffline',
165 'ChromeDriverTest.testEmulateNetworkConditionsSpeed', 167 'ChromeDriverTest.testEmulateNetworkConditionsSpeed',
166 ] 168 ]
167 ) 169 )
168 170
169 171
170 class ChromeDriverBaseTest(unittest.TestCase): 172 class ChromeDriverBaseTest(unittest.TestCase):
171 """Base class for testing chromedriver functionalities.""" 173 """Base class for testing chromedriver functionalities."""
172 174
173 def __init__(self, *args, **kwargs): 175 def __init__(self, *args, **kwargs):
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 def testEmulateNetworkConditions(self): 801 def testEmulateNetworkConditions(self):
800 # DSL: 2Mbps throughput, 5ms RTT 802 # DSL: 2Mbps throughput, 5ms RTT
801 latency = 5 803 latency = 5
802 throughput = 2048 * 1024 804 throughput = 2048 * 1024
803 self._driver.SetNetworkConditions(latency, throughput, throughput) 805 self._driver.SetNetworkConditions(latency, throughput, throughput)
804 806
805 network = self._driver.GetNetworkConditions() 807 network = self._driver.GetNetworkConditions()
806 self.assertEquals(latency, network['latency']); 808 self.assertEquals(latency, network['latency']);
807 self.assertEquals(throughput, network['download_throughput']); 809 self.assertEquals(throughput, network['download_throughput']);
808 self.assertEquals(throughput, network['upload_throughput']); 810 self.assertEquals(throughput, network['upload_throughput']);
811 self.assertEquals(False, network['offline']);
812
813 def testEmulateNetworkConditionsName(self):
814 # DSL: 2Mbps throughput, 5ms RTT
815 #latency = 5
816 #throughput = 2048 * 1024
817 self._driver.SetNetworkConditionsName('DSL')
818
819 network = self._driver.GetNetworkConditions()
820 self.assertEquals(5, network['latency']);
821 self.assertEquals(2048*1024, network['download_throughput']);
822 self.assertEquals(2048*1024, network['upload_throughput']);
823 self.assertEquals(False, network['offline']);
809 824
810 def testEmulateNetworkConditionsSpeed(self): 825 def testEmulateNetworkConditionsSpeed(self):
811 # Warm up the browser. 826 # Warm up the browser.
812 self._http_server.SetDataForPath( 827 self._http_server.SetDataForPath(
813 '/', "<html><body>blank</body></html>") 828 '/', "<html><body>blank</body></html>")
814 self._driver.Load(self._http_server.GetUrl() + '/') 829 self._driver.Load(self._http_server.GetUrl() + '/')
815 830
816 # DSL: 2Mbps throughput, 5ms RTT 831 # DSL: 2Mbps throughput, 5ms RTT
817 latency = 5 832 latency = 5
818 throughput_kbps = 2048 833 throughput_kbps = 2048
819 throughput = throughput_kbps * 1024 834 throughput = throughput_kbps * 1024
820 self._driver.SetNetworkConditions(latency, throughput, throughput) 835 self._driver.SetNetworkConditions(latency, throughput, throughput)
821 836
822 _32_bytes = " 0 1 2 3 4 5 6 7 8 9 A B C D E F" 837 _32_bytes = " 0 1 2 3 4 5 6 7 8 9 A B C D E F"
823 _1_megabyte = _32_bytes * 32768 838 _1_megabyte = _32_bytes * 32768
824 self._http_server.SetDataForPath( 839 self._http_server.SetDataForPath(
825 '/1MB', 840 '/1MB',
826 "<html><body>%s</body></html>" % _1_megabyte) 841 "<html><body>%s</body></html>" % _1_megabyte)
827 start = time.time() 842 start = time.time()
828 self._driver.Load(self._http_server.GetUrl() + '/1MB') 843 self._driver.Load(self._http_server.GetUrl() + '/1MB')
829 finish = time.time() 844 finish = time.time()
830 duration = finish - start 845 duration = finish - start
831 actual_throughput_kbps = 1024 / duration 846 actual_throughput_kbps = 1024 / duration
832 self.assertLessEqual(actual_throughput_kbps, throughput_kbps * 1.5) 847 self.assertLessEqual(actual_throughput_kbps, throughput_kbps * 1.5)
833 self.assertGreaterEqual(actual_throughput_kbps, throughput_kbps / 1.5) 848 self.assertGreaterEqual(actual_throughput_kbps, throughput_kbps / 1.5)
834 849
850 def testEmulateNetworkConditionsNameSpeed(self):
851 # Warm up the browser.
852 self._http_server.SetDataForPath(
853 '/', "<html><body>blank</body></html>")
854 self._driver.Load(self._http_server.GetUrl() + '/')
855
856 # DSL: 2Mbps throughput, 5ms RTT
857 throughput_kbps = 2048
858 throughput = throughput_kbps * 1024
859 self._driver.SetNetworkConditionsName('DSL')
860
861 _32_bytes = " 0 1 2 3 4 5 6 7 8 9 A B C D E F"
862 _1_megabyte = _32_bytes * 32768
863 self._http_server.SetDataForPath(
864 '/1MB',
865 "<html><body>%s</body></html>" % _1_megabyte)
866 start = time.time()
867 self._driver.Load(self._http_server.GetUrl() + '/1MB')
868 finish = time.time()
869 duration = finish - start
870 actual_throughput_kbps = 1024 / duration
871 self.assertLessEqual(actual_throughput_kbps, throughput_kbps * 1.5)
872 self.assertGreaterEqual(actual_throughput_kbps, throughput_kbps / 1.5)
873
835 def testEmulateNetworkConditionsOffline(self): 874 def testEmulateNetworkConditionsOffline(self):
836 self._driver.SetNetworkConditions(5, 2048, 2048, offline=True) 875 self._driver.SetNetworkConditions(5, 2048, 2048, offline=True)
837 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html')) 876 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html'))
838 self.assertIn('is not available', self._driver.GetTitle()) 877 self.assertIn('is not available', self._driver.GetTitle())
839 878
840 def testShadowDomFindElementWithSlashDeep(self): 879 def testShadowDomFindElementWithSlashDeep(self):
841 """Checks that chromedriver can find elements in a shadow DOM using /deep/ 880 """Checks that chromedriver can find elements in a shadow DOM using /deep/
842 css selectors.""" 881 css selectors."""
843 self._driver.Load(self.GetHttpUrlForFile( 882 self._driver.Load(self.GetHttpUrlForFile(
844 '/chromedriver/shadow_dom_test.html')) 883 '/chromedriver/shadow_dom_test.html'))
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 1536
1498 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( 1537 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule(
1499 sys.modules[__name__]) 1538 sys.modules[__name__])
1500 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) 1539 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter)
1501 ChromeDriverTest.GlobalSetUp() 1540 ChromeDriverTest.GlobalSetUp()
1502 MobileEmulationCapabilityTest.GlobalSetUp() 1541 MobileEmulationCapabilityTest.GlobalSetUp()
1503 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) 1542 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests)
1504 ChromeDriverTest.GlobalTearDown() 1543 ChromeDriverTest.GlobalTearDown()
1505 MobileEmulationCapabilityTest.GlobalTearDown() 1544 MobileEmulationCapabilityTest.GlobalTearDown()
1506 sys.exit(len(result.failures) + len(result.errors)) 1545 sys.exit(len(result.failures) + len(result.errors))
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/embed_networks_in_cpp.py ('k') | chrome/test/chromedriver/window_commands.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698