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, const std::vector<std::string>& paths) { |
| 193 Error* error = NULL; |
| 194 RunSessionTask(NewRunnableMethod( |
| 195 automation_.get(), |
| 196 &Automation::DragAndDropFilePaths, |
| 197 current_target_.window_id, |
| 198 location, |
| 199 paths, |
| 200 &error)); |
| 201 return error; |
| 202 } |
| 203 |
191 Error* Session::NavigateToURL(const std::string& url) { | 204 Error* Session::NavigateToURL(const std::string& url) { |
192 Error* error = NULL; | 205 Error* error = NULL; |
193 RunSessionTask(NewRunnableMethod( | 206 RunSessionTask(NewRunnableMethod( |
194 automation_.get(), | 207 automation_.get(), |
195 &Automation::NavigateToURL, | 208 &Automation::NavigateToURL, |
196 current_target_.window_id, | 209 current_target_.window_id, |
197 url, | 210 url, |
198 &error)); | 211 &error)); |
199 return error; | 212 return error; |
200 } | 213 } |
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 current_target_.window_id, | 1278 current_target_.window_id, |
1266 path, | 1279 path, |
1267 &error)); | 1280 &error)); |
1268 if (error) | 1281 if (error) |
1269 return error; | 1282 return error; |
1270 if (!file_util::ReadFileToString(path, png)) | 1283 if (!file_util::ReadFileToString(path, png)) |
1271 return new Error(kUnknownError, "Could not read screenshot file"); | 1284 return new Error(kUnknownError, "Could not read screenshot file"); |
1272 return NULL; | 1285 return NULL; |
1273 } | 1286 } |
1274 | 1287 |
| 1288 Error* Session::GetAttribute(const WebElementId& element, |
| 1289 const std::string& key, Value** value) { |
| 1290 std::string script = base::StringPrintf( |
| 1291 "return (%s).apply(null, arguments);", atoms::GET_ATTRIBUTE); |
| 1292 |
| 1293 ListValue args; |
| 1294 args.Append(element.ToValue()); |
| 1295 args.Append(Value::CreateStringValue(key)); |
| 1296 |
| 1297 Error* error = ExecuteScript(script, &args, value); |
| 1298 if (error) { |
| 1299 return error; |
| 1300 } |
| 1301 |
| 1302 return NULL; |
| 1303 } |
| 1304 |
| 1305 Error* Session::GetClickableLocation(const WebElementId& element, |
| 1306 gfx::Point* location) { |
| 1307 Error* error = CheckElementPreconditionsForClicking(element); |
| 1308 if (error) { |
| 1309 return error; |
| 1310 } |
| 1311 |
| 1312 error = GetElementLocationInView(element, location); |
| 1313 if (error) { |
| 1314 return error; |
| 1315 } |
| 1316 |
| 1317 gfx::Size size; |
| 1318 error = GetElementSize(current_target(), element, &size); |
| 1319 if (error) { |
| 1320 return error; |
| 1321 } |
| 1322 |
| 1323 location->Offset(size.width() / 2, size.height() / 2); |
| 1324 return NULL; |
| 1325 } |
| 1326 |
1275 } // namespace webdriver | 1327 } // namespace webdriver |
OLD | NEW |