| 317 | } |
| 318 | |
| 319 | int InputManager::PointerMoveTo(BrowserHandle browser_wrapper, |
| 320 | const Json::Value& move_to_action, |
| 321 | InputState* input_state) { |
| 322 | LOG(TRACE) << "Entering InputManager::PointerMoveTo"; |
| 323 | int status_code = WD_SUCCESS; |
| 324 | bool element_specified = false; |
| 325 | std::string origin = "viewport"; |
| 326 | if (move_to_action.isMember("origin")) { |
| 327 | Json::Value origin_value = move_to_action["origin"]; |
| 328 | if (origin_value.isString()) { |
| 329 | origin = origin_value.asString(); |
| 330 | } else if (origin_value.isObject() && origin_value.isMember(JSON_ELEMENT_PROPERTY_NAME)) { |
| 331 | origin = origin_value[JSON_ELEMENT_PROPERTY_NAME].asString(); |
| 332 | element_specified = true; |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | long x_offset = 0; |
| 337 | if (move_to_action.isMember("x") && move_to_action["x"].isInt()) { |
| 338 | x_offset = move_to_action["x"].asInt(); |
| 339 | } |
| 340 | |
| 341 | long y_offset = 0; |
| 342 | if (move_to_action.isMember("y") && move_to_action["y"].isInt()) { |
| 343 | y_offset = move_to_action["y"].asInt(); |
| 344 | } |
| 345 | |
| 346 | bool offset_specified = move_to_action.isMember("x") && |
| 347 | move_to_action.isMember("y") && |
| 348 | (x_offset != 0 || y_offset != 0); |
| 349 | |
| 350 | long duration = 100; |
| 351 | if (move_to_action.isMember("duration") && move_to_action["duration"].isInt()) { |
| 352 | duration = move_to_action["duration"].asInt(); |
| 353 | } |
| 354 | |
| 355 | ElementHandle target_element; |
| 356 | if (element_specified) { |
| 357 | status_code = this->element_map_->GetManagedElement(origin, &target_element); |
| 358 | if (status_code != WD_SUCCESS) { |
| 359 | return status_code; |
| 360 | } |
| 361 | } |
| 362 | if (this->action_simulator_->UseExtraInfo()) { |
| 363 | MouseExtraInfo* extra_info = new MouseExtraInfo(); |
| 364 | if (element_specified) { |
| 365 | extra_info->element = target_element->element(); |
| 366 | } else { |
| 367 | extra_info->element = NULL; |
| 368 | } |
| 369 | extra_info->offset_specified = offset_specified; |
| 370 | extra_info->offset_x = x_offset; |
| 371 | extra_info->offset_y = y_offset; |
| 372 | INPUT mouse_input; |
| 373 | mouse_input.type = INPUT_MOUSE; |
| 374 | mouse_input.mi.dwFlags = MOUSEEVENTF_MOVE; |
| 375 | mouse_input.mi.dx = 0; |
| 376 | mouse_input.mi.dy = 0; |
no test coverage detected