Skip to content

Commit

Permalink
Merge pull request #26 from itaibh/fluent_api
Browse files Browse the repository at this point in the history
Fluent API and other fixes.
  • Loading branch information
itaibh authored Jul 30, 2018
2 parents 09e4f2b + 2528cea commit 4d95679
Show file tree
Hide file tree
Showing 46 changed files with 1,374 additions and 616 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
},
"require": {
"php": ">=5.6.0",
"facebook/webdriver": "^1.4.1",
"gregwar/image": "^2.0"
"facebook/webdriver": "^1.6.0"
},
"suggest": {
"phpunit/phpunit": "To run your tests"
Expand Down
2 changes: 1 addition & 1 deletion eyes.common.php/EyesScreenshot.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected abstract function convertLocation(Location $location, $from, $to);
* @param string $coordinatesType The coordinates type of {@code location}.
* @return Location The corresponding location inside the screenshot,
* in screenshot as-is coordinates type.
* @throws /Applitools/Exceptions/OutOfBoundsException If the location is
* @throws \Applitools\Exceptions\OutOfBoundsException If the location is
* not inside the frame's region in the screenshot.
*/
public abstract function getLocationInScreenshot(Location $location, $coordinatesType);
Expand Down
4 changes: 3 additions & 1 deletion eyes.common.php/logging/PrintLogHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public function open() {}

public function onMessage($verbose, $message) {
if (!$verbose || $this->isVerbose) {
print_r(date("H:i:s") . " Eyes: " . $message. "\r\n");
$t = gettimeofday();
$mSec = round($t["usec"] / 1000);
print_r(date("H:i:s",$t["sec"]). ".$mSec Eyes: " . $message. PHP_EOL);
}
}

Expand Down
84 changes: 82 additions & 2 deletions eyes.common.php/match/ImageMatchSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ class ImageMatchSettings
/** @var FloatingMatchSettings[] */
private $floatingMatchSettings = [];

/** @var Region[] */
private $layoutRegions = [];

/** @var Region[] */
private $strictRegions = [];

/** @var Region[] */
private $contentRegions = [];

// /** @var Region[] */
// private $exactRegions = [];


public function __construct($matchLevel = null, ExactMatchSettings $exact = null)
{
Expand Down Expand Up @@ -122,11 +134,79 @@ public function setFloatingMatchSettings($floatingMatchSettings)
$this->floatingMatchSettings = $floatingMatchSettings;
}

public function getIgnoreRegionsAsFormattedArray()
/**
* @return Region[]
*/
public function getLayoutRegions()
{
return $this->layoutRegions;
}

/**
* @param Region[] $layoutRegions
*/
public function setLayoutRegions($layoutRegions)
{
$this->layoutRegions = $layoutRegions;
}

/**
* @return Region[]
*/
public function getStrictRegions()
{
return $this->strictRegions;
}

/**
* @param Region[] $strictRegions
*/
public function setStrictRegions($strictRegions)
{
$this->strictRegions = $strictRegions;
}

/**
* @return Region[]
*/
public function getContentRegions()
{
return $this->contentRegions;
}

/**
* @param Region[] $contentRegions
*/
public function setContentRegions($contentRegions)
{
$this->contentRegions = $contentRegions;
}

// /**
// * @return Region[]
// */
// public function getExactRegions()
// {
// return $this->exactRegions;
// }
//
// /**
// * @param Region[] $exactRegions
// */
// public function setExactRegions($exactRegions)
// {
// $this->exactRegions = $exactRegions;
// }

/**
* @param Region[] $regions
* @return array
*/
public function getRegionsAsFormattedArray($regions)
{
$retVal = [];

foreach ($this->ignoreRegions as $r) {
foreach ($regions as $r) {
$retVal[] = [
"left" => $r->getLeft(),
"top" => $r->getTop(),
Expand Down
15 changes: 12 additions & 3 deletions eyes.common.php/server/ServerConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,13 @@ public function matchWindow(RunningSession $runningSession, MatchWindowData $mat
return $result;
}

/**
* @param RunningSession $runningSession
* @param bool $isAborted
* @param bool $save
* @return TestResults
* @throws Exception
*/
public function stopSession(RunningSession $runningSession, $isAborted, $save)
{
ArgumentGuard::notNull($runningSession, "runningSession");
Expand Down Expand Up @@ -321,7 +328,11 @@ private function getImageMatchSettingsAsFormattedArray(ImageMatchSettings $match
$retVal = [
"matchLevel" => $matchSettings->getMatchLevel(),
"ignoreCaret" => $matchSettings->isIgnoreCaret(),
"ignore" => $matchSettings->getIgnoreRegionsAsFormattedArray(),
"ignore" => $matchSettings->getRegionsAsFormattedArray($matchSettings->getIgnoreRegions()),
"layout" => $matchSettings->getRegionsAsFormattedArray($matchSettings->getLayoutRegions()),
"strict" => $matchSettings->getRegionsAsFormattedArray($matchSettings->getStrictRegions()),
//"exact" => $matchSettings->getRegionsAsFormattedArray($matchSettings->getExactRegions()),
"content" => $matchSettings->getRegionsAsFormattedArray($matchSettings->getContentRegions()),
"floating" => $matchSettings->getFloatingMatchSettingsAsFormattedArray()
];

Expand All @@ -338,5 +349,3 @@ private function getImageMatchSettingsAsFormattedArray(ImageMatchSettings $match
return $retVal;
}
}

?>
Loading

0 comments on commit 4d95679

Please sign in to comment.