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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « chrome/test/chromedriver/window_commands.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/chromedriver/window_commands.h" 5 #include "chrome/test/chromedriver/window_commands.h"
6 6
7 #include <list> 7 #include <list>
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 // default to 100 meters accuracy. 862 // default to 100 meters accuracy.
863 geoposition.accuracy = 100; 863 geoposition.accuracy = 100;
864 } 864 }
865 865
866 Status status = web_view->OverrideGeolocation(geoposition); 866 Status status = web_view->OverrideGeolocation(geoposition);
867 if (status.IsOk()) 867 if (status.IsOk())
868 session->overridden_geoposition.reset(new Geoposition(geoposition)); 868 session->overridden_geoposition.reset(new Geoposition(geoposition));
869 return status; 869 return status;
870 } 870 }
871 871
872 Status ExecuteSetNetworkConditions(
873 Session* session,
874 WebView* web_view,
875 const base::DictionaryValue& params,
876 scoped_ptr<base::Value>* value) {
877 const base::DictionaryValue* conditions = NULL;
878 NetworkConditions network_conditions;
879 // |latency| is required.
880 if (!params.GetDictionary("network_conditions", &conditions) ||
881 !conditions->GetDouble("latency", &network_conditions.latency))
882 return Status(kUnknownError, "missing or invalid 'network_conditions'");
883
884 // Either |throughput| or the pair |download_throughput| and
885 // |upload_throughput| is required.
886 if (conditions->HasKey("throughput")) {
887 if (!conditions->GetDouble("throughput",
888 &network_conditions.download_throughput))
889 return Status(kUnknownError, "invalid 'throughput'");
890 conditions->GetDouble("throughput", &network_conditions.upload_throughput);
891 } else if (conditions->HasKey("download_throughput") &&
892 conditions->HasKey("upload_throughput")) {
893 if (!conditions->GetDouble("download_throughput",
894 &network_conditions.download_throughput) ||
895 !conditions->GetDouble("upload_throughput",
896 &network_conditions.upload_throughput))
897 return Status(kUnknownError,
898 "invalid 'download_throughput' or 'upload_throughput'");
899 } else {
900 return Status(kUnknownError,
901 "invalid 'network_conditions' is missing 'throughput' or "
902 "'download_throughput'/'upload_throughput' pair");
903 }
904
905 // |offline| is optional.
906 if (conditions->HasKey("offline")) {
907 if (!conditions->GetBoolean("offline", &network_conditions.offline))
908 return Status(kUnknownError, "invalid 'offline'");
909 } else {
910 network_conditions.offline = false;
911 }
912
913 session->overridden_network_conditions.reset(
914 new NetworkConditions(network_conditions));
915 return web_view->OverrideNetworkConditions(
916 *session->overridden_network_conditions);
917 }
918
872 Status ExecuteTakeHeapSnapshot( 919 Status ExecuteTakeHeapSnapshot(
873 Session* session, 920 Session* session,
874 WebView* web_view, 921 WebView* web_view,
875 const base::DictionaryValue& params, 922 const base::DictionaryValue& params,
876 scoped_ptr<base::Value>* value) { 923 scoped_ptr<base::Value>* value) {
877 return web_view->TakeHeapSnapshot(value); 924 return web_view->TakeHeapSnapshot(value);
878 } 925 }
OLDNEW
« 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