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

Unified Diff: chrome/test/chromedriver/window_commands.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/chromedriver/window_commands.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/window_commands.cc
diff --git a/chrome/test/chromedriver/window_commands.cc b/chrome/test/chromedriver/window_commands.cc
index 9a3c40512fa32d40afa8c6e46dcc08131266fa7d..70273317d553390e4e8ecaa80c9ec82821227925 100644
--- a/chrome/test/chromedriver/window_commands.cc
+++ b/chrome/test/chromedriver/window_commands.cc
@@ -869,6 +869,53 @@ Status ExecuteSetLocation(
return status;
}
+Status ExecuteSetNetworkConditions(
+ Session* session,
+ WebView* web_view,
+ const base::DictionaryValue& params,
+ scoped_ptr<base::Value>* value) {
+ const base::DictionaryValue* conditions = NULL;
+ NetworkConditions network_conditions;
+ // |latency| is required.
+ if (!params.GetDictionary("network_conditions", &conditions) ||
+ !conditions->GetDouble("latency", &network_conditions.latency))
+ return Status(kUnknownError, "missing or invalid 'network_conditions'");
+
+ // Either |throughput| or the pair |download_throughput| and
+ // |upload_throughput| is required.
+ if (conditions->HasKey("throughput")) {
+ if (!conditions->GetDouble("throughput",
+ &network_conditions.download_throughput))
+ return Status(kUnknownError, "invalid 'throughput'");
+ conditions->GetDouble("throughput", &network_conditions.upload_throughput);
+ } else if (conditions->HasKey("download_throughput") &&
+ conditions->HasKey("upload_throughput")) {
+ if (!conditions->GetDouble("download_throughput",
+ &network_conditions.download_throughput) ||
+ !conditions->GetDouble("upload_throughput",
+ &network_conditions.upload_throughput))
+ return Status(kUnknownError,
+ "invalid 'download_throughput' or 'upload_throughput'");
+ } else {
+ return Status(kUnknownError,
+ "invalid 'network_conditions' is missing 'throughput' or "
+ "'download_throughput'/'upload_throughput' pair");
+ }
+
+ // |offline| is optional.
+ if (conditions->HasKey("offline")) {
+ if (!conditions->GetBoolean("offline", &network_conditions.offline))
+ return Status(kUnknownError, "invalid 'offline'");
+ } else {
+ network_conditions.offline = false;
+ }
+
+ session->overridden_network_conditions.reset(
+ new NetworkConditions(network_conditions));
+ return web_view->OverrideNetworkConditions(
+ *session->overridden_network_conditions);
+}
+
Status ExecuteTakeHeapSnapshot(
Session* session,
WebView* web_view,
« no previous file with comments | « chrome/test/chromedriver/window_commands.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698