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

Unified Diff: chrome/test/chromedriver/session_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/session_commands.h ('k') | chrome/test/chromedriver/test/run_py_tests.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/session_commands.cc
diff --git a/chrome/test/chromedriver/session_commands.cc b/chrome/test/chromedriver/session_commands.cc
index 9af15c3a49f51164d7b480df0a1c6d5f13448759..b403124f5d63c31e8d49df11e8063f586ff47d0d 100644
--- a/chrome/test/chromedriver/session_commands.cc
+++ b/chrome/test/chromedriver/session_commands.cc
@@ -356,6 +356,20 @@ Status ExecuteSwitchToWindow(
return status;
}
+ if (session->overridden_network_conditions) {
+ WebView* web_view;
+ status = session->chrome->GetWebViewById(web_view_id, &web_view);
+ if (status.IsError())
+ return status;
+ status = web_view->ConnectIfNecessary();
+ if (status.IsError())
+ return status;
+ status = web_view->OverrideNetworkConditions(
+ *session->overridden_network_conditions);
+ if (status.IsError())
+ return status;
+ }
+
session->window = web_view_id;
session->SwitchToTopFrame();
session->mouse_position = WebPoint(0, 0);
@@ -456,6 +470,29 @@ Status ExecuteGetLocation(
return Status(kOk);
}
+Status ExecuteGetNetworkConditions(
+ Session* session,
+ const base::DictionaryValue& params,
+ scoped_ptr<base::Value>* value) {
+ if (!session->overridden_network_conditions) {
+ return Status(kUnknownError,
+ "network conditions must be set before it can be retrieved");
+ }
+ base::DictionaryValue conditions;
+ conditions.SetBoolean("offline",
+ session->overridden_network_conditions->offline);
+ conditions.SetInteger("latency",
+ session->overridden_network_conditions->latency);
+ conditions.SetInteger(
+ "download_throughput",
+ session->overridden_network_conditions->download_throughput);
+ conditions.SetInteger(
+ "upload_throughput",
+ session->overridden_network_conditions->upload_throughput);
+ value->reset(conditions.DeepCopy());
+ return Status(kOk);
+}
+
Status ExecuteGetWindowPosition(
Session* session,
const base::DictionaryValue& params,
« no previous file with comments | « chrome/test/chromedriver/session_commands.h ('k') | chrome/test/chromedriver/test/run_py_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698