Skip to content

Commit

Permalink
WIP: try to add option -picturesRatio
Browse files Browse the repository at this point in the history
it could help on #103, but it' not completed yet
(PrinterPictures::_picturesRatio is still not used)
  • Loading branch information
gturri committed Mar 24, 2020
1 parent d0c6b6f commit 2aa4a8c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 22 additions & 0 deletions _tests/src/test/java/nspages/printers/Test_pictures.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static org.junit.Assert.assertEquals;

import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement;

import nspages.Helper;
Expand Down Expand Up @@ -67,6 +68,27 @@ public void withoutModificationDateOption(){
}
}

@Test
public void withoutRatio() {
generatePage("pictures:start", "<nspages -exclude -usePictures>");
Dimension dimension = getPictureLinks().get(0).getSize();
assertEquals(240.0, dimension.height, 10);
assertEquals(300.0, dimension.width, 10);
}

@Test
public void withRatio() {
generatePage("pictures:start", "<nspages -exclude -usePictures -picturesRatio = \"0.5\">");
Dimension dimension = getPictureLinks().get(0).getSize();
assertEquals(120, dimension.height, 10);
assertEquals(300, dimension.width, 10);
}

@Test
public void withNonIntegerRatio() {
//TODO
}

private List<WebElement> getPictureLinks(){
WebElement wrapper = getDriver().findElement(By.className("nspagesPicturesModeMain"));
return wrapper.findElements(By.tagName("a"));
Expand Down
4 changes: 2 additions & 2 deletions optionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ static function checkNbColumns(&$match, &$varAffected){
}

static function checkPictureRatio(&$match, &$varAffected){
if(optionParser::preg_match_wrapper("pictures?Ratio *=? *\"?([[:digit:]]*)\"?", $match, $found)) {
if(optionParser::preg_match_wrapper("pictures?Ratio *=? *\"?([.[:digit:]]*)\"?", $match, $found)) {
if($found[1] != '') {
$varAffected = (int) $found[1];
$varAffected = (double) $found[1];
if ($varAffected <= 0){
$varAffected = 0.01;
}
Expand Down

0 comments on commit 2aa4a8c

Please sign in to comment.