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

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

Issue 883083002: [chromedriver] Add Network Conditions Override Manager and tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix warning 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 from pylib import valgrind_tools 43 from pylib import valgrind_tools
44 from pylib.device import device_utils 44 from pylib.device import device_utils
45 45
46 46
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.
54 'ChromeDriverTest.testEmulateNetworkConditionsOffline',
53 ] 55 ]
54 56
55 _VERSION_SPECIFIC_FILTER = {} 57 _VERSION_SPECIFIC_FILTER = {}
56 _VERSION_SPECIFIC_FILTER['HEAD'] = [ 58 _VERSION_SPECIFIC_FILTER['HEAD'] = [
57 # https://code.google.com/p/chromedriver/issues/detail?id=992 59 # https://code.google.com/p/chromedriver/issues/detail?id=992
58 'ChromeDownloadDirTest.testDownloadDirectoryOverridesExistingPreferences', 60 'ChromeDownloadDirTest.testDownloadDirectoryOverridesExistingPreferences',
59 ] 61 ]
60 _VERSION_SPECIFIC_FILTER['37'] = [ 62 _VERSION_SPECIFIC_FILTER['37'] = [
61 # https://code.google.com/p/chromedriver/issues/detail?id=954 63 # https://code.google.com/p/chromedriver/issues/detail?id=954
62 'MobileEmulationCapabilityTest.testClickElement', 64 'MobileEmulationCapabilityTest.testClickElement',
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 self._driver.ExecuteScript('debugger;') 782 self._driver.ExecuteScript('debugger;')
781 783
782 def testMobileEmulationDisabledByDefault(self): 784 def testMobileEmulationDisabledByDefault(self):
783 self.assertFalse(self._driver.capabilities['mobileEmulationEnabled']) 785 self.assertFalse(self._driver.capabilities['mobileEmulationEnabled'])
784 786
785 def testChromeDriverSendLargeData(self): 787 def testChromeDriverSendLargeData(self):
786 script = 's = ""; for (i = 0; i < 10e6; i++) s += "0"; return s;' 788 script = 's = ""; for (i = 0; i < 10e6; i++) s += "0"; return s;'
787 lots_of_data = self._driver.ExecuteScript(script) 789 lots_of_data = self._driver.ExecuteScript(script)
788 self.assertEquals('0'.zfill(int(10e6)), lots_of_data) 790 self.assertEquals('0'.zfill(int(10e6)), lots_of_data)
789 791
792 def testEmulateNetworkConditions(self):
793 # DSL: 2Mbps throughput, 5ms RTT
794 latency = 5
795 throughput = 2048 * 1024
796 self._driver.SetNetworkConditions(latency, throughput, throughput)
797
798 network = self._driver.GetNetworkConditions()
799 self.assertEquals(latency, network['latency']);
800 self.assertEquals(throughput, network['download_throughput']);
801 self.assertEquals(throughput, network['upload_throughput']);
802
803 def testEmulateNetworkConditionsOffline(self):
804 self._driver.SetNetworkConditions(5, 2048, 2048, offline=True)
805 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html'))
806 self.assertIn('is not available', self._driver.GetTitle())
807
808 def testEmulateNetworkConditionsSpeed(self):
809 # Warm up the browser.
810 self._http_server.SetDataForPath(
811 '/', "<html><body>blank</body></html>")
812 self._driver.Load(self._http_server.GetUrl() + '/')
813
814 # DSL: 2Mbps throughput, 5ms RTT
815 latency = 5
816 throughput_kbps = 2048
817 throughput = throughput_kbps * 1024
818 self._driver.SetNetworkConditions(latency, throughput, throughput)
819
820 _32_bytes = " 0 1 2 3 4 5 6 7 8 9 A B C D E F"
821 _1_megabyte = _32_bytes * 32768
822 self._http_server.SetDataForPath(
823 '/1MB',
824 "<html><body>%s</body></html>" % _1_megabyte)
825 start = time.time()
826 self._driver.Load(self._http_server.GetUrl() + '/1MB')
827 finish = time.time()
828 duration = finish - start
829 actual_throughput_kbps = 1024 / duration
830 self.assertLessEqual(actual_throughput_kbps, throughput_kbps * 1.5)
831 self.assertGreaterEqual(actual_throughput_kbps, throughput_kbps / 1.5)
832
790 def testShadowDomFindElementWithSlashDeep(self): 833 def testShadowDomFindElementWithSlashDeep(self):
791 """Checks that chromedriver can find elements in a shadow DOM using /deep/ 834 """Checks that chromedriver can find elements in a shadow DOM using /deep/
792 css selectors.""" 835 css selectors."""
793 self._driver.Load(self.GetHttpUrlForFile( 836 self._driver.Load(self.GetHttpUrlForFile(
794 '/chromedriver/shadow_dom_test.html')) 837 '/chromedriver/shadow_dom_test.html'))
795 self.assertTrue(self._driver.FindElement("css", "* /deep/ #olderTextBox")) 838 self.assertTrue(self._driver.FindElement("css", "* /deep/ #olderTextBox"))
796 839
797 def testShadowDomFindChildElement(self): 840 def testShadowDomFindChildElement(self):
798 """Checks that chromedriver can find child elements from a shadow DOM 841 """Checks that chromedriver can find child elements from a shadow DOM
799 element.""" 842 element."""
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 1491
1449 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( 1492 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule(
1450 sys.modules[__name__]) 1493 sys.modules[__name__])
1451 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) 1494 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter)
1452 ChromeDriverTest.GlobalSetUp() 1495 ChromeDriverTest.GlobalSetUp()
1453 MobileEmulationCapabilityTest.GlobalSetUp() 1496 MobileEmulationCapabilityTest.GlobalSetUp()
1454 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) 1497 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests)
1455 ChromeDriverTest.GlobalTearDown() 1498 ChromeDriverTest.GlobalTearDown()
1456 MobileEmulationCapabilityTest.GlobalTearDown() 1499 MobileEmulationCapabilityTest.GlobalTearDown()
1457 sys.exit(len(result.failures) + len(result.errors)) 1500 sys.exit(len(result.failures) + len(result.errors))
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/session_commands.cc ('k') | chrome/test/chromedriver/window_commands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698