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

Side by Side 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 unified diff | Download patch
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/session_commands.h" 5 #include "chrome/test/chromedriver/session_commands.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 if (status.IsError()) 349 if (status.IsError())
350 return status; 350 return status;
351 status = web_view->ConnectIfNecessary(); 351 status = web_view->ConnectIfNecessary();
352 if (status.IsError()) 352 if (status.IsError())
353 return status; 353 return status;
354 status = web_view->OverrideGeolocation(*session->overridden_geoposition); 354 status = web_view->OverrideGeolocation(*session->overridden_geoposition);
355 if (status.IsError()) 355 if (status.IsError())
356 return status; 356 return status;
357 } 357 }
358 358
359 if (session->overridden_network_conditions) {
360 WebView* web_view;
361 status = session->chrome->GetWebViewById(web_view_id, &web_view);
362 if (status.IsError())
363 return status;
364 status = web_view->ConnectIfNecessary();
365 if (status.IsError())
366 return status;
367 status = web_view->OverrideNetworkConditions(
368 *session->overridden_network_conditions);
369 if (status.IsError())
370 return status;
371 }
372
359 session->window = web_view_id; 373 session->window = web_view_id;
360 session->SwitchToTopFrame(); 374 session->SwitchToTopFrame();
361 session->mouse_position = WebPoint(0, 0); 375 session->mouse_position = WebPoint(0, 0);
362 return Status(kOk); 376 return Status(kOk);
363 } 377 }
364 378
365 Status ExecuteSetTimeout( 379 Status ExecuteSetTimeout(
366 Session* session, 380 Session* session,
367 const base::DictionaryValue& params, 381 const base::DictionaryValue& params,
368 scoped_ptr<base::Value>* value) { 382 scoped_ptr<base::Value>* value) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 location.SetDouble("latitude", session->overridden_geoposition->latitude); 463 location.SetDouble("latitude", session->overridden_geoposition->latitude);
450 location.SetDouble("longitude", session->overridden_geoposition->longitude); 464 location.SetDouble("longitude", session->overridden_geoposition->longitude);
451 location.SetDouble("accuracy", session->overridden_geoposition->accuracy); 465 location.SetDouble("accuracy", session->overridden_geoposition->accuracy);
452 // Set a dummy altitude to make WebDriver clients happy. 466 // Set a dummy altitude to make WebDriver clients happy.
453 // https://code.google.com/p/chromedriver/issues/detail?id=281 467 // https://code.google.com/p/chromedriver/issues/detail?id=281
454 location.SetDouble("altitude", 0); 468 location.SetDouble("altitude", 0);
455 value->reset(location.DeepCopy()); 469 value->reset(location.DeepCopy());
456 return Status(kOk); 470 return Status(kOk);
457 } 471 }
458 472
473 Status ExecuteGetNetworkConditions(
474 Session* session,
475 const base::DictionaryValue& params,
476 scoped_ptr<base::Value>* value) {
477 if (!session->overridden_network_conditions) {
478 return Status(kUnknownError,
479 "network conditions must be set before it can be retrieved");
480 }
481 base::DictionaryValue conditions;
482 conditions.SetBoolean("offline",
483 session->overridden_network_conditions->offline);
484 conditions.SetInteger("latency",
485 session->overridden_network_conditions->latency);
486 conditions.SetInteger(
487 "download_throughput",
488 session->overridden_network_conditions->download_throughput);
489 conditions.SetInteger(
490 "upload_throughput",
491 session->overridden_network_conditions->upload_throughput);
492 value->reset(conditions.DeepCopy());
493 return Status(kOk);
494 }
495
459 Status ExecuteGetWindowPosition( 496 Status ExecuteGetWindowPosition(
460 Session* session, 497 Session* session,
461 const base::DictionaryValue& params, 498 const base::DictionaryValue& params,
462 scoped_ptr<base::Value>* value) { 499 scoped_ptr<base::Value>* value) {
463 ChromeDesktopImpl* desktop = NULL; 500 ChromeDesktopImpl* desktop = NULL;
464 Status status = session->chrome->GetAsDesktop(&desktop); 501 Status status = session->chrome->GetAsDesktop(&desktop);
465 if (status.IsError()) 502 if (status.IsError())
466 return status; 503 return status;
467 504
468 AutomationExtension* extension = NULL; 505 AutomationExtension* extension = NULL;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 Status ExecuteSetAutoReporting( 685 Status ExecuteSetAutoReporting(
649 Session* session, 686 Session* session,
650 const base::DictionaryValue& params, 687 const base::DictionaryValue& params,
651 scoped_ptr<base::Value>* value) { 688 scoped_ptr<base::Value>* value) {
652 bool enabled; 689 bool enabled;
653 if (!params.GetBoolean("enabled", &enabled)) 690 if (!params.GetBoolean("enabled", &enabled))
654 return Status(kUnknownError, "missing parameter 'enabled'"); 691 return Status(kUnknownError, "missing parameter 'enabled'");
655 session->auto_reporting_enabled = enabled; 692 session->auto_reporting_enabled = enabled;
656 return Status(kOk); 693 return Status(kOk);
657 } 694 }
OLDNEW
« 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