OLD | NEW |
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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 WebView* web_view = NULL; | 144 WebView* web_view = NULL; |
145 Status status = session->GetTargetWindow(&web_view); | 145 Status status = session->GetTargetWindow(&web_view); |
146 if (status.IsError()) | 146 if (status.IsError()) |
147 return Status(kSessionNotCreatedException, status); | 147 return Status(kSessionNotCreatedException, status); |
148 | 148 |
149 status = web_view->ConnectIfNecessary(); | 149 status = web_view->ConnectIfNecessary(); |
150 if (status.IsError()) | 150 if (status.IsError()) |
151 return Status(kSessionNotCreatedException, status); | 151 return Status(kSessionNotCreatedException, status); |
152 | 152 |
153 base::ListValue args; | 153 base::ListValue args; |
154 std::unique_ptr<base::Value> result(new base::FundamentalValue(0)); | 154 std::unique_ptr<base::Value> result(new base::Value(0)); |
155 status = web_view->CallFunction(session->GetCurrentFrameId(), | 155 status = web_view->CallFunction(session->GetCurrentFrameId(), |
156 "function(s) { return 1; }", args, &result); | 156 "function(s) { return 1; }", args, &result); |
157 if (status.IsError()) | 157 if (status.IsError()) |
158 return Status(kSessionNotCreatedException, status); | 158 return Status(kSessionNotCreatedException, status); |
159 | 159 |
160 int response; | 160 int response; |
161 if (!result->GetAsInteger(&response) || response != 1) { | 161 if (!result->GetAsInteger(&response) || response != 1) { |
162 return Status(kSessionNotCreatedException, | 162 return Status(kSessionNotCreatedException, |
163 "unexpected response from browser"); | 163 "unexpected response from browser"); |
164 } | 164 } |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 | 490 |
491 status = web_view->ConnectIfNecessary(); | 491 status = web_view->ConnectIfNecessary(); |
492 if (status.IsError()) | 492 if (status.IsError()) |
493 return status; | 493 return status; |
494 | 494 |
495 bool is_pending; | 495 bool is_pending; |
496 status = web_view->IsPendingNavigation( | 496 status = web_view->IsPendingNavigation( |
497 session->GetCurrentFrameId(), nullptr, &is_pending); | 497 session->GetCurrentFrameId(), nullptr, &is_pending); |
498 if (status.IsError()) | 498 if (status.IsError()) |
499 return status; | 499 return status; |
500 value->reset(new base::FundamentalValue(is_pending)); | 500 value->reset(new base::Value(is_pending)); |
501 return Status(kOk); | 501 return Status(kOk); |
502 } | 502 } |
503 | 503 |
504 Status ExecuteGetLocation(Session* session, | 504 Status ExecuteGetLocation(Session* session, |
505 const base::DictionaryValue& params, | 505 const base::DictionaryValue& params, |
506 std::unique_ptr<base::Value>* value) { | 506 std::unique_ptr<base::Value>* value) { |
507 if (!session->overridden_geoposition) { | 507 if (!session->overridden_geoposition) { |
508 return Status(kUnknownError, | 508 return Status(kUnknownError, |
509 "Location must be set before it can be retrieved"); | 509 "Location must be set before it can be retrieved"); |
510 } | 510 } |
(...skipping 14 matching lines...) Expand all Loading... |
525 ChromeDesktopImpl* desktop = nullptr; | 525 ChromeDesktopImpl* desktop = nullptr; |
526 Status status = session->chrome->GetAsDesktop(&desktop); | 526 Status status = session->chrome->GetAsDesktop(&desktop); |
527 if (status.IsError()) | 527 if (status.IsError()) |
528 return status; | 528 return status; |
529 if (!desktop->IsNetworkConnectionEnabled()) | 529 if (!desktop->IsNetworkConnectionEnabled()) |
530 return Status(kUnknownError, "network connection must be enabled"); | 530 return Status(kUnknownError, "network connection must be enabled"); |
531 | 531 |
532 int connection_type = 0; | 532 int connection_type = 0; |
533 connection_type = desktop->GetNetworkConnection(); | 533 connection_type = desktop->GetNetworkConnection(); |
534 | 534 |
535 value->reset(new base::FundamentalValue(connection_type)); | 535 value->reset(new base::Value(connection_type)); |
536 return Status(kOk); | 536 return Status(kOk); |
537 } | 537 } |
538 | 538 |
539 Status ExecuteGetNetworkConditions(Session* session, | 539 Status ExecuteGetNetworkConditions(Session* session, |
540 const base::DictionaryValue& params, | 540 const base::DictionaryValue& params, |
541 std::unique_ptr<base::Value>* value) { | 541 std::unique_ptr<base::Value>* value) { |
542 if (!session->overridden_network_conditions) { | 542 if (!session->overridden_network_conditions) { |
543 return Status(kUnknownError, | 543 return Status(kUnknownError, |
544 "network conditions must be set before it can be retrieved"); | 544 "network conditions must be set before it can be retrieved"); |
545 } | 545 } |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 if (status.IsError()) | 807 if (status.IsError()) |
808 return Status(kUnknownError, "unable to unzip 'file'", status); | 808 return Status(kUnknownError, "unable to unzip 'file'", status); |
809 | 809 |
810 value->reset(new base::StringValue(upload.value())); | 810 value->reset(new base::StringValue(upload.value())); |
811 return Status(kOk); | 811 return Status(kOk); |
812 } | 812 } |
813 | 813 |
814 Status ExecuteIsAutoReporting(Session* session, | 814 Status ExecuteIsAutoReporting(Session* session, |
815 const base::DictionaryValue& params, | 815 const base::DictionaryValue& params, |
816 std::unique_ptr<base::Value>* value) { | 816 std::unique_ptr<base::Value>* value) { |
817 value->reset(new base::FundamentalValue(session->auto_reporting_enabled)); | 817 value->reset(new base::Value(session->auto_reporting_enabled)); |
818 return Status(kOk); | 818 return Status(kOk); |
819 } | 819 } |
820 | 820 |
821 Status ExecuteSetAutoReporting(Session* session, | 821 Status ExecuteSetAutoReporting(Session* session, |
822 const base::DictionaryValue& params, | 822 const base::DictionaryValue& params, |
823 std::unique_ptr<base::Value>* value) { | 823 std::unique_ptr<base::Value>* value) { |
824 bool enabled; | 824 bool enabled; |
825 if (!params.GetBoolean("enabled", &enabled)) | 825 if (!params.GetBoolean("enabled", &enabled)) |
826 return Status(kUnknownError, "missing parameter 'enabled'"); | 826 return Status(kUnknownError, "missing parameter 'enabled'"); |
827 session->auto_reporting_enabled = enabled; | 827 session->auto_reporting_enabled = enabled; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 std::unique_ptr<base::Value>* value) { | 874 std::unique_ptr<base::Value>* value) { |
875 WebView* web_view = nullptr; | 875 WebView* web_view = nullptr; |
876 Status status = session->GetTargetWindow(&web_view); | 876 Status status = session->GetTargetWindow(&web_view); |
877 if (status.IsError()) | 877 if (status.IsError()) |
878 return status; | 878 return status; |
879 status = web_view->DeleteScreenOrientation(); | 879 status = web_view->DeleteScreenOrientation(); |
880 if (status.IsError()) | 880 if (status.IsError()) |
881 return status; | 881 return status; |
882 return Status(kOk); | 882 return Status(kOk); |
883 } | 883 } |
OLD | NEW |