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

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

Issue 1022543002: [chromedriver] Implement DELETE NetworkConditions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allocate on the stack 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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 793
794 def testMobileEmulationDisabledByDefault(self): 794 def testMobileEmulationDisabledByDefault(self):
795 self.assertFalse(self._driver.capabilities['mobileEmulationEnabled']) 795 self.assertFalse(self._driver.capabilities['mobileEmulationEnabled'])
796 796
797 def testChromeDriverSendLargeData(self): 797 def testChromeDriverSendLargeData(self):
798 script = 's = ""; for (i = 0; i < 10e6; i++) s += "0"; return s;' 798 script = 's = ""; for (i = 0; i < 10e6; i++) s += "0"; return s;'
799 lots_of_data = self._driver.ExecuteScript(script) 799 lots_of_data = self._driver.ExecuteScript(script)
800 self.assertEquals('0'.zfill(int(10e6)), lots_of_data) 800 self.assertEquals('0'.zfill(int(10e6)), lots_of_data)
801 801
802 def testEmulateNetworkConditions(self): 802 def testEmulateNetworkConditions(self):
803 # Network conditions must be set before it can be retrieved.
804 self.assertRaises(chromedriver.UnknownError,
805 self._driver.GetNetworkConditions)
806
803 # DSL: 2Mbps throughput, 5ms RTT 807 # DSL: 2Mbps throughput, 5ms RTT
804 latency = 5 808 latency = 5
805 throughput = 2048 * 1024 809 throughput = 2048 * 1024
806 self._driver.SetNetworkConditions(latency, throughput, throughput) 810 self._driver.SetNetworkConditions(latency, throughput, throughput)
807 811
808 network = self._driver.GetNetworkConditions() 812 network = self._driver.GetNetworkConditions()
809 self.assertEquals(latency, network['latency']); 813 self.assertEquals(latency, network['latency']);
810 self.assertEquals(throughput, network['download_throughput']); 814 self.assertEquals(throughput, network['download_throughput']);
811 self.assertEquals(throughput, network['upload_throughput']); 815 self.assertEquals(throughput, network['upload_throughput']);
812 self.assertEquals(False, network['offline']); 816 self.assertEquals(False, network['offline']);
813 817
818 # Network Conditions again cannot be retrieved after they've been deleted.
819 self._driver.DeleteNetworkConditions()
820 self.assertRaises(chromedriver.UnknownError,
821 self._driver.GetNetworkConditions)
822
814 def testEmulateNetworkConditionsName(self): 823 def testEmulateNetworkConditionsName(self):
815 # DSL: 2Mbps throughput, 5ms RTT 824 # DSL: 2Mbps throughput, 5ms RTT
816 #latency = 5 825 #latency = 5
817 #throughput = 2048 * 1024 826 #throughput = 2048 * 1024
818 self._driver.SetNetworkConditionsName('DSL') 827 self._driver.SetNetworkConditionsName('DSL')
819 828
820 network = self._driver.GetNetworkConditions() 829 network = self._driver.GetNetworkConditions()
821 self.assertEquals(5, network['latency']); 830 self.assertEquals(5, network['latency']);
822 self.assertEquals(2048*1024, network['download_throughput']); 831 self.assertEquals(2048*1024, network['download_throughput']);
823 self.assertEquals(2048*1024, network['upload_throughput']); 832 self.assertEquals(2048*1024, network['upload_throughput']);
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 1547
1539 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( 1548 all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule(
1540 sys.modules[__name__]) 1549 sys.modules[__name__])
1541 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) 1550 tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter)
1542 ChromeDriverTest.GlobalSetUp() 1551 ChromeDriverTest.GlobalSetUp()
1543 MobileEmulationCapabilityTest.GlobalSetUp() 1552 MobileEmulationCapabilityTest.GlobalSetUp()
1544 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) 1553 result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests)
1545 ChromeDriverTest.GlobalTearDown() 1554 ChromeDriverTest.GlobalTearDown()
1546 MobileEmulationCapabilityTest.GlobalTearDown() 1555 MobileEmulationCapabilityTest.GlobalTearDown()
1547 sys.exit(len(result.failures) + len(result.errors)) 1556 sys.exit(len(result.failures) + len(result.errors))
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/server/http_handler.cc ('k') | chrome/test/chromedriver/window_commands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698