WebDriverCoordinates.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. // Copyright 2004-present Facebook. All Rights Reserved.
  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. namespace Facebook\WebDriver\Interactions\Internal;
  16. use Facebook\WebDriver\Exception\UnsupportedOperationException;
  17. use Facebook\WebDriver\WebDriverPoint;
  18. /**
  19. * Interface representing basic mouse operations.
  20. */
  21. class WebDriverCoordinates
  22. {
  23. /**
  24. * @var null
  25. */
  26. private $onScreen;
  27. /**
  28. * @var callable
  29. */
  30. private $inViewPort;
  31. /**
  32. * @var callable
  33. */
  34. private $onPage;
  35. /**
  36. * @var string
  37. */
  38. private $auxiliary;
  39. /**
  40. * @param null $on_screen
  41. * @param callable $in_view_port
  42. * @param callable $on_page
  43. * @param string $auxiliary
  44. */
  45. public function __construct($on_screen, callable $in_view_port, callable $on_page, $auxiliary)
  46. {
  47. $this->onScreen = $on_screen;
  48. $this->inViewPort = $in_view_port;
  49. $this->onPage = $on_page;
  50. $this->auxiliary = $auxiliary;
  51. }
  52. /**
  53. * @throws UnsupportedOperationException
  54. * @return WebDriverPoint
  55. */
  56. public function onScreen()
  57. {
  58. throw new UnsupportedOperationException(
  59. 'onScreen is planned but not yet supported by Selenium'
  60. );
  61. }
  62. /**
  63. * @return WebDriverPoint
  64. */
  65. public function inViewPort()
  66. {
  67. return call_user_func($this->inViewPort);
  68. }
  69. /**
  70. * @return WebDriverPoint
  71. */
  72. public function onPage()
  73. {
  74. return call_user_func($this->onPage);
  75. }
  76. /**
  77. * @return string The attached object id.
  78. */
  79. public function getAuxiliary()
  80. {
  81. return $this->auxiliary;
  82. }
  83. }