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

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: Cleaning up Network Names; adding integration tests 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 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 def testEmulateNetworkConditions(self): 792 def testEmulateNetworkConditions(self):
793 # DSL: 2Mbps throughput, 5ms RTT 793 # DSL: 2Mbps throughput, 5ms RTT
794 latency = 5 794 latency = 5
795 throughput = 2048 * 1024 795 throughput = 2048 * 1024
796 self._driver.SetNetworkConditions(latency, throughput, throughput) 796 self._driver.SetNetworkConditions(latency, throughput, throughput)
797 797
798 network = self._driver.GetNetworkConditions() 798 network = self._driver.GetNetworkConditions()
799 self.assertEquals(latency, network['latency']); 799 self.assertEquals(latency, network['latency']);
800 self.assertEquals(throughput, network['download_throughput']); 800 self.assertEquals(throughput, network['download_throughput']);
801 self.assertEquals(throughput, network['upload_throughput']); 801 self.assertEquals(throughput, network['upload_throughput']);
802 self.assertEquals(False, network['offline']);
803
804 def testEmulateNetworkConditionsName(self):
805 # DSL: 2Mbps throughput, 5ms RTT
806 #latency = 5
807 #throughput = 2048 * 1024
808 self._driver.SetNetworkConditionsName('DSL')
809
810 network = self._driver.GetNetworkConditions()
811 self.assertEquals(5, network['latency']);
812 self.assertEquals(2048*1024, network['download_throughput']);
813 self.assertEquals(2048*1024, network['upload_throughput']);
814 self.assertEquals(False, network['offline']);
802 815
803 def testEmulateNetworkConditionsOffline(self): 816 def testEmulateNetworkConditionsOffline(self):
804 self._driver.SetNetworkConditions(5, 2048, 2048, offline=True) 817 self._driver.SetNetworkConditions(5, 2048, 2048, offline=True)
805 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html')) 818 self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html'))
806 self.assertIn('is not available', self._driver.GetTitle()) 819 self.assertIn('is not available', self._driver.GetTitle())
807 820
808 def testEmulateNetworkConditionsSpeed(self): 821 def testEmulateNetworkConditionsSpeed(self):
809 # Warm up the browser. 822 # Warm up the browser.
810 self._http_server.SetDataForPath( 823 self._http_server.SetDataForPath(
811 '/', "<html><body>blank</body></html>") 824 '/', "<html><body>blank</body></html>")
(...skipping 11 matching lines...) Expand all
823 '/1MB', 836 '/1MB',
824 "<html><body>%s</body></html>" % _1_megabyte) 837 "<html><body>%s</body></html>" % _1_megabyte)
825 start = time.time() 838 start = time.time()
826 self._driver.Load(self._http_server.GetUrl() + '/1MB') 839 self._driver.Load(self._http_server.GetUrl() + '/1MB')
827 finish = time.time() 840 finish = time.time()
828 duration = finish - start 841 duration = finish - start
829 actual_throughput_kbps = 1024 / duration 842 actual_throughput_kbps = 1024 / duration
830 self.assertLessEqual(actual_throughput_kbps, throughput_kbps * 1.5) 843 self.assertLessEqual(actual_throughput_kbps, throughput_kbps * 1.5)
831 self.assertGreaterEqual(actual_throughput_kbps, throughput_kbps / 1.5) 844 self.assertGreaterEqual(actual_throughput_kbps, throughput_kbps / 1.5)
832 845
846 def testEmulateNetworkConditionsNameSpeed(self):
847 # Warm up the browser.
848 self._http_server.SetDataForPath(
849 '/', "<html><body>blank</body></html>")
850 self._driver.Load(self._http_server.GetUrl() + '/')
851
852 # DSL: 2Mbps throughput, 5ms RTT
853 throughput_kbps = 2048
854 throughput = throughput_kbps * 1024
855 self._driver.SetNetworkConditionsName('DSL')
856
857 _32_bytes = " 0 1 2 3 4 5 6 7 8 9 A B C D E F"
858 _1_megabyte = _32_bytes * 32768
859 self._http_server.SetDataForPath(
860 '/1MB',
861 "<html><body>%s</body></html>" % _1_megabyte)
862 start = time.time()
863 self._driver.Load(self._http_server.GetUrl() + '/1MB')
864 finish = time.time()
865 duration = finish - start
866 actual_throughput_kbps = 1024 / duration
867 self.assertLessEqual(actual_throughput_kbps, throughput_kbps * 1.5)
868 self.assertGreaterEqual(actual_throughput_kbps, throughput_kbps / 1.5)
869
833 def testShadowDomFindElementWithSlashDeep(self): 870 def testShadowDomFindElementWithSlashDeep(self):
834 """Checks that chromedriver can find elements in a shadow DOM using /deep/ 871 """Checks that chromedriver can find elements in a shadow DOM using /deep/
835 css selectors.""" 872 css selectors."""
836 self._driver.Load(self.GetHttpUrlForFile( 873 self._driver.Load(self.GetHttpUrlForFile(
837 '/chromedriver/shadow_dom_test.html')) 874 '/chromedriver/shadow_dom_test.html'))
838 self.assertTrue(self._driver.FindElement("css", "* /deep/ #olderTextBox")) 875 self.assertTrue(self._driver.FindElement("css", "* /deep/ #olderTextBox"))
839 876
840 def testShadowDomFindChildElement(self): 877 def testShadowDomFindChildElement(self):
841 """Checks that chromedriver can find child elements from a shadow DOM 878 """Checks that chromedriver can find child elements from a shadow DOM
842 element.""" 879 element."""
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 1527
1491 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( 1528 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule(
1492 sys.modules[__name__]) 1529 sys.modules[__name__])
1493 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) 1530 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter)
1494 ChromeDriverTest.GlobalSetUp() 1531 ChromeDriverTest.GlobalSetUp()
1495 MobileEmulationCapabilityTest.GlobalSetUp() 1532 MobileEmulationCapabilityTest.GlobalSetUp()
1496 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) 1533 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests)
1497 ChromeDriverTest.GlobalTearDown() 1534 ChromeDriverTest.GlobalTearDown()
1498 MobileEmulationCapabilityTest.GlobalTearDown() 1535 MobileEmulationCapabilityTest.GlobalTearDown()
1499 sys.exit(len(result.failures) + len(result.errors)) 1536 sys.exit(len(result.failures) + len(result.errors))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698