|
| 1 | +<?php |
| 2 | +// Copyright 2011-present Element 34 |
| 3 | +// |
| 4 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +// you may not use this file except in compliance with the License. |
| 6 | +// You may obtain a copy of the License at |
| 7 | +// |
| 8 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +// |
| 10 | +// Unless required by applicable law or agreed to in writing, software |
| 11 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +// See the License for the specific language governing permissions and |
| 14 | +// limitations under the License. |
| 15 | + |
| 16 | +include_once('WebDriverActionChains.php'); |
| 17 | + |
| 18 | +class PHPWebDriver_WebDriverTouchActions extends PHPWebDriver_WebDriverActionChains { |
| 19 | + |
| 20 | + public function __construct($session) { |
| 21 | + parent::__construct($session); |
| 22 | + } |
| 23 | + |
| 24 | + public function single_tap($element, $curl_opts = array()) { |
| 25 | + $this->actions[] = "return \$this->session->touch()->click(array('element' => '" . $element->getID() . "'), " . unwind_associated_array($curl_opts) . ");"; |
| 26 | + return $this; |
| 27 | + } |
| 28 | + |
| 29 | + public function down($x, $y, $curl_opts = array()) { |
| 30 | + $this->actions[] = "return \$this->session->touch()->down(array('x' => " . $x . ", 'y' => " . $y . "), " . unwind_associated_array($curl_opts) . ");"; |
| 31 | + return $this; |
| 32 | + } |
| 33 | + |
| 34 | + public function move($x, $y, $curl_opts = array()) { |
| 35 | + $this->actions[] = "return \$this->session->touch()->move(array('x' => " . $x . ", 'y' => " . $y . "), " . unwind_associated_array($curl_opts) . ");"; |
| 36 | + return $this; |
| 37 | + } |
| 38 | + |
| 39 | + public function up($x, $y, $curl_opts = array()) { |
| 40 | + $this->actions[] = "return \$this->session->touch()->up(array('x' => " . $x . ", 'y' => " . $y . "), " . unwind_associated_array($curl_opts) . ");"; |
| 41 | + return $this; |
| 42 | + } |
| 43 | + |
| 44 | + public function element_scroll($element, $xoffset, $yoffset, $curl_opts = array()) { |
| 45 | + $this->actions[] = "return \$this->session->touch()->scroll(array('element' => '" . $element->getID() . "', 'xoffset' => " . $xoffset . ", 'yoffset' => " . $yoffset . "), " . unwind_associated_array($curl_opts) . ");"; |
| 46 | + return $this; |
| 47 | + } |
| 48 | + |
| 49 | + public function scroll($xoffset, $yoffset, $curl_opts = array()) { |
| 50 | + $this->actions[] = "return \$this->session->touch()->scroll(array('xoffset' => " . $xoffset . ", 'yoffset' => " . $yoffset . "), " . unwind_associated_array($curl_opts) . ");"; |
| 51 | + return $this; |
| 52 | + } |
| 53 | + |
| 54 | + public function double_tap($element, $curl_opts = array()) { |
| 55 | + $this->actions[] = "return \$this->session->touch()->doubleclick(array('element' => '" . $element->getID() . "'), " . unwind_associated_array($curl_opts) . ");"; |
| 56 | + return $this; |
| 57 | + } |
| 58 | + |
| 59 | + public function long_tap($element, $curl_opts = array()) { |
| 60 | + $this->actions[] = "return \$this->session->touch()->longclick(array('element' => '" . $element->getID() . "'), " . unwind_associated_array($curl_opts) . ");"; |
| 61 | + return $this; |
| 62 | + } |
| 63 | + |
| 64 | + public function flick($xspeed, $yspeed, $curl_opts = array()) { |
| 65 | + $this->actions[] = "return \$this->session->touch()->flick(array('xspeed' => " . $xspeed . ", 'yspeed' => " . $yspeed . "), " . unwind_associated_array($curl_opts) . ");"; |
| 66 | + return $this; |
| 67 | + } |
| 68 | + |
| 69 | + public function element_flick($element, $xoffset, $yoffset, $speed, $curl_opts = array()) { |
| 70 | + $this->actions[] = "return \$this->session->touch()->flick(array('element' => '" . $element->getID() . "', 'xoffset' => " . $xoffset . ", 'yoffset' => " . $yoffset . ", 'speed' => " . $speed . "), " . unwind_associated_array($curl_opts) . ");"; |
| 71 | + return $this; |
| 72 | + } |
| 73 | +} |
| 74 | + |
0 commit comments