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

Unified 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: Fixing scoping bug; switching throughput and latency fields to doubles Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/chromedriver/test/run_py_tests.py
diff --git a/chrome/test/chromedriver/test/run_py_tests.py b/chrome/test/chromedriver/test/run_py_tests.py
index d64b0a9703e0fc702c90bf7ccba0795a3025ab89..dd6a68e0f98522e728ba1190c78700deeed497d4 100755
--- a/chrome/test/chromedriver/test/run_py_tests.py
+++ b/chrome/test/chromedriver/test/run_py_tests.py
@@ -787,6 +787,42 @@ class ChromeDriverTest(ChromeDriverBaseTest):
lots_of_data = self._driver.ExecuteScript(script)
self.assertEquals('0'.zfill(int(10e6)), lots_of_data)
+ def testEmulateNetworkConditions(self):
+ # DSL: 2Mbps throughput, 5ms RTT
+ latency = 5
+ throughput = 2048 * 1024
+ self._driver.SetNetworkConditions(latency, throughput, throughput)
+
+ network = self._driver.GetNetworkConditions()
+ self.assertEquals(latency, network['latency']);
+ self.assertEquals(throughput, network['download_throughput']);
+ self.assertEquals(throughput, network['upload_throughput']);
+
+ def testEmulateNetworkConditionsSpeed(self):
+ # Warm up the browser.
+ self._http_server.SetDataForPath(
+ '/', "<html><body>blank</body></html>")
+ self._driver.Load(self._http_server.GetUrl() + '/')
+
+ # DSL: 2Mbps throughput, 5ms RTT
+ latency = 5
+ throughput_kbps = 2048
+ throughput = throughput_kbps * 1024
+ self._driver.SetNetworkConditions(latency, throughput, throughput)
+
+ _32_bytes = " 0 1 2 3 4 5 6 7 8 9 A B C D E F"
+ _1_megabyte = _32_bytes * 32768
+ self._http_server.SetDataForPath(
+ '/1MB',
+ "<html><body>%s</body></html>" % _1_megabyte)
+ start = time.time()
+ self._driver.Load(self._http_server.GetUrl() + '/1MB')
+ finish = time.time()
+ duration = finish-start
+ actual_throughput_kbps = 1024 / duration
+ self.assertLessEqual(actual_throughput_kbps, throughput_kbps * 1.5)
+ self.assertGreaterEqual(actual_throughput_kbps, throughput_kbps / 1.5)
+
def testShadowDomFindElementWithSlashDeep(self):
"""Checks that chromedriver can find elements in a shadow DOM using /deep/
css selectors."""

Powered by Google App Engine
This is Rietveld 408576698