OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webdriver/session.h" | 5 #include "chrome/test/webdriver/session.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 181 } |
182 error = NULL; | 182 error = NULL; |
183 RunSessionTask(NewRunnableMethod( | 183 RunSessionTask(NewRunnableMethod( |
184 this, | 184 this, |
185 &Session::SendKeysOnSessionThread, | 185 &Session::SendKeysOnSessionThread, |
186 keys, | 186 keys, |
187 &error)); | 187 &error)); |
188 return error; | 188 return error; |
189 } | 189 } |
190 | 190 |
| 191 Error* Session::DragAndDropFilePaths( |
| 192 const gfx::Point& location, |
| 193 const std::vector<FilePath::StringType>& paths) { |
| 194 Error* error = NULL; |
| 195 RunSessionTask(NewRunnableMethod( |
| 196 automation_.get(), |
| 197 &Automation::DragAndDropFilePaths, |
| 198 current_target_.window_id, |
| 199 location, |
| 200 paths, |
| 201 &error)); |
| 202 return error; |
| 203 } |
| 204 |
191 Error* Session::NavigateToURL(const std::string& url) { | 205 Error* Session::NavigateToURL(const std::string& url) { |
192 Error* error = NULL; | 206 Error* error = NULL; |
193 RunSessionTask(NewRunnableMethod( | 207 RunSessionTask(NewRunnableMethod( |
194 automation_.get(), | 208 automation_.get(), |
195 &Automation::NavigateToURL, | 209 &Automation::NavigateToURL, |
196 current_target_.window_id, | 210 current_target_.window_id, |
197 url, | 211 url, |
198 &error)); | 212 &error)); |
199 return error; | 213 return error; |
200 } | 214 } |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 if (!automation_.get()) | 924 if (!automation_.get()) |
911 return NULL; | 925 return NULL; |
912 Error* error = NULL; | 926 Error* error = NULL; |
913 RunSessionTask(NewRunnableMethod( | 927 RunSessionTask(NewRunnableMethod( |
914 automation_.get(), | 928 automation_.get(), |
915 &Automation::WaitForAllTabsToStopLoading, | 929 &Automation::WaitForAllTabsToStopLoading, |
916 &error)); | 930 &error)); |
917 return error; | 931 return error; |
918 } | 932 } |
919 | 933 |
| 934 Error* Session::GetAttribute(const WebElementId& element, |
| 935 const std::string& key, Value** value) { |
| 936 std::string script = base::StringPrintf( |
| 937 "return (%s).apply(null, arguments);", atoms::GET_ATTRIBUTE); |
| 938 |
| 939 ListValue args; |
| 940 args.Append(element.ToValue()); |
| 941 args.Append(Value::CreateStringValue(key)); |
| 942 |
| 943 Error* error = ExecuteScript(script, &args, value); |
| 944 if (error) { |
| 945 return error; |
| 946 } |
| 947 |
| 948 return NULL; |
| 949 } |
| 950 |
| 951 Error* Session::GetClickableLocation(const WebElementId& element, |
| 952 gfx::Point* location) { |
| 953 Error* error = CheckElementPreconditionsForClicking(element); |
| 954 if (error) { |
| 955 return error; |
| 956 } |
| 957 |
| 958 error = GetElementLocationInView(element, location); |
| 959 if (error) { |
| 960 return error; |
| 961 } |
| 962 |
| 963 gfx::Size size; |
| 964 error = GetElementSize(current_target(), element, &size); |
| 965 if (error) { |
| 966 return error; |
| 967 } |
| 968 |
| 969 location->Offset(size.width() / 2, size.height() / 2); |
| 970 return NULL; |
| 971 } |
| 972 |
920 const std::string& Session::id() const { | 973 const std::string& Session::id() const { |
921 return id_; | 974 return id_; |
922 } | 975 } |
923 | 976 |
924 const FrameId& Session::current_target() const { | 977 const FrameId& Session::current_target() const { |
925 return current_target_; | 978 return current_target_; |
926 } | 979 } |
927 | 980 |
928 void Session::set_async_script_timeout(int timeout_ms) { | 981 void Session::set_async_script_timeout(int timeout_ms) { |
929 async_script_timeout_ = timeout_ms; | 982 async_script_timeout_ = timeout_ms; |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 path, | 1319 path, |
1267 &error)); | 1320 &error)); |
1268 if (error) | 1321 if (error) |
1269 return error; | 1322 return error; |
1270 if (!file_util::ReadFileToString(path, png)) | 1323 if (!file_util::ReadFileToString(path, png)) |
1271 return new Error(kUnknownError, "Could not read screenshot file"); | 1324 return new Error(kUnknownError, "Could not read screenshot file"); |
1272 return NULL; | 1325 return NULL; |
1273 } | 1326 } |
1274 | 1327 |
1275 } // namespace webdriver | 1328 } // namespace webdriver |
OLD | NEW |